1. Why?
This howto explains how to have a working setup using LVM and RAID1 ready to host Xen VPS.
You will need LVM to give a (fast) physical partition to your VPS, but Linux don't know how to boot on LVM, so you will need to use a small RAID1 partition on which you will boot.
2. Booting
First, boot the Debian Installer (DI). On the syslinux prompt, you need to type "expert26" in order to boot with kernel 2.6 and have the installer ask more questions.
Do the begining of the setup as usual, but don't forget to ask to load the RAID and the LVM modules. Then you should arrive at the partition setup screen.
3. Creating the physical partitions
You should now create the partitions for RAID1. First, create a small partition at the begining of each disks. They will be used for the / (root partition), and it shouldn't be bigger than 800 MB. Set the boot flag on each disks for this partition, and select "use as", then "physical device for RAID".
Then select the free space on each disk, and create a partition that should take all the remaining space but 5BG, and then select to use them as RAID device. You should leave 5GB unused for 2 reasons. First, the end of the disks are often where you find bad sectors. Second, when a HDD needs to be replaced, it's hard to find exactly the same type. If you buy a replacement disk that is few MB smaller, and can't create a RAID1 partition of exactly the same size, then you are stucked.
Now you should have 2 disks, with each 1 small partition of 800 MB with the boot flag on, and a big one with all the rest of the space but 5GB. All partition marked to be used for RAID1. It's time to go in "finish and write to disk", and then reboot (yes, without the partition being mounted!). Linux loads the partition tables ONLY at boot time, so you really need to reboot.
4. Creating 2 RAID1 devices
Restart the installer, do like you did before, and reach the partitionning utility. You should now see the partitions you created.
Go in the RAID utility menu of the partition screen (on top of the menu). Select the option to create RAID device, select RAID1, say you want to use 2 disks, and no spare disk. Select the first and the third entry (the small boot partition on each disks). Do it again with the 2 remaining partition (that big one) on each disk. Leave the RAID1 menu. It should start to do the copy of the first disk to the 2nd (RAID1 is done at device level, not filesystem, it never knows if the disks are empty, in fact it doesn't care at all of the content of the datas itself).
Now you should see the 2 partitions on each disks, plus 2 RAID1 devices.
5. Creating the LVM devices
Select the 2nd RAID1 device (the one using the big partition). Say you want to use it as a LVM device, then go back to the main screen.
It's now time to create the LVM partitions. Go on the top entry of the partition screen, and select LVM. Go in the "volume group" management, and create the LVM array. It should ask you for a name, call it "lvm1", and select the (only) available device you just created that is in fact the big RAID1 device.
Exit the volume group creation menu, and now go in the "logical volume" creation. Create 5 logical volumes. It will ask you for a name, just call it "usr" for the /usr partition and so on. A partition scheme like this one should be ok:
name size
usr 3GB
var 1GB
tmp 400MB
root 400MB
swap 512MB
This should leave most of the LVM space free to be used by your all your VPS.
6. Selecting type (ext3) and mount points
Exit the LVM utility, and go back to the main partition screen. You should now see the 2 raid1 device, the 5 logical volumes you did, and the 2 physical partitions on each disks. It's time for you to mount the partitions.
First, select the small RAID1 device. Say you want to use it as ext3, and that the mount point is / (the root partition).
Then select the "usr" logical volume say you want to use it as ext3, and select the mount point. Do the same for /var, /tmp and /root (for /root you will need to type the full path of the mount point). Select the "swap" logical volume and say you want to use it as swap space.
7. You are good to go!
All your partitions are now created and the mount point is selected for all of them. Just go in "Finish and write change to disk", it will format them all and do the rest of the install as usual.
One last thing: the DI will warn you again that Linux doesn't load partition tables on the fly, but at boot time only. Just ignore the message this time: it's true it can't load the partition tables, but it knows about the changes you did with LVM and RAID1 arrays.
8. Important thing
When doing this, you HAVE to follow the order:
- Create the RAID partitions on both disks
- Reboot
- Create the LVM physical volume
- Create the LVM logical volumes
- Mount the / on the first RAID1 device
- Select the moint point for the LVM volumes
If you don't, you will screw everything.
Editing this page means accepting its license.