LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Software RAID 1 from Existing Boot Drive (https://www.linuxquestions.org/questions/linux-general-1/software-raid-1-from-existing-boot-drive-350031/)

johnwyles 08-04-2005 04:31 PM

Software RAID 1 from Existing Boot Drive
 
My problem is that I am getting an incorrect superblock when booting a RAID1 mirror. I have tried many things and so I will outline my procedure to see if there is something I missed and to see if there is something I did wrong. I do not have raidtools so 90% of the documentation out there cannot be applied to me. togami.com/~warren/guides/remoteraidcrazies/ <--- This page was as close as any document has come to helping me with this process.

This whole procedure was performed after booting a Live CD with none of the SATA drives mounted.

My setup plan:
/dev/sda is the pre-existing master and the drive I am wanting to mirror from. So data in the synch should flow sda -> sdb.

Code:

/dev/sda1 -> /dev/md0 (ext3) - to be "/boot"
/dev/sdb1 -> /dev/md0 (ext3) - to be "/boot"

/dev/sda2 -> /dev/md1 (swap)
/dev/sdb2 -> /dev/md1 (swap)

/dev/sda3 -> /dev/md2 (ext3) - to be "/"
/dev/sdb3 -> /dev/md2 (ext3) - to be "/"

Procedure:
To create the array:

I fdisked the /dev/sdb drive and made sure it was exactly like /dev/sda. I then ran mkfs.ext3 for /dev/sdb1 and /dev/sdb3, and ran mkswap for /dev/sdb2. Now that the drives were identical in their partition scehem I changed the filesystem type to "fd" for both /dev/sda and /dev/sdb. Next I created the array:

Code:

mdadm --create /dev/md0 --level=1 --raid-disks=2 /dev/sda1 /dev/sdb1
mdadm --create /dev/md1 --level=1 --raid-disks=2 /dev/sda2 /dev/sdb2
mdadm --create /dev/md2 --level=1 --raid-disks=2 /dev/sda3 /dev/sdb3

After issuing cat /proc/mdstat I saw that all drives were sync'ed properly (they all had [UU]). With the drives now sync'ed I moved on to mounting what is to be the root and boot partitions:

Code:

mount /dev/md2 /mnt/sysimage
Code:

mount /dev/md0 /mnt/sysimage/boot
I then chroot'ed to the environment and changed the /etc/fstab file and the /boot/grub/grub.conf file.

Code:

chroot /mnt/sysimage
Code:

vi /etc/fstab
Here I removed LABEL=/ and LABEL=/boot for / and /boot mountpoints respectively. I replaced these lines with the following:
Code:

/dev/md2      /            ext3    defaults    1 1
/dev/md0      /boot    ext3    defaults    1 2

Since these drives were apparently labeled I de-labeled them:
Code:

e2label /dev/sda1 ""
e2label /dev/sda3 ""
e2label /dev/sdb1 ""
e2label /dev/sdb3 ""

Code:

vi /etc/fstab
Here I added a kernel and initrd that reflected my system:
Code:

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
title Fedora Core 4 RAID1 (2.6.12-1.1398_FCsmp)
        root (hd0,0)
        kernel /kernel-2.6.12-1.1398_FCsmp ro root=/dev/md0
        initrd /initrd-2.6.12-1.1398_FCsmp-RAID1.img
title Fedora Core 4 (2.6.12-1.1398_FCsmp)
        root (hd0,0)
        kernel /kernel-2.6.12-1.1398_FCsmp ro root=/dev/sda1
        initrd /initrd-2.6.12-1.1398_FCsmp.img

Since I wanted to be sure I had RAID1 loading on boot I built the ramdisk mentioned in the
Code:

/boot/grub/grub.conf
above:
Code:

mkinitrd --preload raid1 --with=raid1 /initrd-2.6.12-1.1398_FCsmp-RAID1.img 2.6.12-1.1398_FCsmp
Everything was ready, as far as I could tell, so I rebooted and got the message that the superblock did not match and a prompt for an emergency shell was give as an option. This also made the array out-of-sync and so I rebooted to the Live CD, sync'ed the drives with the procedure described above, and ran an e2fsck on them.
Code:

e2fsck /dev/sda1
e2fsck /dev/sdb3
e2fsck /dev/sdb1
e2fsck /dev/sdb3

None of this worked and I still get the message. Can anyone help? I do not have a backup drive to store all of the data or I would simply re-install Linux with the RAID1 already in place. Any ideas? THANKS!

johnwyles 08-05-2005 11:42 AM

FIXED!
 
I resolved this issue by running the following commands from the Live CD:

Code:

e2fsck -cc /dev/md2
Answered "Yes" to nearly everything and erased any files that contained bad blocks (only one in my case). This took over 10 hours to complete!!!
Code:

e2fsck -cc /dev/md0
This was to correct sizing issues that apparently also appeared with my /boot partition.

Code:

resize2fs /dev/md2
resize2fs /dev/md0

This did not take long at all and properly resized the partitions and resolved my issues.

If anyone would like to do this then the procedure I have outlined should work and has now been verified by me! GOOD LUCK (You will need it)!


All times are GMT -5. The time now is 10:41 PM.