Proxmox VE Software RAID (MDRAID) Installation.

Proxmox VE installation can’t be done from scratch to a Software-RAID Device (MD RAID).

Here is a simple guide covering this kind of setup, doing some post-install work.

First of all, let’s start by having a box equipped with two identical Hard Drives (assuming that they’re seen by Linux as /dev/sda and /dev/sdb) and Proxmox VE installed in standard mode in /dev/sda as proposed from the installer GUI.

LogIn into the box via SSH, install MD RAID Utilities and perform a system upgrade:

apt-get update
apt-get install mdadm
apt-get dist-upgrade

Reboot the box if the kernel has been upgraded by the dist-upgrade task.

Copy the partition table from /dev/sda to /dev/sdb with sfdisk:

sfdisk -d /dev/sda | sfdisk -f /dev/sdb

Check the work with fdisk:

fdisk -l /dev/sda
fdisk -l /dev/sdb

Change/dev/sdb partition types to Linux MD (Software RAID) with sfdisk:

sfdisk -c /dev/sdb 1 fd
sfdisk -c /dev/sdb 2 fd

Initialide the two RAID Devices (MD Array) with mdadmin, by adding /dev/sdb MD partitions:

mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1
mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/sdb2

Create the EXT3 FileSystem (or EXT4 if you specified it in the Proxmox VE Installation) in the first MD Device and copy the /boot directory (used to boot the system later) inside it:

mkfs.ext3 /dev/md0
mkdir /mnt/md0
mount /dev/md0 /mnt/md0
cp -ax /boot/* /mnt/md0

Change FSTAB to mount /boot from the /dev/md0 device instead of find it bu its UUID, by editing /etc/fstab file.
The line containing the /boot mountpoing with UUID, needs to be replaced with:

/dev/md0 /boot ext3 defaults 0 1

Reboot the system, if all has been done correctly /dev/md0 is now mounted on /boot (check the work with ‘mount | grep boot’).

After that, GRUB Boot Loader needs to be configured to boot from the MD Array. This can be done by editing /etc/default/grub file, adding the following two lines:

GRUB_DISABLE_LINUX_UUID=true
GRUB_PRELOAD_MODULES="raid dmraid"

Add the raid1 module by adding a line containig ‘raid1’ in /etc/modules and /etc/initramfs-tools/modules then install GRUB on both Hard Disks, update it and also update initramfs:

grub-install /dev/sda
grub-install /dev/sdb
update-grub
update-initramfs -u

It is time now to add /dev/sda1 to the MD RAID, to do this let’s change the partition type to FD and add the partition to the already configured MD Array:

sfdisk -c /dev/sda 1 fd
mdadm --add /dev/md0 /dev/sda1

After that /dev/md0 should resync automatically, check it with ‘cat /proc/mdstat’. After resync has been done, the output should appear like this:

Personalities : [raid1] 
md0 : active raid1 sda1[2] sdb1[1]
      522944 blocks super 1.2 [2/2] [UU]
md1 : active raid1 sdb2[1]
      976106304 blocks super 1.2 [2/1] [_U]
unused devices: <none>

Time to work with LVM now, Proxmox VE installation process created a LVM on /dev/sda2 by default, we have to move it on /dev/md1 instead:

pvcreate /dev/md1
vgextend pve /dev/md1
pvmove /dev/sda2 /dev/md1

The PVMove will take long time to complete, this depends on CPU and Disk Speed. After completion, finish the work by removing the old Volume Group:

vgreduce pve /dev/sda2
pvremove /dev/sda2

Finally, as last action, let’s add /dev/sda2 to the MD raid (/dev/md1)

sfdisk -c /dev/sda 2 fd
mdadm --add /dev/md1 /dev/sda2

After that /dev/md1 should resync automatically, check it with ‘cat /proc/mdstat’, the output should appear like this:

Personalities : [raid1] 
md0 : active raid1 sda1[2] sdb1[1]
      522944 blocks super 1.2 [2/2] [UU]
 
md1 : active raid1 sda2[2] sdb2[1]
      976106304 blocks super 1.2 [2/1] [_U]
      [>....................]  recovery =  0.0% (651264/976106304) finish=474.2min speed=34277K/sec
 
unused devices: <none>

After Array-Sync, the Proxmox Installation will be operative in MD RAID (Mirror) as expected.


Comments are closed.