Notes on RAID for Ubuntu

From Wildsong
Revision as of 23:59, 21 January 2010 by Brian Wilson (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Shorthand notes on how to set up Ubuntu Server on a system with RAID 1

Some notes:

  1. Target system has 12GB of RAM
  2. Target system has two 250GB drives (actually a 320 and a 250, I ignore the extra space for now)
  3. Target system will have a RAID controller and 4 more drives for data.

The dark secret is that the installer disk (for 9.10 anyway) will detect and install onto mdadm raid if it exists. So the procedure is to partition the disks FIRST, then boot into the Ubuntu installer.

Partition the drives

Create 6 partitions on each drive, like this

1   1GB  /boot       wont be raid, so we can boot!
2  10GB  /           where the system will be eventually
3  10GB  not mounted initial install location
4        EXT
5  24GB  SWAP        won't be raided, so we will have 48GB of swap
6 200GB /var         will be raided /var partition

Set the type on the RAID partitions to Linux Raid (type=FD) for 2, 3 and 6

Partitions are far bigger than they need to be but the data on this system will live on an NFS server and on another RAID array to be installed later. Making the boot partitions 1 GB means in a pinch an entire copy of Linux can be installed there.

Create RAID filesystems

See http://www.linuxfoundation.org/collaborate/workgroups/linux-raid

First convert the second and sixth partitions to RAID1

mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sda2 /dev/sdb2
mdadm --create /dev/md1 --level=mirror --raid-devices=2 /dev/sda3 /dev/sdb3
mdadm --create /dev/md2 --level=mirror --raid-devices=2 /dev/sda6 /dev/sdb6

Make filesystems on the new RAID devices (or do this in Ubuntu installer)

mke2fs -j /dev/md0
mke2fs -j /dev/md1
mke2fs -j /dev/md2

Install Ubuntu Server

Select MANUAL when you get to the disk partitioning.

  • Tell it to put /boot on /dev/sda1
  • Tell it to use EXT3 filesystem for /dev/md0, and to put / there.
  • Tell it to use EXT3 for /dev/md2, and to put /var there.
  • Ignore the other partitions, they are for later.

Put a copy of /boot on the other hard drive

I have found that drive failures don't happen often enough to really obsess with getting the /boot partition onto RAID, it's too much work. But it's nice to keep a copy on the other hard drive and set it up so you can boot from either one. This makes it possible to get the system going again if you lose drive sda.

mke2fs /dev/sdb1
mount /dev/sdb1 /mnt
cd /boot
tar cvf - . | (cd /mnt; tar xpf -)

You can go ahead and make things bootable from here too if you want.

Put a copy of / on the other RAID partition

You can also create a copy of / on the other RAID

Edit the new /etc/fstab file

Reboot to test

Loose ends

You can check /proc/mdstat to see if RAID reconstruction is complete.

cat /proc/mdstat

Having the operating system on both /dev/md0 and /dev/md1 gives you a way to make major changes when testing new things and still have a fallback position. You have several options then; for example a cautious approach is to sync the partitions from a rescue disk before doing anything major. Or you can install a completely new OS onto the spare partition, get it all set up, and make it the new root partition. When done testing you then sync back to the old root. Note, all this requires some care in managing /etc/fstab.