How do you resize an existing partition / slice ?

Ian Jefferson ijeff at sandbox.ca
Sat Apr 29 04:04:48 UTC 2006


If you have extra disk space it's fairly straightforward to use dump/ 
restore and re-partition.

I recently found myself desiring to re-slice my disk from a single  
slice to 5 slices.

The basics were to dump the contents of my root, var, and usr  
partitions to 3 files on another disk.  I booted from a distribution  
CD and installed a new OS on slice 2 with the default partitions.   
Slice 1 became a 1g partition for DOS if the urge struck me later,  
Slice 2 was a new OS and slice 3 was for the old/existing OS.

I relabeled my 2nd slice and restored the original OS to the various  
partitions.  The only thing I forgot was to re-name the partitions in  
the /etc/fstab on my old OS. The change in slice number went like this:

/dev/ad0s1b             none            swap    sw               
0       0
/dev/ad0s1a             /               ufs     rw               
1       1
/dev/ad0s1e             /tmp            ufs     rw               
2       2
/dev/ad0s1f             /usr            ufs     rw               
2       2
/dev/ad0s1d             /var            ufs     rw               
2       2

Became

/dev/ad0s3b             none            swap    sw               
0       0
/dev/ad0s3a             /               ufs     rw               
1       1
/dev/ad0s3e             /tmp            ufs     rw               
2       2
/dev/ad0s3f             /usr            ufs     rw               
2       2
/dev/ad0s3d             /var            ufs     rw               
2       2


In your case if you want just the original slice you would do  
something like:

boot from the live filesystem CD
fdisk your drive,
label (partition) your drive to the configuration you want
newfs each new partition,
mount the drive you used for backup
mount each of the new partitions of your original disk
Restore each of the partitions in turn.

Reboot from the original disk.

This looks a bit complex but is not too bad at all.  This dump/ 
restore or even tar'ing filesystems is something we used a long time  
ago to "image" NeXT systems.  It's been quite reliable for me.  Your  
mileage may vary.

IJ


On Apr 29, 2006, at 3:24 AM, Low Kian Seong wrote:

> Dear all,
>
> Like the subject shows, I would just like to know how do i resize an
> existing partition or slice, ermm with minimum loss of data of course.
>
> Thanks.
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions- 
> unsubscribe at freebsd.org"



More information about the freebsd-questions mailing list