How to safely merge two slices on harddisk?
malcolm.kay at internode.on.net
Mon Feb 9 03:55:39 PST 2004
On Mon, 9 Feb 2004 13:46, Rob wrote:
> I have a hard disk, on which I would like to merge two slices
> into one single slice. The disk slices are as follows:
> /dev/ad1s1a 98M 43M 47M 48% /home/userB
> /dev/ad1s1d 64G 45G 14G 77% /home/userA
> /dev/ad1s1e 3.0G 2.5G 282M 90% /home/userC
> /dev/ad1s1f 3.0G 1.0G 1.7G 37% /usr/ports
> /dev/ad1s1g 3.0G 268M 2.5G 10% /mnt
> /dev/ad1s1h 295M 295M -23.5M 109% /diskless_swap
> I want to merge /ad1s1f and /ad1s1g into one 6Gb slice.
> The merging should NOT destroy anything in the slices before
> (ad1s1a, d, and e), but destroying the data in the one afer
> (ad1s1h) is no problem.
> Is there a way to do this? What is the safest one?
> (without having to backup the whole disk).
Any manipulation at this level is risky. To do so without first
taking a backup endangers all your data.
But once you have the assurance of a backup you could copy
all the information from /mnt into some new tree in /usr/ports.
That is a tree copy of the content of /dev/ad1s1g to a new tree
cp -Rp /mnt /usr/ports/newtree
Having done that partition /dev/ad1s1g becomes free and you
can rebuild the disk label using disklabel to eliminate the 'g'
partition and extend the size of the 'f' partitition to take up the
extra space. But first umount the 'f' and 'g' partitions.
Do not change the offset of 'f'. If 'g' does not physically
follow 'f' on the disk then this is not going to work -- give up
If all has gone well so far you should now be able to use growfs
on /dev/ad1s1f to expand the file system to fill the partition.
Remount the 'f' partition and you should be back in business.
If you want to find what was on /dev/ad1s1g with the original path
ln -s /usr/ports/newtree /mnt
If you are on 5.x then be warned that I have no experience with
these versions of FBSD.
And in any case I have never, myself, had occassion to use growfs.
More information about the freebsd-questions