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
Shell1234567mkdir /usr/varcd /vartar cvf - . | (cd /usr/var; tar xvf - )cd /chflags -R noschg /varrm -rf /varln -s /usr/var /var
- Move /tmp to /usr/var/tmp
Shell123456789mkdir /usr/var/tmpcd /tmptar cvf - . | (cd /usr/var/tmp; tar xvf - )cd /chflags -R noschg /tmprm -rf /tmpln -s /usr/var/tmp /tmpchmod -h 777 /tmpchmod 1777 /usr/var/tmp