Notes on RAID for Ubuntu: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
mNo edit summary
Brian Wilson (talk | contribs)
Line 15: Line 15:
  5  24GB  SWAP      ''won't be raided, so we will have 48GB of swap''
  5  24GB  SWAP      ''won't be raided, so we will have 48GB of swap''
  6 200GB /raidvar  ''will be raided /var partition''
  6 200GB /raidvar  ''will be raided /var partition''
Set the type on the RAID partitions to Linux Raid (type=FD) for 2 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.  
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.  
Line 26: Line 28:


Unmount the extra filesystems and remove their entries from /etc/fstab.
Unmount the extra filesystems and remove their entries from /etc/fstab.
=== Remove dmraid now! ===
This is true for Ubuntu Server 9.10, not sure about other releases.
It turns out that the dmraid and mdadm packages fight for ownership of the raid drives and that mdadm loses; this means once you have RAID working and you reboot, you won't be able to access the drives you create with mdadm.
So remove it now... if you wait until later you will have to back up 3 steps and reboot more times... do it right now.
apt-get --purge remove dmraid


== Create RAID filesystems ==
== Create RAID filesystems ==

Revision as of 22:48, 21 January 2010

Shorthand notes on how to convert a new Ubuntu system to RAID 1

Install Ubuntu Server

System has 12GB of RAM

System has two 250GB drives (actually a 320 and a 250, I ignore the extra space for now)

During installation create 6 partitions on each drive, so that the system can be converted to RAID 1 (mirrored)

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

Set the type on the RAID partitions to Linux Raid (type=FD) for 2 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.

Add packages

Do the Ubuntu Server installation. After it's done install the package to manage raid

apt-get install mdadm

Unmount the extra filesystems and remove their entries from /etc/fstab.

Create RAID filesystems

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

First convert the second and sixth partitions to RAID1

mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sda2 /dev/sdb2
mdadm --monitor /dev/md0
mdadm --create --verbose /dev/md2 --level=mirror --raid-devices=2 /dev/sda6 /dev/sdb6
mdadm --monitor /dev/md2

Make filesystems on the new RAID devices mke2fs -j /dev/md0 mke2fs -j /dev/md2

Create mount points for testing. I use /raidroot and /raidvar. Add temporary entries to /etc/fstab, Use the "blkid" command to find a UUID for a filesystem.

Check /proc/mdstat to see if RAID reconstruction is complete. Then reboot to single user mode. The reboot is mostly just to confirm things are working with RAID and the kernel so far.

Copy

I prefer to do this from a rescue disk; adjust command accordingly

mkdir /tmp/root & mount /dev/sd3 /tmp/root
mkdir -p /tmp/raidroot/var
mount /dev/md0 /tmp/raidroot
mount /dev/md2 /tmp/raidroot/var
cd /tmp/root
tar cvf - . | (cd /tmp/raidroot; tar xpf -) 

Edit the copied /etc/fstab in /dev/md0 to make it use the newly root and var.

cd /tmp/raidroot
vi fstab

Edit the grub stuff to add the capability to boot using the new root partition; you probably can't boot into it yet from the hard drive. Boot into the old /dev/sda3 root and do an update-initramfs. Then try to boot into /dev/md0

If it boots successfully then repeat the above steps to create a RAID 1 backup of /dev/md0 onto /dev/md1.

Remember to also copy the /boot partition once you have the RAID set up.

cd /boot tar cvf - . | (cd /boot_backup; tar xpf -)

This makes it possible to get the system going again if you lose drive sda. sdb won't be bootable but you can bring things online with a rescue CD or you could go ahead and make it bootable if you want to mess with grub more

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.