The procedure draws heavily on Warren Togami's document at http://togami.com/~warren/guides/remoteraidcrazies/. There are a few typos in his and I've made some enhancements, so use mine instead of his :-)# edit /etc/fstab and /boot/grub/grub.conf to use /dev/sda instead of labels
e2label /dev/sda1 ''
^1^3
# run fdisk and change all partitions on /dev/sda to type fd
sfdisk -d /dev/sda | sfdisk /dev/sdb
mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1
mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb3
mkfs.ext3 /dev/md0
^0^1
mkinitrd -v --preload=raid1 /root/initrd-$(uname -r).img $(uname -r)
mv /boot/initrd-$(uname -r).img{,.orig}
mv /root/initrd-$(uname -r).img /boot
reboot # This is the magic step! Don't skip it!
cat /proc/mdstat # Make sure that md0 and md1 are running
# reboot w/ rescue disk
modprobe raid1
for i in $(seq 0 9); do mknod /dev/md${i} b 9 $i; done
cd mnt
mkdir {sda1,sda3,md0,md1}
mount /{dev,mnt}/sda1
^1^3
mdadm -A /dev/md0 /dev/sdb1
mdadm -A /dev/md1 /dev/sdb3
mount /{dev,mnt}/md0
^0^1
# edit /mnt/sda1/grub/grub.conf to boot from /dev/md1
# edit /mnt/sda3/etc/fstab to mount /dev/md0 @ /boot & /dev/md1 @ /
cp -a /mnt/sda1/* /mnt/md0 # This is why we use the rescue disk; we probably
cp -a /mnt/sda3/* /mnt/md1 # don't want to try copying a running system
# The above will take a loooooong time.
umount sda1 sda3 md0 md1
reboot
cat /proc/mdstat
mdadm /dev/md0 -a /dev/sda1
mdadm /dev/md1 -a /dev/sda3
watch -n 1 'cat /proc/mdstat' # The above will take a looooooong time.
grub --no-floppy
device (hd0) /dev/sda
root (hd0,0)
setup (hd0)
device (hd0) /dev/sdb
root (hd0,0)
setup (hd0)
quit
rm /boot/initrd*.orig
reboot
13 August 2009
Migrating to RAID-1
Here's an old post, which hopefully nobody will ever need because everybody's installing RAID-1 or better on every system that ever gets built. Back in 2007, I migrated a RHEL system with a single hard drive to a software RAID-1 array -- without losing any data :-) Here's how to do it -- the instructions are specific to whatever version of RHEL that was way back then, but the technique will be useful on any reasonably-modern distro:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment