Re: how to convert to RAID-1 in place?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jack Howarth wrote:
>     I have a machine that has been successfully upgraded to
> FC5 from FC4. However we would like to add a second drive and
> convert the existing partitions on the disk to degraded RAID-1
> paritions then add the missing slices from the second drive.
> Has this procedure been documented anywhere? I know this is
> possible under both Solaris and MacOS X, but haven't found it
> described for Linux anywhere. Thanks in advance for any help
> on this issue.

It can be done, but you have to be careful.

For every partition you want to convert, you have to do these steps:

1) Make sure you have a backup of your data (you *always* should have
a backup).

2) Unmount the filesystem.

3) Shrink the filesystem a bit, because the RAID metadata will be
placed in some sectors at the end of the partition; in fact, the useful
space will be a bit smaller. You can use resize2fs or resize_reiserfs
with an option of "-100M" (shrink by 100 megabytes). 100 megabytes is
absolutely more than needed, but we will regain the space in step 7).

4) Use mdadm to create your RAID-1. You have to use --raid-devices=1
and add the --force option because the tools are a little surprised
to see a RAID-1 consisting of just one disk.

5) Use fdisk to change the partition type to 0xfd (RAID autodetect),
if you want the autodetection at next boot.

6) Reboot the machine, the RAID-1 device should be visible and the
filesystem should be mountable (manually or even automatically, if
you've corrected your /etc/fstab before the reboot).

7) Enlarge the filesystem to regain almost all of the 100 megabytes
we've lost above. Just use resize2fs or resize_reiserfs with no
parameters, they will detect the size of the device automatically.
Do this operation with the filesystem not mounted (for reiserfs
you can do it while mounted too, I'm not sure for ext2).

8) At this point you have your RAID-1 working and you can mount
the device, but it's still a one disk RAID-1.

9) Use mdadm --grow --raid-disks=2 to change the number of disks
of your RAID-1 to 2.

10) Now you have a 2-disk RAID-1 working with only one disk, so you
use mdadm --manage --add to put the partition you have on your
second disk inside the RAID-1; after this command the reconstruction
will start in background (data are mirrored from disk1 to disk2).

11) Be sure your partition on the second disk has type 0xfd for
RAID autodetection at next boot.

The file /cat/mdstat will show you if the reconstruction is
still in progress or not.

You can also use cat /proc/partitions to see the little difference
between the size of each of the partitions and the size of the
RAID device.

The method is not particularly difficult, I've done it in the past
(even from normal partition to 4 disk RAID-1...).

There are two tricks involved:

1) You can't just create a 2 disk RAID-1 because the reconstruction
could copy disk2 to disk1 and destroy your data.

2) You have to shrink the filesytem; if not, everything could work
for a while, but sooner or later the filesystem will try to access
the missing blocks at the end of the device and possibly destroy
your data.

Best regards.

-- 
   Roberto Ragusa    mail at robertoragusa.it

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux