Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Feb 2004 22:25:35 +1030
From:      Malcolm Kay <malcolm.kay@internode.on.net>
To:        Rob <nospam@users.sourceforge.net>, freebsd-questions@freebsd.org
Subject:   Re: How to safely merge two slices on harddisk?
Message-ID:  <200402092225.35217.malcolm.kay@internode.on.net>
In-Reply-To: <4026FBA6.8030001@users.sourceforge.net>
References:  <4026FBA6.8030001@users.sourceforge.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 9 Feb 2004 13:46, Rob wrote:
> Hi,
>
> 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=20
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
on /dev/ad1s1f.
   cp -Rp /mnt /usr/ports/newtree

Having done that partition /dev/ad1s1g becomes free and you=20
can rebuild the disk label using disklabel to eliminate the 'g'=20
partition and extend the size of the 'f' partitition to take up the=20
extra space. But first umount the 'f' and 'g' partitions.
CAUTION
=3D=3D=3D=3D=3D=3D=3D=3D
    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
    now!!!

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=20
then
   rm /mnt
   ln -s /usr/ports/newtree /mnt

If you are on 5.x then be warned that I have no experience with=20
these versions of FBSD.

And in any case I have never, myself, had occassion to use growfs.

Malcolm



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200402092225.35217.malcolm.kay>