shrink /usr size

Matthew Seaman m.seaman at
Thu Mar 18 10:25:21 UTC 2010

Hash: SHA1

On 18/03/2010 09:52:50, Антон Клесс wrote:
> 2010/3/18 Aiza <aiza21 at>
>> /usr is the last partition in the slice. It has 15GB and only 600mb used. I
>> would like to shrink /usr to 7GB leaving me 7GB for another new partition

> The same question: how to extend existed one?

If, and only if, you have free space on your HDD following the partition
you want to expand, you can use bsdlabel to edit the partition table and
then growfs(8) to extend the filesystem into the new space.

> I'm going to change HDD on server to a bigger one and dd from old to new,
> but in this case the space visible to FreeBSD would be the same, how to make
> it grow?

However, in this case -- don't do that.  dd(1) is not the best choice.

Instead, use sade(8) or fdisk(8) and bsdlabel(8) to slice and partition
your new hard drive, install any necessary boot blocks etc.  Or use the
new gpart(8) stuff.  Create filesystems using newfs(1).  Mount the new
partitions temporarily under /mnt:

   # mount -t ufs -o rw /dev/ad2s1a /mnt
   # mount -t ufs -o rw /dev/ad2s1e /mnt/usr

Then use dump(8) and restore(8) to duplicate the contents of your old
partitions onto your new HDD:

   # dump -0a -L -C 32 -f - /  | ( cd /mnt ; restore -rf - )
   # dump -0a -L -C 32 -f - /usr | ( cd /mnt/usr ; restore -rf - )

Edit /mnt/etc/fstab appropriately, then unmount the partitions from your
new HDD, shutdown your system and reboot from the new HDD.

dump and restore is much more efficient than using dd(1) as it copies
the actual files into a new filesystem.  It also understands more about
the internals of the filesystem than other backup software, so gives the
most accurate duplication.  The '-L' flag causes it to operate on a
snapshot of the source filesystem, which avoids the sort of problems you
can get dealing with live filesystems.



- -- 
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP:     Ramsgate
                                                  Kent, CT11 9PW
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla -


More information about the freebsd-questions mailing list