Xenserver 7 migration to linux raid
Xenserver recently upgraded to the seventh version and of course I could not pass by.
Among the conspicuous buns (in addition to migration to CentOS 7) there is another disk partitioning with separately mounted / var / log (finally) and a root increased to 20 gigs (alleluia!).
But he is not able to do this when loading RAID of any level. So, you need to migrate the already installed system again.
Fortunately, if XenServer has just been installed, then this is not so scary.
So, I will not give installation manuals - nothing really changed there. If you install from scratch - during installation you do not need to create storage for the VM, we will do them later.
After installation, the breakdown will be something like this:
The first thing we do is turn off existing repositories (if there are any):
Naturally, pv and vg specify their own, and not just copy-paste;)
Now we stop and delete the RAID, if they are in the system:
At the same time, you may not have any partitions - for example, I did not have sda4 (apparently because I did not create storage during installation).
Below I believe that you do not have the / dev / sda4 partition.
Delete the partition table on / dev / sdb and copy it from / dev / sda:
Set RAID type for partitions:
We create, in fact, RAID:
Create a new swap partition.He will not live on RAID, so we will have two of them.
Create partitions (root and / var / logs) and mount:
Copy the files to a new section:
Create the mdadm.conf file:
We change mount points on RAID:
Copy the partition label to / dev / sdb:
We make chroot in our future system:
Install the bootloader:
Change the GRUB configuration to boot from RAID:
Exiting chroot:
Reboot. We set the second one as the boot disk, on which we created RAID. If something goes wrong - there will be a chance to boot from the "old" system and try again.
If everything went well, then we rewrite the table from / dev / sdb to / dev / sda:
And we add partitions in RAID:
Just in case, werecreate SWAP and reinstall the bootloader on / dev / sda:
We reboot again to verify that everything was installed correctly.
Well, that's all. Now it remains to connect (or create) partitions with data, add (if necessary) them to RAID and create / connect storage:
This material is a compilation of several howto found on the Web. Comments and additions are welcome in every possible way.
Among the conspicuous buns (in addition to migration to CentOS 7) there is another disk partitioning with separately mounted / var / log (finally) and a root increased to 20 gigs (alleluia!).
But he is not able to do this when loading RAID of any level. So, you need to migrate the already installed system again.
Fortunately, if XenServer has just been installed, then this is not so scary.
So, I will not give installation manuals - nothing really changed there. If you install from scratch - during installation you do not need to create storage for the VM, we will do them later.
After installation, the breakdown will be something like this:
/ (root) 18GB
(update) 18GB
/boot/efi 512M
/var/log 4GB
swap 1GB
0. Delete the old
The first thing we do is turn off existing repositories (if there are any):
xe sr-list
xe pbd-list sr-uuid=
xe pbd-unplug uuid=
xe sr-forget uuid=
Naturally, pv and vg specify their own, and not just copy-paste;)
Now we stop and delete the RAID, if they are in the system:
mdadm --stop /dev/md0
mdadm --stop /dev/md1
mdadm --stop /dev/md2
mdadm --stop /dev/md3
mdadm --stop /dev/md4
mdadm --stop /dev/md5
mdadm --zero-superblock /dev/sdb1
mdadm --zero-superblock /dev/sdb2
mdadm --zero-superblock /dev/sdb3
mdadm --zero-superblock /dev/sdb4
mdadm --zero-superblock /dev/sdb5
mdadm --zero-superblock /dev/sdb6
At the same time, you may not have any partitions - for example, I did not have sda4 (apparently because I did not create storage during installation).
Below I believe that you do not have the / dev / sda4 partition.
1. Building a new
Delete the partition table on / dev / sdb and copy it from / dev / sda:
sgdisk --zap-all /dev/sdb
sgdisk -R /dev/sdb /dev/sda
Set RAID type for partitions:
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
We create, in fact, RAID:
yes|mdadm --create /dev/md0 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb1 missing
yes|mdadm --create /dev/md1 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb2 missing
yes|mdadm --create /dev/md2 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb3 missing
yes|mdadm --create /dev/md3 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb5 missing
yes|mdadm --create /dev/md4 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb6 missing
Create a new swap partition.
mkswap /dev/md4
Create partitions (root and / var / logs) and mount:
mkfs.ext3 /dev/md0
mkfs.ext3 /dev/md3
mount /dev/md0 /mnt
mkdir -p /mnt/var/log
mount /dev/md3 /mnt/var/log
Copy the files to a new section:
cp -xR --preserve=all / /mnt
Create the mdadm.conf file:
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
2. We correct fstab and grub
We change mount points on RAID:
sed -i 's/LABEL=root-[a-zA-Z\-]*/\/dev\/md0/' /mnt/etc/fstab
sed -i 's/LABEL=swap-[a-zA-Z\-]*/\/dev\/sda6/' /mnt/etc/fstab
sed -i 's/LABEL=logs-[a-zA-Z\-]*/\/dev\/md3/' /mnt/etc/fstab
sed -i '/sda6/ a\/dev/sdb6 swap swap defaults 0 0 ' /mnt/etc/fstab
Copy the partition label to / dev / sdb:
e2label /dev/sda1 |xargs -t e2label /dev/sdb1
We make chroot in our future system:
mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys
mount --bind /proc /mnt/proc
mount --bind /run /mnt/run
chroot /mnt /bin/bash
Install the bootloader:
grub-install /dev/sdb
Create a new initrd:
Change the GRUB configuration to boot from RAID:
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' /boot/grub/grub.cfg
sed -i '/search/ i\ insmod part_msdos' /boot/grub/grub.cfg
sed -i '/search/ i\ insmod diskfilter mdraid09' /boot/grub/grub.cfg
sed -i '/search/ c\ set root=(hd0,gpt1)' /boot/grub/grub.cfg
Exiting chroot:
exit
Reboot. We set the second one as the boot disk, on which we created RAID. If something goes wrong - there will be a chance to boot from the "old" system and try again.
If everything went well, then we rewrite the table from / dev / sdb to / dev / sda:
sgdisk -R /dev/sda /dev/sdb
And we add partitions in RAID:
mdadm -a /dev/md0 /dev/sda1
mdadm -a /dev/md1 /dev/sda2
mdadm -a /dev/md2 /dev/sda3
mdadm -a /dev/md3 /dev/sda5
mdadm -a /dev/md4 /dev/sda6
Just in case, we
grub-install /dev/sda
We reboot again to verify that everything was installed correctly.
Well, that's all. Now it remains to connect (or create) partitions with data, add (if necessary) them to RAID and create / connect storage:
xe sr-create content-type=user device-config:device=/dev/md5 host-uuid= name-label=”SRRaid1-Local” shared=false type=lvm
This material is a compilation of several howto found on the Web. Comments and additions are welcome in every possible way.