Oct 5, 2016, 14:00

Xenserver 7 software RAID installation issues.

Installing Xenserver on Hetzner physical server on software RAID from this source we encountered following issues:

  1. In case you initialized RAID before, you should stop any /dev/md* devices in order to go further with installation.
  2. Installation guides contain sed command usage, which potentially could cause grub errors when boot. Ensure to have proper boot sting in boot.cfg which looks like following: (md/md0). We encountered (/md/md/0) spelling several times after applying guides recommendation.

Installing Xenserver on software RAID is totally manual operation.

So, try following guide from 2016-10-05

### START ###
 
xe sr-list
xe pbd-list sr-uuid=<local storage-uuid>
xe pbd-unplug uuid=<uuid>
xe sr-forget uuid=<local storage-uuid>
 
sed -i 's/metadata_read_only = 1/metadata_read_only = 0/' /etc/lvm/lvm.conf
lvremove ...
vgremove ...
pvremove /dev/sda3
sed -i 's/metadata_read_only = 0/metadata_read_only = 1/' /etc/lvm/lvm.conf
 
sgdisk -R /dev/sdb /dev/sda
 
sgdisk --typecode=1:fd00 /dev/sdb
sgdisk --typecode=2:fd00 /dev/sdb
sgdisk --typecode=3:fd00 /dev/sdb
sgdisk --typecode=5:fd00 /dev/sdb
sgdisk --typecode=6:fd00 /dev/sdb
 
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 missing
mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdb2 missing
mdadm --create /dev/md2 --level=1 --raid-devices=2 /dev/sdb3 missing
mdadm --create /dev/md4 --level=1 --raid-devices=2 /dev/sdb5 missing
mdadm --create /dev/md5 --level=1 --raid-devices=2 /dev/sdb6 missing
 
mkfs.ext3 /dev/md0
mkfs.ext3 /dev/md4
mkswap /dev/md5
 
mount /dev/md0 /mnt
mkdir -p /mnt/var/log
mount /dev/md4 /mnt/var/log
 
cp -xa / /mnt
cp -xa /var/log /mnt/var
 
echo "MAILADDR root" > /mnt/etc/mdadm.conf
echo "auto +imsm +1.x -all" >> /mnt/etc/mdadm.conf
echo "DEVICE /dev/sd*[a-z][1-9]" >> /mnt/etc/mdadm.conf
mdadm --detail --scan >> /mnt/etc/mdadm.conf
cp /mnt/etc/mdadm.conf /etc
 
sed -i 's/LABEL=root-[a-zA-Z\-]*/\/dev\/md0/' /mnt/etc/fstab
sed -i 's/LABEL=swap-[a-zA-Z\-]*/\/dev\/md5/' /mnt/etc/fstab
sed -i 's/LABEL=logs-[a-zA-Z\-]*/\/dev\/md4/' /mnt/etc/fstab
cp /mnt/etc/fstab /etc
 
e2label /dev/sda1 |xargs -t e2label /dev/md0
 
mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys
mount --bind /proc /mnt/proc
chroot /mnt /bin/bash
 
cp /boot/initrd-$(uname -r).img /boot/initrd-$(uname -r).img.bak
 
dracut --mdadmconf --fstab --add="mdraid" --add-drivers="raid1" --force /boot/initrd-$(uname -r).img $(uname -r) -M
 
sed -i 's/quiet/rd.auto rd.auto=1 rhgb quiet/' /boot/grub/grub.cfg
sed -i 's/LABEL=root-[a-zA-Z\-]*/\/dev\/md0/' /boot/grub/grub.cfg
sed -i '/search/ i\  insmod gzio part_msdos diskfilter mdraid1x' /boot/grub/grub.cfg
sed -i '/search/ c\  set root=(md/0)' /boot/grub/grub.cfg
 
grub-install /dev/sda # Not sure if this works, since there is no raid on sda yet, so grub-install might not add the mdraid1x driver
grub-install /dev/sdb
 
exit
 
cp /mnt/boot/initrd-3.10.0+10.img /boot/
cp /mnt/boot/grub/grub.cfg /boot/grub/grub.cfg
 
reboot
 
sgdisk -R /dev/sda /dev/sdb
 
mdadm -a /dev/md0 /dev/sda1
mdadm -a /dev/md1 /dev/sda2
mdadm -a /dev/md2 /dev/sda3
mdadm -a /dev/md4 /dev/sda5
mdadm -a /dev/md5 /dev/sda6
 
# To be super save install grub on sda again, since it discovers the raid and adds the required drivers.
# grub-install /dev/sda
 
xe sr-create content-type=user device-config:device=/dev/md2 host-uuid=<host-uuid> name-label="Local storage" shared=false type=lvm
 
### END ###

Note: Use xe list-hosts to find host-uuid.

Share