resizing partitions

John Nielsen lists at
Tue Oct 23 17:30:52 PDT 2007

On Tuesday 23 October 2007, Chad Perrin wrote:
> I have need to alter some partition sizes on a (laptop) system I use
> daily, with FreeBSD 6.2-RELEASE installed.  Are there tools you'd
> recommend for this, that should be stable and not prone to hosing up my
> filesystems?  In particular, I probably don't need to shrink any
> partitions -- only grow them -- but I'm not sure how I want to handle
> this at this time.  I worry a bit about using some Linux LiveCD's
> partition management tools on a FreeBSD system.  Any advice would be
> appreciated.

The best tools (IMO) for this are dump and restore. If you have external 
storage, storage on another system accessible by a reasonably fast network 
from your laptop, or dvd burner (if the example here[1] works, I haven't 
tried it) then this will definitely be your best option. Make your backup 
using dump and verify that it's complete, intact, and able to be restored 
from a fixit CD. Then (still from the fixit CD) blow away your existing 
partitions, make your new ones, and run restore to put your data back.

If that option doesn't appeal to you you should still make and verify a 
complete backup before doing anything else. Depending on how much free 
space (and possibly swap) you have on your disk, you could possibly do a 
few different passes using growfs (in the base system) to this effect:
	identify next (in block order on the disk) partition to be grown.
	if there is no (or not enough) unpartitioned space after the growing 
partition, move everything from the next partition to other partitions, 
possibly creating temporary partitions closer to the end of the disk, or 
permanently relocating one or more partitions to the end of the disk, or 
temporarily converting your swap partition to a filesystem (be sure to not 
use it as swap for the duration, of course)...
		destroy the newly freed partition
	use growfs
	if there's room and a need, recreate the destroyed partition and restore 
its contents from elsewhere

I share your doubts about Linux utilities being able to handle UFS (esp. 
UFS2) filesystems correctly.


Specifically, the example command line is:
/sbin/dump -0u  -L -C16 -B4589840 -P 'growisofs -Z /dev/cd0=/dev/fd/0' /u

More information about the freebsd-questions mailing list