Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Feb 2008 11:55:46 -0500
From:      Jerry McAllister <jerrymc@msu.edu>
To:        Deian Popov <deianp@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: expanding /usr
Message-ID:  <20080204165546.GE7685@gizmo.acns.msu.edu>
In-Reply-To: <bfc2b10c0802040212u5fb598f7s9f69343a46b75232@mail.gmail.com>
References:  <bfc2b10c0802040212u5fb598f7s9f69343a46b75232@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Feb 04, 2008 at 12:12:49PM +0200, Deian Popov wrote:

> Hello,
> 
> I would like to expand /usr of FreeBSD 6.2. I plan to get a new HDD, format
> it and create slices. But how to proceed after that? Do I just mount it over
> the existing /usr or is there any additional steps that must be performed?

Probably the easiest thing is to create a large partition on the new disk 
and then move some of the big stuff over there and create a symlink 
to it.    /usr/local  and  /usr/src  are often good candidates.

To do that, create the partition using fdisk (for the slice), then 
bsdlabel (for the partitions) and finally newfs to create a filesystem 
on each partition.

Then, mount the partition to a nice mnemonically named mount point.
I often use /work or even /junk, but you choose.
(presuming the new disk is ad0 - second IDE or SATA, your new big
 partition is partition e and you want to mount it as work and /usr/local
 and /usr/src are hogging to much of your /usr space)

  mkdir /work
  mount /dev/ad1s1f /work

Then use tar to move the contents of /usr/local and /usr/src
You can pipe a tar to a tar, but I tend to prefer to tar to a file
and then untar from that file.  I feel safer.

  cd /usr/local
  tar cvpf /work/loc.tar *    (you can skip the 'v' if it annoys you)
  cd /work                    (I use it to see that things are moving)
  mkdir usr.local
  cd usr.local
  tar xvpf ../usr.local

Now, check out the new stuff just to feel confident it got there.
  cd /work/usr.local
     look in some files

Create the sym link
  cd /usr
  mv local old.local
  ln -s /work/usr.local local

Check out the link - do a 'cd /usr/local' and make sure it gets you 
in to /work/usr.local,  

then go back and rm the /usr/old.local  and the  /work/loc.tar and you 
are all set.

Do the same for /usr/src

  cd /usr/src
  tar cvpf /work/src.tar *
  cd /work
  mkdir usr.src
  cd usr.src
  tar xpvf ../usr.tar
Check it out and then,
  cd /usr
  mv src old.src
  ln -s /work/usr.src src
Check out the link
  cd /usr
  rm old.src
  rm /work/usr.tar

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Another way is to make a whole new partition on the new disk just for /usr.
First, determine how much space you need for it. 
Go in to /root and use 'du'

  cd /
  du -sk *    (or du -sm * or whatever multiplier you want, 
               'k' makes it list in kilobytes, 'm' in megabytes, etc)

Multiply the /usr size by about 2 and create at least one partition on
the new disk that suits that size.  - 2 gives room for expansion - if you
plan to do a lot of installing from ports, or whatever, than maybe you
need much more room than that.  I would go for >10 GBytes if you plan
to build a lot of stuff.   

Once you get your new disk sliced, partitioned and filesystems build
and have made mount points and mounted them, then use dump/restore to
move stuff to the new partition and redo the mounts.

  mkdir /newusr          
  mount /dev/ad1s1e /newusr   (presuming it is partition 'e' on SATA disk 1)
  cd /newusr
  dump 0af - /usr | restore -rf -
Take a look at a few files to make sure it all went well.

Fix the mount in fstab and remount /usr and /newusr
  umount /newusr
  umount /usr
  mount /dev/ad1s1e /usr
  vi /etc/fstab    Edit the /usr line so it mounts /dev/ad1s1e instead
                    of /dev/ad0s1f or whatever it is.
Clean up a little
  cd /
  rmdir newusr

You should then be just fine.

You can reuse the /dev/ad0s1f space, formerly mounted as /usr for
something else.   I would suggest [carefully] rm-ing all files in
the old /usr space before trying to use it.    

  cd /
  mkdir /play
  mount /dev/ad0s1f /play       
  cd /play
  pwd          Make sure where you are
  rm -rf *     do this carefully.  If you are in the wrong place
                                   it is a disaster.
  vi /etc/fstab   Edit by dup-ing the /usr line and modifying it
                  to be mounting /dev/ad0s1f on /play but with other
                  info being the same.

Now you have some space in /play you can play with.

By the way, if you are not up-to-date on your FreeBSD version, this
would also be a good time to take care of that.

////jerry
      


> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080204165546.GE7685>