partitioning
Debian 5.0 (Lenny) install on Software RAID
As mentioned in previous posts, I’m a big fan of Linux Software RAID. Most of the Ubuntu servers I install these days are configured with two disks in a RAID1 configuration. Contrary to recommendations you’ll find elsewhere, I put all partitions on RAID1, not some (that includes swap, /boot and / – in fact I don’t normally create a separate /boot partition, leaving it on the same partition as /). I guess if you’re using RAID1, I think you should get the advantage of it for all of your data, not just the really, really important stuff on a single RAIDed partition.
When installing Ubuntu (certainly recent releases including 8.10 and 9.04) you can configure all of this through the standard installation process – creating your partitions first, flagged for use in RAID and then configuring software RAID and creating a number of software RAID volumes.
I was recently installing a Debian 5.0 server and wanted to go with a similar config to the following,
Physical device | Size | Software RAID device | Filesystem | Description |
---|---|---|---|---|
/dev/sda1 |
6GB | /dev/md0 |
swap | Double the system physical memory |
/dev/sdb1 |
6GB | |||
/dev/sda2 |
10GB | /dev/md1 |
ext3, / | You can split this into multiple partitions for /var, /home and so on |
/dev/sdb2 |
10GB | |||
/dev/sda3 |
40GB | /dev/md2 |
ext3, /data | Used for critical application data on this server |
/dev/sdb3 |
40GB |
When I followed a standard install of Debian using the above configuration, when it came to installing GRUB, it failed with an error. The error seemed to be related to the use of Software RAID. Searching the web for possible solutions mostly turned up suggestions to create a non-RAIDed /boot
partition but since this works on Ubuntu I figured it should also work on Debian (from which Ubuntu is largely derived).
First, a little background to GRUB and Linux Software RAID. It seems that GRUB cannot read Linux software RAID devices (which it needs to do to start the boot process). What it can do, is read standard Linux partitions. Given that Linux software RAID1 places a standard copy of a Linux partition on each RAID device, you can simply configure GRUB against the Linux partition and, at a GRUB level, ignore the software RAID volume. This seems to be how the Ubuntu GRUB installer works. A GRUB configuration stanza like the following should thus work without problems,
title Debian GNU/Linux, kernel 2.6.26-2-amd64 root (hd0,1) kernel /boot/vmlinuz-2.6.26-2-amd64 root=/dev/md1 ro initrd /boot/initrd.img-2.6.26-2-amd64
When I tried a configuration like this on my first install of Debian on the new server, it failed with the aforementioned error. Comparing a similarly configured Ubuntu server with the newly installed Debian server, the only obvious difference I could see is that the partition table on the Ubuntu server uses the old msdos format while the partition table on the Debian server seems to be in GPT format. I can’t find any documentation on when this change was made in Debian (or indeed whether it was something in my configuration that specifically triggered the use of GPT) but it seems like this was the source of the problems for GRUB.
To circumvent the creation of a GPT partition table on both disks, I restarted the Debian installer in Expert mode and installed the optional parted
partitioning module when prompted. Before proceeding to the partitioning disks stage of the Debian installation, I moved to a second virtual console (Alt-F2) and started parted against each disk and ran the mklabel
command to create a new partition table. When prompted for the partition table type, I input msdos
.
I then returned to the Debian installer (Alt-F1) and continued the installation in the normal way – the partitioner picks up that the disks already have an partition table and uses that rather than recreating it.
This time, when it came to the GRUB bootloader installation step, it proceeded without any errors and I completed the installation of a fully RAIDed system.
Repartitioning modern Linux systems without reboot
This one is for my own future reference as much as anything. Ever since the move to udev in Linux 2.6, I’ve found it neccesary to do the very un-Linux like thing of rebooting before the appropriate device appeared under /dev. This was only an occasional hassle but still, you shouldn’t need to reboot Linux for such a thing.
Thanks to Robert for his Google magic in turning up partprobe, part of the GNU Parted package. As the Debian man page for partprobe says
partprobe is a program that informs the operating system kernel of partition table changes, by requesting that the operating system re-read the partition table.
Excellent! Parted is normally installed on Debian and Ubuntu by default anyways, if not, simply, aptitude install parted and you’ll have access to the excellent partprobe.
We were trying to add some additional swap to a running system, the full series of commands needed as follows (I could have used parted to create the partition but the cfdisk tool has a nice interface),
- sudo cfdisk /dev/sda (and create new partition of type FD, Linux RAID)
- sudo cfdisk /dev/sdb (and create new partition of type FD, Linux RAID)
- sudo partprobe
- sudo mdadm –create /dev/md3 -n 2 -x 0 -l 1 /dev/sda4 /dev/sdb4 (our swap devices are software RAID1 devices)
- sudo /etc/init.d/udev restart (this updates /dev/disk/by-uuid/ with the new RAID device)
- sudo mkswap /dev/md3
- sudo vi /etc/fstab (and add a new entry for /dev/md3 as a swap device)
- sudo swapon -a (to activate the swap device)
- sudo swapon -s (to verify it is working)
Categories
Archives
- September 2010
- February 2010
- November 2009
- September 2009
- August 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- November 2007
- September 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- September 2006
- July 2006
- June 2006
- April 2006