Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Dec 2006 11:40:34 -0500
From:      Jerry McAllister <>
To:        Bradley Giesbrecht <>
Subject:   Re: var out of space
Message-ID:  <>
In-Reply-To: <>
References:  <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help

> Hello,
> I inherited a freebsd installation with a var slice/mount that is to  
> small and filling up all the time.
> What type of info should I provide to allow someone to help me with a  
> solution?
> I would very much prefer to not install another drive just for /var.
> /usr has plenty of space. Can I mount var off of /usr?
> Here is the output of df for starters:
> /dev/ad0s1a    128990  119970    -1298   101%    /
> /dev/ad0s1f    257998  185246    52114    78%    /tmp
> /dev/ad0s1g 112755734 4533434 99201842     4%    /usr
> /dev/ad0s1e    257998  206956    30404    87%    /var
> procfs              4       4        0   100%    /proc

You are right, whoever built that machine put all the spare space 
in to /usr (wouldn't be my choice, but...) so you can make use of
that space.

The first thing to do is to figure out what is using the space.
use du(1) for that.
probably something like:      (NOTE: do this as root or single user)
  cd /var
  du -sk *

The most like culprits are /var/mail,  var/spool,  /var/log,  and /var/db
Rather than moving all of /var in to /usr, just move the worst of
those and make symlinks.

Of course you might also want to clean up some of the stuff, for example
if /var/log is taking up all the space, use newsyslog(8) to manage
rotation of logs and clearing of old logs.

But, really your /var is too small so even after you clean up you will
have to move some things.

For example, you can move /var/spool to /usr by:

  cd /var/spool
  tar cpf /usr/spool.tar *
  cd /usr
  mkdir var.spool
  cd var.spool
  tar xpf ../spool.tar
  cd /var
  mv spool old-spool
  ln -s /usr/var.spool spool
Now check things out by doing looking around:   cd /var/spool  should
get you to /usr/var.spool and find all the files in place.  When you
are convinced it is good, then:
  cd /var
  rm -rf old-spool
You might just find some files it refused to rm because flags are
set on them, particularly 'schg'  so you will have to unset those
flags to nuke the files.  
  chflags noschg file_name    for example
Then remove those files by hand.
See chflags(1)

At this point you would have /var/spool actually living in /usr
with no problem.

NOTE that doing the tar to a file and then untarring and also moving 
/var/spool to a different file and checking things first is being a
little more careful(chicken) than absolutely necessary, but I prefer
being safe.   Also, my naming convention (making the directory be
var.spool) helps me keep track of things sort of like using mnemonic
variable names.

This doesn't muck with your partition layout like moving all of /var
in to /usr would.

But, if you really want to move all of /var to /usr and change the
mounts, then use dump/restore as follows:

  cd /usr
  mkdir newvar
  cd newvar
  dump 0af - /var | restore -rf -
  umount /var
  cd /etc
Edit /etc/fstab to remove or comment out the /var line 
  cd /
  rmdir var
  ln -s /usr/newvar var
Check it out - it should work just fine.

Of course, you don't have to use the name 'newvar' for the
directory name in /usr, but it makes it clearer what happened.
Now the 260MB in the ad0s1e partition will be essentially unused
for anything unless you mount it as something else.
I really think the former solution is a little better, but either 
will work.

NOTE also that a possibly better overall solution that either is to 
completely reinstall FreeBSD from scratch and completely reorganize 
your disk at the same time especially if it is below version 6.1.
Of course, you would want to make complete backups before doing that
so you can put what parts of your data you want to keep back on after
the installation.

But, if you are new to FreeBSD, just moving a couple of things to free
up space in /var will easily give you time to play around and become 
familiar and then you can do the complete re-install later when you 
have a better picture of what you want and after 6.2 RELEASE comes out.

> and ls -la at / looks like this:
> -rw-r--r--   2 root  wheel      802 May 25  2004 .cshrc
> -rw-r--r--   2 root  wheel      251 May 25  2004 .profile
> -r--r--r--   1 root  wheel     6355 May 25  2004 COPYRIGHT
> drwxr-xr-x   2 root  wheel     1024 Nov 29 17:39 bin
> drwxr-xr-x   3 root  wheel      512 Nov  5 15:27 boot
> drwxr-xr-x   2 root  wheel      512 Jan 16  2005 cdrom
> lrwxr-xr-x   1 root  wheel       10 Jan 16  2005 compat -> usr/compat
> drwxr-xr-x   3 root  wheel    20480 Jan 16  2005 dev
> drwxr-xr-x  16 root  wheel     2560 Dec  1 16:11 etc
> lrwxrwxrwx   1 root  wheel        9 Jan 16  2005 home -> /usr/home
> -r-xr-xr-x   1 root  wheel  4344469 Nov  5 13:22 kernel
> -r-xr-xr-x   1 root  wheel  4344469 Nov  5 13:22 kernel.GENERIC
> drwxr-xr-x   2 root  wheel      512 May 25  2004 mnt
> drwxr-xr-x   2 root  wheel     4608 Nov  5 13:22 modules
> dr-xr-xr-x   1 root  wheel      512 Dec 17 01:10 proc
> drwxr-xr-x   3 root  wheel      512 Nov  5 13:36 root
> drwxr-xr-x   2 root  wheel     2048 Nov  5 15:27 sbin
> drwxr-xr-x   4 root  wheel     1024 Jan 16  2005 stand
> lrwxr-xr-x   1 root  wheel       11 Nov  5 15:27 sys -> usr/src/sys
> drw-------   7 root  wheel     2048 Dec 17 01:09 tmp
> drwxr-xr-x  18 root  wheel      512 Jan 16  2005 usr
> drwxr-xr-x  21 root  wheel      512 Nov  6 11:54 var

That doesn't affect anything.   It looks about normal.

The only problem is that you need more space in root or something
cleaned out.   Do a du -sk * in root to see what is hogging
all the space.    Also, you might want to use the -F flag on ls
as in ls -laF so it marks the directories for you.  Makes it easier
to see what is going on.


> Thanks for any help,
> Brad
> _______________________________________________
> mailing list
> To unsubscribe, send any mail to ""

Want to link to this message? Use this URL: <>