Comments on How To Set Up Software RAID1 On A Running System (Incl. GRUB Configuration) (Debian Etch)
How To Set Up Software RAID1 On A Running System (Incl. GRUB Configuration) (Debian Etch) This guide explains how to set up software RAID1 on an already running Debian Etch system. The GRUB bootloader will be configured in such a way that the system will still be able to boot if one of the hard drives fails (no matter which one).
15 Comment(s)
Comments
Thanks for a great howto! It was a life saver, as I have never set up RAID before, let alone on a running system. The install did not go perfectly however and so I thought I might share my notes and a couple of suggestions. Luckily I did a backup of the entire system before beginning, so I was able to restore the system and begin again after I could not get the system to boot off the RAID array. N.B. I did the install on a Debian testing system (lenny/amd64), but I've checked that everything applies to etch as well.
1. If the disks are not brand new, mdadm will detect the previous filesystem when creating the array and ask if you want to continue. Answer, 'yes'. I also got a segfault error from mdadm and a warning that the disk was 'dirty'. The warning could probably be avoided by zeroing the entire disk with dd. Despite the error and warning everything worked as it should.
2. Instead of: cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig mdadm --examine --scan >> /etc/mdadm/mdadm.conf do: mv /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig /usr/share/mdadm/mkconf >> /etc/mdadm/mdadm.conf This will create a proper mdadm.conf and remove the control file in /var/lib/mdadm (if arrays are found). If you do not remove the control file, you should get a warning message when updating the initrd images.
3. When editing GRUBS's menu.lst, I followed the advice in the comments and put the stanza for the RAID array, before the '### BEGIN AUTOMAGIC KERNELS LIST' line. If you put your custom stanzas inside the AUTOMAGIC area, they will be overwritten during the next kernel upgrade. Instead of: update-initramfs -u I had to do: dpkg-reconfigure mdadm When asked to specify the arrays needed for the root filesystem, I answered with the appropriate devices (in my case only /dev/md0) instead of selecting the default, 'all'. Otherwise I kept to the default answers. After the initrd images had been created, I updated GRUB: update-grub
4. Instead of using the GRUB shell, I used grub-install to install the boot loader on the hard drives: grub-install /dev/sda grub-install /dev/sdb
5. After having added both disks to the arrays, it was time to update the initrd again. First I executed: dpkg-reconfigure mdadm and was informed that the initrd would not be updated, because it was a custom image. The configure script informed me that I could force the update by running 'update-initramfs' with the '-t' option, so that is what I did: update-initramfs -u -t
6. Every time you update the initrd image, you also have to re-install GRUB in the MBR's: grub-install /dev/sda grub-install /dev/sdb Otherwise the system will not boot and you will be thrown into the GRUB shell. Other notes: It is normal for 'fdisk -l' to report stuff like, 'Disk /dev/md0 doesn't contain a valid partition table'. This is because fdisk cannot read md arrays correctly. If you forget to re-install GRUB in the MBR's, after updating your initrd, and get the GRUB shell on reboot. Do the following: Boot from a Debian Installer CD (full or netinst) of the same architecture as your install (so if you're running amd64, it has to be a amd64 CD). Boot the CD in 'rescue' mode. After networking has been set up and the disks have been detected press CTRL+ALT+F2, followed by Enter, to get a prompt. Execute the following commands (md0=/boot and md2=/): mkdir /mnt/mydisk mount /dev/md2 /mnt/mydisk mount /dev/md0 /mnt/mydisk/boot mount -t proc none /mnt/mydisk/proc mount -o bind /dev /mnt/mydisk/dev chroot /mnt/mydisk grub-install /dev/sda grub-install /dev/sdb exit umount /mnt/mydisk/proc umount /mnt/mydisk/dev umount /mnt/mydisk/boot umount /mnt/mydisk reboot
Thank you so much for this detailed howto. It saved me a lot of pain and worked perfectly on Ubuntu 8.04.1 LTS.
I am relatively new to linux and am completely dependent on these tutorials. I bought a server and installed Suse 10.3. After running Ubuntu on my desktop and laptop, I decided to change the server to run Ubuntu as well (I didn't uninstall Suse - just installed over it??). After installing the server based on "The Perfect Ubuntu Server 8.04" (https://www.howtoforge.com/perfect-server-ubuntu8.04-lts) I installed the ISPConfig as detailed at the end. Then to install RAID, I followed the tutorial perfectly I think, but at the end of step 6 after rebooting, I still show sda1 rather than md0.
root@costarica:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/costarica-root
228G 1.4G 216G 1% /
varrun 502M 108K 502M 1% /var/run
varlock 502M 0 502M 0% /var/lock
udev 502M 76K 502M 1% /dev
devshm 502M 0 502M 0% /dev/shm
/dev/sda1 236M 26M 198M 12% /boot
root@costarica:~#
vi /etc/fstab shows the following:
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# /dev/mapper/costarica-root
UUID=2e3442d3-c650-480a-a923-4775de238b7f / ext3 relatime,errors=remount-ro,usrquota,grpquota 0 1
# /dev/md0
UUID=251a68c2-1497-433b-b415-d49ca8f2125e /boot ext3 relatime 0 2
# /dev/mapper/costarica-swap_1
UUID=03c6c32e-38bd-4707-9df5-dcdd3049825a none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
It looks different than the one in the tutorial but I attribute that to being ubuntu rather than debian.
Can anyone shed some light on this for me? Did I miss a step or are there other steps involved because of Ubuntu?
Thanks for any help.
Jason.
Dear all,
this howto just worked for me flawlessly for my brand-new Debian Lenny (testing) today (03-Jan-2009) !!!
No issues, no problems at all. I had several different partitions, even extended ones, I only had to follow on paper, which partition goes into which numbered array - that's it ;-)
(And my boot partition wasn't /boot but simply /, I did everything accordingly - flawless!!!)
THANK YOU VERY MUCH for this HowTo, I've NEVER EVER raid-ed before and it's a success :)
md0 = /
md1 = swap
md2 = /home
This all on an Abit NF7-S2, BIOS-Raid OFF, 2 x SATA2 Samsung 320G, Sempron 2800+, 2x512 DDR400 ;-)
lol:~# df -m
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/md0 18778 2312 15512 13% /
tmpfs 506 0 506 0% /lib/init/rw
udev 10 1 10 2% /dev
tmpfs 506 0 506 0% /dev/shm
/dev/md2 280732 192 266281 1% /home
lol:~#
Cheers from Europe !
Great tutorial,
my compliments
I wonder, what's the point in having the swap on a raid1? shouldn't it be better to add /dev/sda2 and /dev/sdb2 directly as two separate swap devices?
Can I apply this How-to to my PPC Debian Etch? Thanks!
Nice howto!
I would like to correct some minor errors though:
Ext2 on boot instead of ext3... Ext3 on /boot is just a waste of space and resources. You dont need journaling for your boot partition :)
and why make a raid array for swap? swap will stripe data as a raid0 anyway.. just tell linux to swap to two different physical disks and voila. Striping made easy :p
Happy raiding :p
(If you suddenly need a lot of swapspace, you can use "swapon" command to swap to memorysticks or whatever you need, unlike fstab fixing, swapon wil get resetted on reboot) ;)
I spent hours trying to work out not only how to set up a software RAID, but also how to do it on a boot partition. I didn't even come close to looking at a live system. I got nowhere until I found this HOWTO which does it all very well. Thank you!
Andy
It works just perfectly with ubuntu 8.04
Thanks for the brilliant how-to
You might like to put a link somewhere in this howto to your newer howto detailing the install with Grub2. I spent some time following this howto and tripping up on Grub2 and doing lots of googling, before finally realising that what I thought were google hits on your existing howto were actually pointing to a separate but very similarly named howto, that covers Grub2!
I did manage to lose all my existing data following this. I was not doing this with a root partition so I had no issues with partitions being in use and I specified both disks in the create command rather than the "missing" placeholder - maybe that was my problem.
Hi thanks for the tutorial.
I got a question about /etc/fstab file.
My File contains must UUIDs not sda or sdb.
Can I just replace them with sda and sdb?
Regards
Of course, you mean not "cp /etc/mdadm/mdadm.conf_orig /etc/mdadm/mdadm.conf" but "cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig", right?
This ALMOST worked on Debian 9.3 (Stretch) but our '/', '/home' and 'swap' are all crypto mapped.
Back to the drawing board with a Live-USB boot to perform it in a single line mdadm command.
Excellent learning experience.