One one of the first things I do on a newly installed FreeBSD system is to move /var and /tmp to under /usr. Since I usually allocate about 4Gb for the root slice and the rest of a disk—usually several hundred gigabytes—goes to /usr (well, there’s also the swap slice that takes few gigabytes) having /var and /tmp there is more comfortable as some log files, database files, or some temp files can sometimes grow to multi-gigabyte size and exhaust the root space.
Below is a simple procedure to move the /var to /usr/var and /tmp to /usr/var/tmp. This is best to do early on in a new system installation since many services tend to hook into /tmp and/or /var, and may thus lock files in those directories making the move more difficult. If you’re making this move on an established system, at least stop all the services that might interfere with the process (such as database services). It might even be a good idea to boot into a single user mode (if you do so, remember to correctly mount your disks before proceeding). I usually do this early in a new system install, before installing any major services, or at least before scripting them to run.
- Move /var to /usr/var
mkdir /usr/var cd /var tar cvf - . | (cd /usr/var; tar xvf - ) cd / chflags -R noschg /var rm -rf /var ln -s /usr/var /var
- Move /tmp to /usr/var/tmp
mkdir /usr/var/tmp cd /tmp tar cvf - . | (cd /usr/var/tmp; tar xvf - ) cd / chflags -R noschg /tmp rm -rf /tmp ln -s /usr/var/tmp /tmp chmod -h 777 /tmp chmod 1777 /usr/var/tmp