Comment 5 for bug 226484

Revision history for this message
Dustin Kirkland  (kirkland) wrote : Re: boot from manually constructed raid1 root fails because of missing hostname in initramfs

Okay, I've spent a little more time on this, and I think there is a lot more involved from a configuration perspective to manually take a non-RAID system to a root-on-RAID1 system.

Here are the steps I was able to use in a Jaunty KVM to get this to work.

Install Jaunty into a KVM, and boot it with a single disk:
 HOST# qemu-img create -f qcow2 disk1.img 4G
 HOST# kvm -hda disk1.img -cdrom jaunty-server-amd64.iso

Ensure that system is happy, hunkey, and dorey.

Create a new disk.
 HOST# qemu-img create -f qcow2 disk2.img 4G

Launch the guest with both disks now:
 HOST# kvm -hda disk1.img -hdb disk2.img

The rest of these commands are to be run in the guest....

Partition:
 # fdisk /dev/sdb
n
p
(enter)
(enter)
t
fd
w

Create /dev/md0:
 # mdadm --create /dev/md0 --level=raid1 --raid-devices=2 missing /dev/sdb1

Append your raid configuration file:
 # mdadm --detail --scan >> /etc/mdadm/mdadm.conf

Configure your raid. Note that this will update your initramfs with the new mdadm.conf file!!!
 # dpkg-reconfigure mdadm

Fix /etc/fstab, which is configured for /dev/sda1 to provide /. Update this to /dev/md0 (or the UUID of /dev/md0).
 # vi /etc/fstab
...

Add the new disk to your bootloader device map:
 # echo "(hd1) /dev/sdb" >> /boot/grub/device.map

Format the filesystem:
 # mkfs.ext3 /dev/md0

Mount it:
 # mount /dev/md0 /mnt

Copy the data over from the first dist to the second. Make sure you exclude the dynamically created kernel filesystems.
 # rsync -aP --exclude /dev/ --exclude /mnt/ --exclude --/proc/ --exclude /sys / /mnt
 # mkdir /mnt/dev /mnt/mnt /mnt/proc /mnt/sys

Install the bootloader on the raid device.
 # grub-install /dev/md0

Reboot.

Hit (esc) to enter the grub menu. Hit (e) to edit your kernel line. Replace root=(*) with root=/dev/md0.

:-Dustin