nutznboltz
June 10th, 2004, 09:58
I just upgraded a box from FreeBSD-4-STABLE to FreeBSD-5.2.1-RELEASE for the first time. I used CVS to get the RELENG_5_2 branch and then compiled and installed the source code. Don't try this yourself unless you are will to muck with the bootstrap changeover.

During the upgrade the I noticed that I was now using the root filesystem for /tmp space since the FreeBSD-4-STABLE used mfs /tmp space. Can't do that on Fbsd-5 so I came up with a script you can drop into /etc/rc.d to use md /tmp. That way you can have faster /tmp space.

$ cat /etc/rc.d/md_tmp
#! /bin/sh

# PROVIDE: tmp
# REQUIRE: addswap
# BEFORE: sysctl
# KEYWORD: FreeBSD

. /etc/rc.subr

name="md_tmp"
start_cmd="md_tmp_start"
stop_cmd=":"

md_tmp_start()
{
mdconfig -a -t swap -s 256M -u 10
newfs -U /dev/md10
mount /dev/md10 /tmp
chmod 1777 /tmp
}

load_rc_config $name
run_rc_command "$1"
in operation:
$ df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/da0s1a 126M 56M 60M 48% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/da0s1e 252M 60M 172M 26% /var
/dev/da0s1f 9.8G 5.0G 4.0G 56% /home
/dev/da0s1g 24G 5.1G 17G 23% /usr
procfs 4.0K 4.0K 0B 100% /proc
/dev/md10 252M 16K 232M 0% /tmp

nutznboltz
June 11th, 2004, 20:00
Note that md isn't a RAM disk in the classic sense of grabbing memory for only the disk, it's a VM disk that demand pages so it doesn't waste memory when it's not using the memory for active items in the filesystem.

elmore
June 11th, 2004, 22:57
Hey that's really cool nutznboltz thanks a lot for posting that!

schotty
June 13th, 2004, 19:28
Thanks man, gonna have to try that whenever I get a 5.x box up and going.