PDA

View Full Version : [lubuntu] Grub2 cannot find RAID1 arrays at startup



bitter_buffalo
September 29th, 2010, 05:56 PM
I'm currently running Ubuntu 9.10 Server with a single IDE hard drive. Having recently lost a drive at home, and realizing the magnitude of losing this one at work, I need to implement a RAID1 mirror using mdadm. (Let's debate the merits of software vs. hardware elsewhere.)

I've been trying to do this for the past two days with no success. Grub2 does not recognize the arrays at startup. I feel like there is a simple solution to this, and hope that someone here can point out what I've done wrong or left out. Here's what I've done so far, loosely using and adapting this outdated guide from linuxconfig.org (http://www.linuxconfig.org/Linux_Software_Raid_1_Setup). I want to write-up this process if I can get it working – seems like a common enough task – so please pardon if there's a lot of detail. Thanks in advance for any help.


1. Install new drive of the exact make and model as the existing drive.

The existing drive is partitioned as follows:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0004cd54

Device Boot Start End Blocks Id System
/dev/sda1 * 1 60770 488134993+ 83 Linux
/dev/sda2 60771 60801 249007+ 5 Extended
/dev/sda5 60771 60801 248976 83 Linux

and mounted thus:

/dev/mapper/Server-root on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
/dev/sda5 on /boot type ext2 (rw)Also, /dev/sda1 contains a volume group “Server” with logical volumes “root” and “swap_1”.


2. Copy the partition table from /dev/sda to /dev/sdb.

# sfdisk -d /dev/sda | sfdisk /dev/sdb
3. Set partition ID's on /dev/sdb to RAID autodetect (fd)

# sfdisk --change-id /dev/sdb 1 fd
# sfdisk --change-id /dev/sdb 5 fd

*Is there an issue with sdb5 residing on extended partition sdb2? I'm not able to exactly replicate the partition structure on the array... just md1 and md5
4. Create arrays using mdadm and format them

# mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/sdb1
# mdadm --create /dev/md5 --level=1 --raid-disks=2 missing /dev/sdb5

# mkfs.ext4 /dev/md1
# mkfs.ext2 /dev/md5
(I'm using ext2 & ext4 to mirror the options for /dev/sda I chose at installation)
5. Create /dev/sda1 equivalent lvm2 volume groups and logical volumes on /dev/md1

# pvcreate /dev/md1
# vgcreate raid_vg /dev/md1
# lvcreate -l(same) -nraid_root raid_vg
# lvcreate -l(same) -nraid_swap raid_vg

6. Copy the data from /dev/sda to the array.

# mount /dev/md5 /media
# rsync -aqxP /boot/* /media (using dd yielded a partition error)
# umount /media

# dd if=/dev/mapper/Server-root of=/dev/mapper/raid_vg-raid_root bs=64M

# mkswap /dev/mapper/raid_vg-raid_swap
7. Append array info to /etc/mdadm/mdadm.conf.

# cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf.orig
# mdadm --detail --scan >> /etc/mdadm/mdadm.conf
8. Edit /etc/fstab so that it mounts the arrays at startup.

Old fstab:
proc /proc proc defaults 0 0
/dev/mapper/Server-root / ext4 errors=remount-ro 0 1
UUID=33ede685-ed72-4149-83d1-749ace28e169 /boot ext2 defaults 0 2
/dev/mapper/Server-swap_1 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0

New fstab:

proc /proc proc defaults 0 0
/dev/mapper/raid_vg-raid_root / ext4 errors=remount-ro 0 1
UUID=7df2beb1-0d79-47a4-b6d6-84bbf7184ec6 /boot ext2 defaults 0 2
/dev/mapper/raid_vg-raid_swap none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0

* UUID value for /dev/md5 obtained from blkid command
9. Mount array as /boot and update-grub.

# umount /dev/sda5
# mount /dev/md5 /boot
# update-grub

* grub finds kernels in /boot, finds Ubuntu 9.10 on /dev/mapper/raid_vg-raid_root, and rewrites grub.cfg
10. Reboot

Here’s where I don’t understand what goes wrong. Grub loads normally, but when I check to make sure I’m using the arrays, I get this:
# mount

/dev/mapper/Server-root on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
/dev/md5 on /boot type ext2 (rw)

It appears to be booting from the array, and using the array’s swap space, but will not root to the array. From the grub menu at startup, when I hit ‘e’ to look at the underlying file, it still points to root at /dev/sda. So from the command line I entered:

insmod raid
insmod lvm
ls

And it still doesn’t show any md devices.

Any ideas? Am I leaving out an initramfs update? If so, where does it go and what, exactly, does it do? Should I manually edit the grub.cfg file to add the raid and lvm modules – even though the file says not to?

Thanks again.