DISCLAIMER: The author takes no responsibility if these instructions cause you to wipe out or destroy anything, including data stored on your Skolelinux server. This is what I did on my installation, installed from a Skolelinux prerelease 40 This Howto assumes: [1] That you have SCSI disks, sda and sdb. If you don't have SCSI disks, but IDE disks, then you'll have to substitute every instance of sda with hda, and sdb with hdb, given that your IDE disk are setup as master and slave at the first IDE channel. [2] That your working installation is located at disk sda(SCSI), or hda(IDE). [3] That you are running a fairly recent version of Skolelinux with swap on lvm. If you have a version of Skolelinux without swap on lvm, prior to about pr40, then you must remember to turn of swap when you get to the point where you "partition the first disk as the second". You turn of swap with the command: swapoff [4] This howto assumes that you have a 2.4.26-1-386 kernel, check with: uname -a what kernelversion you are running, and substitute 2.4.26-1-386 with that. [5] Let us begin... First update the apt source list: vi /etc/apt/sources.list Allow apt to fetch from the net: apt-get update Then fetch some software: apt-get install mdadm In newer versions of Skolelinux smartsuite is installed, that needs to be stopped before running sfdisk: /etc/init.d/smartsuite stop Partition the spare disk: sfdisk -d /dev/sda | \ sed 's/Id=83/Id=fd/g ; s/Id=8e/Id=fd/g' | \ sfdisk /dev/sdb The line "sed 's/...." will change the partition types from linux, and LVM into Linux raid Autodetect If you previously had raid on the disks, you can remove the superblock with mdadm --zero-superblock /dev/sdb{1,5,6} Prepare mdadm: echo 'DEV /dev/sd* /dev/hd*' > /etc/mdadm/mdadm.conf Create a degraded raid: mdadm --create /dev/md/1 --level=1 --raid-disks=2 \ missing /dev/sdb1 mdadm --create /dev/md/5 --level=1 --raid-disks=2 \ missing /dev/sdb5 mdadm --create /dev/md/6 --level=1 --raid-disks=2 \ missing /dev/sdb6 Save the array config: mdadm -E -s | grep ARRAY >> /etc/mdadm/mdadm.conf Note: if you previously have had a raid setup on your disk, you may need to edit you mdadm, and have a look at the output from "mdadm -E -s", to tell which of you raid devices you are going to use. Then it may be better to do: mdadm -E -s >> /etc/mdadm/mdadm.conf and edit /etc/mdadm/mdadm.conf afterwards, to remove old ARRAYS (identified by /dev/sdaX) and also to remove the "devices=/dev/sdXX" It might be even better to remove the old raid superblock on your disks: mdadm --zero-superblock /dev/sdb{1,5,6} Create filesystem on the new root: mke2fs -j /dev/md1 Create physical volumes, and add them to the existing vg_system/vg_data pvcreate /dev/md5 pvcreate /dev/md6 vgextend vg_system /dev/md/5 vgextend vg_data /dev/md/6 Note: When adding them to the volume groups you need to use /dev/md/X Mount the new root file system: mount /dev/md1 /mnt/ Now its time to change to runlevel 1: init 1 Note: If you are doing this with ssh, and like to continue using ssh, then this will take the machine to runlevel 1 with a working ssh: for ALL in $(ls /etc/rc1.d/K* | grep -v ssh) ; do $ALL stop ; done for ALL in $(ls /etc/rc2.d/S* | grep -v ssh) ; do $ALL stop ; done Copy the content of the old root fs: cp -ax / /mnt unmount disc systems that you don't need to have mounted umount /skole/tjener/home0 umount /skole/backup umount /var to umount /usr, you need to switch from bash exec /bin/ash umount /usr Move the content from vg_system and vg_data onto the new Raid disks. pvmove /dev/scsi/host0/bus0/target0/lun0/part5 pvmove /dev/scsi/host0/bus0/target0/lun0/part6 Then remove the old None raid physical volumes from the volume groups vgreduce vg_system /dev/scsi/host0/bus0/target0/lun0/part5 vgreduce vg_data /dev/scsi/host0/bus0/target0/lun0/part6 Remount /usr, as you need some utilities to do the rest mount /usr Create device files (these were not copied as we use devfs, but are needed during boot): cd /mnt/dev/ /sbin/MAKEDEV std /sbin/MAKEDEV sda sdb hda hdb hdc hdd hde hdf hdg hdh md /sbin/MAKEDEV console Now edit fstab to use your new raid devices: vi /mnt/etc/fstab My fstab looks like this: --- Start /mnt/etc/fstab --- # /etc/fstab: static file system information. # # /dev/md1 / ext3 defaults 0 1 /dev/vg_data/lv_home0 /skole/tjener/home0 ext3 defaults 0 2 /dev/vg_system/lv_usr /usr ext3 defaults 0 2 /dev/vg_system/lv_var /var ext3 defaults 0 2 none /tmp tmpfs defaults 0 2 /dev/vg_system/lv_swap none swap sw 0 0 proc /proc proc defaults 0 0 /dev/fd0 /floppy auto rw,user,noauto 0 0 /dev/cdrom /cdrom iso9660 ro,user,noauto 0 0 --- End /mnt/etc/fstab --- Now create a new initrd.img with support for software-raid: mkinitrd -o /mnt/boot/initrd.img-2.4.26-1-386 -r /dev/md1 (When upgrading your kernel you must remember to make a new initrd.img for your new kernel with support for software-raid) You might have to spesify a delay in your initrd, add a value to DELAY= in the file /etc/mkinitrd/mkinitrd.conf, I have DELAY=20 Now you may modify your /boot/grub/menu.lst, and add these lines: title New SW Raid root (hd1,0) kernel /boot/vmlinuz-2.4.26-1-386 root=/dev/md1 ro initrd /boot/initrd.img-2.4.26-1-386 savedefault boot If you are located remotely, then you also have to change the line default 0 to default 2 I STRONGLY advice against doing this from remote, but if you have to, then .... Now reboot. When you log in after reboot, you can check if your new raid is working with tjener:~# mount /dev/md1 on / type ext3 (rw) proc on /proc type proc (rw) /dev/vg_data/lv_home0 on /skole/tjener/home0 type ext3 (rw) /dev/vg_system/lv_usr on /usr type ext3 (rw) /dev/vg_system/lv_var on /var type ext3 (rw) none on /tmp type tmpfs (rw) and the status of the raid devices: tjener:~# cat /proc/mdstat Personalities : [raid1] read_ahead 1024 sectors md6 : active raid1 scsi/host0/bus0/target2/lun0/part6[1] 2064256 blocks [2/1] [_U] md5 : active raid1 scsi/host0/bus0/target2/lun0/part5[1] 2168640 blocks [2/1] [_U] md1 : active raid1 scsi/host0/bus0/target2/lun0/part1[1] 208704 blocks [2/1] [_U] unused devices: In newer versions of Skolelinux smartsuite is installed, that needs to be stopped before running sfdisk: /etc/init.d/smartsuite stop Then partition the first disk as the second: sfdisk -d /dev/sdb | sfdisk /dev/sda Then add the newly created partition , completing the raid1: mdadm /dev/md/1 --add /dev/sda1 mdadm /dev/md/5 --add /dev/sda5 mdadm /dev/md/6 --add /dev/sda6 The machine will answer with: mdadm: hot added /dev/sdaX Now wait while the raids are being recovered: Be warned that the process of recovery can take hours if you have large disks. tjener:~# cat /proc/mdstat will show you the status of your raid. While recovery is underway, /proc/mdstat will display: Personalities : [raid1] read_ahead 1024 sectors md6 : active raid1 scsi/host0/bus0/target0/lun0/part6[2] scsi/host0/bus0/target2/lun0/part6[1] 2064256 blocks [2/1] [_U] [==>..................] recovery = 14.3% (297472/2064256) finish=7.0min speed=4192K/sec md5 : active raid1 scsi/host0/bus0/target0/lun0/part5[2] scsi/host0/bus0/target2/lun0/part5[1] 2168640 blocks [2/1] [_U] md1 : active raid1 scsi/host0/bus0/target0/lun0/part1[0] scsi/host0/bus0/target2/lun0/part1[1] 208704 blocks [2/2] [UU] unused devices: You can read from what /proc/mdstat displays during recovery, the following: There is two pairs of square brackets [2/2][_U]. The two numbers in the first square bracket indicates the number of disks in the array, and the number of active disks in the array. The letter U and the underscore _ in the second square bracket indicates the state of the disks; [UU] means both disks in the array is working, [_U] means the first disk has failed, while the second disk is working. There is also a square bracket after each member disk, this indicates which number this disk has in the array. When recovery is done, /proc/mdstat will display all [2/2][UU], if successfully.: md6 : active raid1 scsi/host0/bus0/target0/lun0/part6[0] scsi/host0/bus0/target2/lun0/part6[1] 2064256 blocks [2/2] [UU] md5 : active raid1 scsi/host0/bus0/target0/lun0/part5[0] scsi/host0/bus0/target2/lun0/part5[1] 2168640 blocks [2/2] [UU] md1 : active raid1 scsi/host0/bus0/target0/lun0/part1[0] scsi/host0/bus0/target2/lun0/part1[1] 208704 blocks [2/2] [UU] unused devices: Now the not-so-fun part comes: update-grub does not understand the device "/dev/md1", and you will have to run grub manually. Change /boot/grub/menu.lst into: title Debian GNU/Linux root (hd0,0) kernel /vmlinuz root=/dev/md1 ro initrd /initrd.img savedefault boot title Debian GNU/Linux (recovery mode) root (hd0,0) kernel /vmlinuz root=/dev/md1 ro single initrd /initrd.img savedefault boot title Debian GNU/Linux, gammel root (hd0,0) kernel /vmlinuz.old root=/dev/md1 ro initrd /initrd.img.old savedefault boot title Debian GNU/Linux, Gammel (recovery mode) root (hd0,0) kernel /vmlinuz.old root=/dev/md1 ro single initrd /initrd.img.old savedefault boot Please make sure that your initrd.img and vmlinuz in / are working symlinks. (mine were broken) Also, you might remove the postinst and postrm hooks in /etc/kernel-img.conf, as update-grub and grub-install is no longer working. Then update grub manually - first on /dev/sdb echo -e 'root (hd1,0)\nsetup (hd0)' | grub --batch then update grub on /dev/sda echo -e 'root (hd0,0)\nsetup (hd0)' | grub --batch *** Now you should be able to boot in the event of disk failure, no matter which drive fails. *** Please test and verify, and give feedback to: faj@bzz.no 2003-10-05 Small details added 2003-11-04, klaus@skolelinux.no Small details added 2004-08-03, klaus@skolelinux.no I can verify that this howto works on one of my ltsp-servers installed with cd from 2003-10-06 I can verify that this howto works on one a server installed with Skolelinux 1.0 Venus. klaus@skolelinux.no More documentation: http://www.devil-linux.org/newdoc/ch01s05.html http://www.parisc-linux.org/faq/raidboot-howto.html http://doc.uni-klu.ac.at/zope/DocZWiki/RAIDHowTo http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=55484 Vadala, Derek "Managing raid on Linux" ISBN 1565927302