Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dd if=/dev/sda of=/dev/sdb bs=512 count=1
- echo -e "\nt\n1\nfd\nt\n3\nfd\nw\nx" | fdisk /dev/sdb
- [ -e /dev/md0 ] || mknod /dev/md0 b 9 0
- [ -e /dev/md1 ] || mknod /dev/md1 b 9 1
- mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1
- mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb3
- pvcreate -ff /dev/md1
- volume_group=`vgscan | grep VG | awk -F \" '{print $2}'`
- vgextend $volume_group /dev/md1
- pvmove /dev/sda3 /dev/md1
- vgreduce $volume_group /dev/sda3 # If this is a fresh install, then there won't be any data to move
- mkfs.ext3 /dev/md0
- cd / && mount /dev/md0 /mnt && rsync -a --progress --exclude=/sys --exclude=/proc --exclude=/dev/shm --exclude=/dev/pts / /mnt
- mkdir /mnt/sys
- mkdir /mnt/proc
- sed -r -i 's,LABEL=root-\w+ ,/dev/md0 ,g' /mnt/etc/fstab
- mkdir /root/initrd && cd /root/initrd
- zcat /boot/initrd-`uname -r`.img | cpio -i && cp /lib/modules/`uname -r`/kernel/drivers/md/raid1.ko lib
- q="echo Waiting for driver initialization."
- sed -r -i "s,^${q}$,\n\necho Loading raid1.ko module\ninsmod /lib/raid1.ko\n${q}\n,g" init
- q="resume /var/swap/swap.001"
- sed -r -i "s,^${q}$,${q}\necho Running raidautorun\nraidautorun /dev/md0\nraidautorun /dev/md1,g" init
- r=`grep mkroot /root/initrd/init`
- sed -r -i "s|^${r}$|${r/sda1/md0}|g" init
- find . -print | cpio -o -Hnewc | gzip -c > /mnt/boot/initrd-`uname -r`.img
- sed -r -i 's,LABEL=root-\w+ ,/dev/md0 ,g' /mnt/etc/fstab
- sed -r -i 's,LABEL=root-\w+ ,/dev/md0 ,g' /etc/fstab
- sed -r -i 's,root=LABEL=root-\w+ ,root=/dev/md0 ,g' /mnt/boot/extlinux.conf
- sed -r -i 's,root=LABEL=root-\w+ ,root=/dev/md0 ,g' /boot/extlinux.conf
- cat /usr/lib/syslinux/mbr.bin > /dev/sdb
- cd /mnt && extlinux -i boot/
- extlinux -i boot/
- cp /mnt/boot/extlinux.conf /boot/
- cp /mnt/boot/initrd-`uname -r`.img /boot
- cd ; umount /mnt || umount /dev/md0
- sync
- reboot
- First we tag the partitions as type Linux raid, then we have to add /dev/sda to the RAID.
- echo -e "\nt\n1\nfd\nt\n3\nfd\nw\nx" | fdisk /dev/sda
- mdadm -a /dev/md0 /dev/sda1
- mdadm -a /dev/md1 /dev/sda3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement