jerrymc at msu.edu
Mon Feb 4 16:59:03 UTC 2008
On Mon, Feb 04, 2008 at 12:12:49PM +0200, Deian Popov wrote:
> 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)
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.
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)
tar xvpf ../usr.local
Now, check out the new stuff just to feel confident it got there.
look in some files
Create the sym link
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
tar cvpf /work/src.tar *
tar xpvf ../usr.tar
Check it out and then,
mv src old.src
ln -s /work/usr.src src
Check out the link
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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'
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.
mount /dev/ad1s1e /newusr (presuming it is partition 'e' on SATA disk 1)
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
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
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.
mount /dev/ad0s1f /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.
> freebsd-questions at freebsd.org mailing list
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
More information about the freebsd-questions