Software RAID 1 on SuSE 9.2

Thursday, July 28th, 2005 - Español English

Here is a brief description of what I had to do to migrate my running SusE 9.2 filesystem to a RAID1 made of my current hard drive and a new (identical) one.

The steps are almost exactly those explained here by Lucas Albers, with slight variations and surely many omissions. Please keep in mind that these are only personal notes I took during the process and that they might be misleading or completely wrong.

My setup is as follows: 2 identical SATA hard drives, one with a full desktop system install and lots of personal information (not to be lost!), another completeley empty. HD1 is /dev/sdb, HD2 is /dev/sda (yes, they are switched)

1) Partition HD2 with fdisk, make it the same as HD1, but give the root partition type fd ("Linux raid autodetect") .

Device Boot Start End Blocks Id System
/dev/sda1 1 131 1052226 82 Linux swap / Solaris
/dev/sda2 * 132 30399 243127710 fd Linux raid autodetect

2) Reboot.

The partition table has to be reloaded, rebooting is highly recommended.

3) Create RAID device:

This is the crucial step: we tell the raid tool that the first disk (the one currently in use) is missing, so that building the raid device and any further operation on it won’t destroy any data. Please note that the keyword missing is in place of the drive which is supposedly missing (namely, our working drive: /dev/sdb2).

mdadm –create /dev/md0 –level=1 –raid-disks=2 missing /dev/sda2

4) Format it:

mkfs.reiserfs /dev/md0

5) Mount it, add it to fstab:

mkdir /mnt/md0
mount /dev/md0 /mnt/md0

6) Copy all of HD1 onto the RAID

cp -aux /mnt/hd1 /mnt/md0

or

rsync -a –progress /mnt/hd1/ /mnt/hd2/

7) Create initial ramdisk.

The initrd needs raid modules. Edit /etc/sysconfig/kernel and add the necessary modules. As I’m running reiserfs on NVidida SATA, I needed two more (YMMV)

INITRD_MODULES=”sata_nv reiserfs raid0 raid1 raid5″

Then run mkinitrd (telling it to use the raid device as root) and edit /boot/grub/menu.lst to your liking as well as /etc/fstab to set the root filesystem to /dev/md0.

mkinitrd -d /dev/md0

8) Reboot with the newly created RAID.

The system should boot correctly now, and the root be /dev/md0.

9) Add HD1 to the RAID

First format HD1 as you did with HD2, setting the desired partitions to fd type. The two partition sizes should match to avoid any problems.

mdadm –add /dev/md0 /dev/sdb2

To see some progress informaton as the first disc comes into sync with the second:

cat /proc/mdstat

10) Rebuild the initial ramdisk with the “recovered” RAID.

Redo step 7, but this time having root set at /dev/md0

11) Reboot. Done.

Please remember this is not at all guaranteed to work. Read more on the subject before trying as you could loose all of your data.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>