Installing Ubuntu 14.04 on RAID 1 and LVM
5 Replies
So you want an Ubuntu server machine running with RAID1 for reliability and LVM for flexibility.
I used a virtualbox guest. I created a test machine: 2CPUs, 2048MB RAM, 2 x 25Gb Hard disk.
Overview
The System disks will be split into three primary partitions.
- boot
- about 750Mb
- mount point /boot
- File system EXT4
- Bootable
- /dev/sda1 + /dev/sdb1 = /dev/md0
- root
- about 24Gb
- LVM volume group vg0
- LVM logical volume lv_root
- mount point / (root)
- File system EXT4
- /dev/sda2 + /dev/sdb2 = /dev/md1
- swap
- about 2Gb
- File system Swap
- /dev/sda3 + /dev/sdb3 = /dev/md2
Installation
Starting with the DVD/CD for Ubuntu Server, install as usual until the disk partition part. I am assuming you can do that. If not, go and learn the basics first!So you have chosen the language, territory, and set the keyboard layout, etc.Partitioning the Disks
After a short wait you will get to the Partition Disks menu select Manual.Add a Disk Partition Table
Select the first hard disk. As it it brand new we need to add a partition table to it.Press return and the on the next menu select Yes and press return.We have a partition table on the first disk.Repeat those steps to create the partition table for the second disk drive.Create the Partitions
We need to start creating the partitions, Highlight the FREE SPACE on the first disk and press return.Create a new partition for /boot, I used the odd 0.8GB for this.I only use Primary partitions here but you can use primary or Logical/Extended, it makes little difference for this example.Put is at the beginning of the free disk space or not your choice.Prepare for RAID
Highlight and then press return on the use as option selecting physical volume for RAID and set the Bootable flag: on. It should look as mine did below. Select Done setting up the partition to return back to the Partition Disks main menu.Use a similar process for root partition. Select the remaining free space on disk one. Create a partition this time I used 24GB, Primary, and Beginning. set Use as to be physical volume for RAID.For the swap partition use all the remaining disk space about 2GB. again set use as to bephysical volume for RAID.Repeat the above making an exact copy for the second drive, now you know why I choose the values I did :-).The disk should look similar to the followingCreate the MD Devices
Now to setup our three RAID1 arrays, /dev/md[012]. Highlight Configure RAID and press return. Write the change to the storage devices.To create our RAID1 MD devices, select partitions in pairs sda1 & sdb1, sda2 &sdb2 etc. Each MD device will have 2 disks and zero spares. The screen shot shows the disks for the boot partition. Repeat for the other two devices and then select finish.Back at the main menu again and it should look similar to the following:Add LVM to the root Partition
Configure the Logical Volume Manager, again write the changes to the disk to continue. Create a volume group.I called mine, vg0. But you can call it anything.Select the the /dev/md1 this is our root partition which will use LVM so we can snap shot it for backups.Create a Logical Volume, on the Volume group vg0.We need to leave some space for the snapshot, so I choose to use 20978Mb. I changed the second digit from a 3 to a zero.Finish and go back to the main menu again.Assign the Filesystems
Highlight the line under LVM VG vg0, LV lv_root to configure our root partition file system. Set it up as an EXT4 file system and a mount point of / (root). When it is all done it should look a bit like thisThe last two are a lot simpleryay!
Highlight the line under RAID device #0. This is the unused space on the device. Set it up as an EXT4 file system and a mount point of /boot.Now setup the swap partition on RAID device #2, it’s a similar process to the /boot partition.Overall it should look like thisSometimes when setting up the LVM you have to redo the /boot and swap partition if you configured those first, it’s rather annoying.Finish with the partitioning and save the changes to disk.Now complete the install as you would any other. I only select open ssh server from the package manager it makes the initial install much quicker. (If you break it you don’t have to wait so long for it to reinstall.)Setup Monitoring and Alerts
If you run the command below, it will configure some default behaviour for monitoring and checking.Manual Checking
To see it is all running okay, there are some commands you can use.Use the df command to see the mounted filesystems and what devices they are.You can see here that the root file system ‘/’ is from the device ‘/dev/mapper/vg0-lv_root’. Which was the volume group ‘vg0’ and the logical volume ‘lv_root’.‘/boot’ is from the device ‘/dev/md0’.To check the swap.You can see it is from the device /dev/md2 and is about 2GB.If you are quick enough or your disks are bigger than 25GB you may even catch the RAID1 system rebuilding. The output below does not show this I was too slow or the host I use for the virtuals is very quick.If you want to watch the array rebuild itself use the following commandTaking md1 above as an example the things to lookout for are that we can see two disks sda1[0] and sdb2[1] are listed. the number in brackets is the order of the disks in the array. On the second line we see ‘[2/2]’. This means there should be 2 twos in the array and there are 2 actually in it. The [UU] is the same thing again for windows uses, pretty but giving no real usable information.To view the status of one or more arrays:To check the status of a disk in an arrayThat’s it. a little long winded maybe be really not that hard, the second time.Oh wait, what happens WHEN a disk fails, that is why we wanted to use RAID!?