Notes on RAID for Ubuntu: Difference between revisions
Brian Wilson (talk | contribs) |
Brian Wilson (talk | contribs) mNo edit summary |
||
Line 39: | Line 39: | ||
Make filesystems on the new RAID devices | Make filesystems on the new RAID devices | ||
mke2fs -j /dev/md0 | mke2fs -j /dev/md0 | ||
mke2fs -j /dev/md2 | |||
Create mount points for testing. I use /raidroot and /raidvar. | Create mount points for testing. I use /raidroot and /raidvar. | ||
Line 51: | Line 51: | ||
Copy. I prefer to do this from a rescue disk; adjust command accordingly | Copy. I prefer to do this from a rescue disk; adjust command accordingly | ||
mkdir /tmp/root | mkdir /tmp/root & mount /dev/sd3 /tmp/root | ||
mkdir -p /tmp/raidroot/var | |||
mkdir /tmp/raidroot | |||
mount /dev/md0 /tmp/raidroot | mount /dev/md0 /tmp/raidroot | ||
mount /dev/md2 /tmp/raidroot/var | |||
cd /tmp/root | cd /tmp/root | ||
tar cvf - . | (cd /tmp/raidroot; tar xpf -) | tar cvf - . | (cd /tmp/raidroot; tar xpf -) | ||
Edit the | Edit the copied /etc/fstab in /dev/md0 to make it use the newly root and var. | ||
to make it use the newly | |||
cd /tmp/raidroot | cd /tmp/raidroot | ||
vi fstab | vi fstab | ||
Edit the grub stuff to add the capability to boot using the new root partition | Edit the grub stuff to add the capability to boot using the new root partition; | ||
you probably can't boot into it yet. Boot into the old /dev/sda3 root and do an update-initramfs. Then try to boot into /dev/md0 | 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 | 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. | |||
Remember to also copy the /boot partition | |||
cd /boot | cd /boot | ||
Line 88: | Line 77: | ||
sdb won't be bootable but you can bring things online with a rescue CD | 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 | 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. |
Revision as of 18:46, 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
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.
Do the 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.