Red Antigua Logo
Yet another piece of web.
Search this site (by Google)
Tools    (top)
Check a site for broken links
(W3C)

Perl modules    (top)
Tree::Numbered::Tools
(CPAN)
Perl tutorials    (top)
Perl modules
HTML::Template
CGI::Application
Cookies with CGI::Application
Upload files with CGI::Application
Download files with CGI::Application
Redirect with CGI::Application
CPAN shell
Install DBD::mysql from the CPAN shell
Perl trim function
Validate an IP with Perl
Run suid Perl scripts under Apache
Perl taint mode
Perl date functions with Date::Calc

In Spanish
Curso de Perl

C tutorials    (top)
C - Introduction
C - Absolute beginner's Emacs
C - Examples for beginners
C - Makefile examples
C - Autotools examples
Server configurations    (top)
DNS
Apache
Apache Authentication and Access Control
mod_perl on FreeBSD
MySQL
MySQL add account
phpMyAdmin
Squid
DHCP

UNIX on Windows    (top)
MSYS2 - UNIX environment for MS Windows 32/64 bits
Apache setup on Windows
MySQL setup on Windows
PHP setup on Windows
Perl setup on Windows
Emacs setup on Windows
PuTTY
WinSCP
GIMP on Windows
MinGW - gcc on Windows
MSYS - UNIX-styled shell on Windows
msysDTK - autotools on Windows
GDB for MinGW on Windows

Misc. FreeBSD/UNIX    (top)
'portupgrade' on FreeBSD
'ipf' on FreeBSD
'pf' on FreeBSD
'su' on FreeBSD
Mount an ISO image under FreeBSD
Load the correct sound driver under FreeBSD without knowing what sound card you are using
Simultaneous sound channels on FreeBSD
FreeBSD network stuff
DOS-to-UNIX file conversion
favicon.ico on UNIX
Emacs tips
Command Line Calculator
Save multimedia streams with 'mplayer'
xargs - solution to 'Argument list too long'
Process multiple images from the command line using 'ImageMagick'
Turn the system bell off under X Windows
Process each line in an input file from the command line (or in a shell script)
How to keep a program running in the background using 'nohup'
How to remove symbolic links in the current directory using 'find' and 'rm'
How to remove Emacs backup files in the current directory and all subdirectories using 'find' and 'rm'
How to execute .profile without logging in
Configure X to handle non-English characters
How to move /var to /usr/var

Redirect a web page    (top)
Redirect to another web page
Apache redirect
C redirect
Perl redirect
PHP redirect
HTML redirect
JavaScript redirect

Javascript    (top)
Trim function
Login form
Register form
Popup window

How to move /var to /usr/var on FreeBSD
How to move /var to /usr/var on FreeBSD

This has been tested on a FreeBSD 7.2 box.

This is the default FreeBSD partition layout:
/
/usr
/var
/tmp
When I installed FreeBSD 7.2, instead I chose the following layout...
/
/usr
... and then I moved /var and /tmp to /usr/.
And after that, symlinking:
/var -> /usr/var
/tmp -> /usr/tmp

Most probably there are arguments against this layout, but I prefer the advantages of having a bigger /usr partition instead of waisting space on separate /var and /tmp partitions. Another advantage is that the risk of causing a full file system on /var (for example by a big temporary file such as a kernel dump) is smaller on a big partition. Anyway, filling up the root partition with temporary files is never a good idea, so /var and /tmp should not be left on the root partition, but moved to /usr/ instead.

Boot/reboot FreeBSD into Single User Mode (boot menu option 4 on FreeBSD 7.2).
When prompted Enter full pathname of shell or RETURN for /bin/sh:
Press ENTER to enter the shell.
Then execute the following commands:
mount -u /                    # re-mount root partition as read-write
mount -a                      # mount all partitions in fstab
chflags noschg /var/empty     # unset the schg flag for /var/empty
mv /var /usr/                 # move /var to /usr/, be prepared for lots of ... is a socket (not copied). messages!
chflags schg /usr/var/empty   # set the schg flag for /usr/var/empty
mv /tmp /usr/                 # move /tmp to /usr/
cd /                          # prepare for symlinking
ln -s /usr/var                # symlink /var
ln -s /usr/tmp                # symlink /tmp
Done!

Then, either
exit                # exit to multiuser mode
or
reboot              # reboot the system
to start using /usr/var and /usr/var.

Note:
The schg flag is used to assure that nobody, not even root, will modify a file or directory.
Use ls -lo to display flags set by chflags:
$ ls -lo /var/
total 46
drwxr-xr-x   2 root    wheel   -     512 May  1 08:53 account
drwxr-xr-x   4 root    wheel   -     512 May  1 10:59 at
drwxr-x---   2 root    audit   -     512 May  1 08:53 audit
drwxr-x---   2 root    wheel   -     512 May 10 03:01 backups
drwxr-xr-x   4 root    wheel   -     512 May  5 07:35 cache
drwxr-x---   2 root    wheel   -     512 Jun  1 12:13 crash
drwxr-x---   3 root    wheel   -     512 May  1 10:59 cron
drwxr-xr-x  11 root    wheel   -     512 May  6 00:52 db
dr-xr-xr-x   2 root    wheel   schg  512 May  1 08:53 empty
drwxrwxr-x   2 root    games   -     512 May  5 02:59 games
drwxrwx--T   2 root    gdm     -     512 May  5 02:30 gdm
drwx------   2 root    wheel   -     512 May  1 08:53 heimdal
drwxr-xr-x   9 root    wheel   -     512 May  9 16:22 lib
drwxr-xr-x   5 root    wheel   -    1536 Jun  3 00:00 log
drwxrwxr-x   2 root    mail    -     512 Jun  2 03:04 mail
drwxr-xr-x   2 daemon  wheel   -     512 May  5 01:05 msgs
drwxr-xr-x   5 root    wheel   -     512 May  5 02:50 named
drwxr-xr-x   2 root    wheel   -     512 May  1 08:53 preserve
drwxr-xr-x  12 root    wheel   -     512 Jun  2 21:48 run
drwxrwxr-x   2 root    daemon  -     512 May  1 08:53 rwho
drwxr-xr-x   9 root    wheel   -     512 May  5 07:35 spool
drwxrwxrwt  27 root    wheel   -    1536 Jun  2 23:16 tmp
drwxr-xr-x   2 root    wheel   -     512 May  5 02:50 yp

Read more
The chflags(1) man page.

Last modified: Wed Sep 7 06:38:43 EDT 2016