Professional Documents
Culture Documents
How To Create Raid 1 On Xenserver-6.2
How To Create Raid 1 On Xenserver-6.2
2
The command below display basic partition summary data. This includes
partition
numbers, starting and ending sector numbers, partition sizes,
sgdisks
partition
Number
Start (sector)
End (sector)
Size
Code
2048
8388641
4.0 GiB
0700
8390656
16777249
4.0 GiB
0700
16779264
1953525134
923.5 GiB
8E00
Name
The command below --zap-all (destroy) the GPT and MBR data structures
then exit.
This option works much like -z, but as it wipes the MBR as well
and
using
this
option,
if
you
sgdisk -p /dev/sdb
[root@flock /]# sgdisk -p /dev/sdb
Disk /dev/sdb: 1953525168 sectors, 931.5 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): C8C73907-8167-4AAC-AF48-6C75A0F666D0
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1953525134
Partitions will be aligned on 2048-sector boundaries
Total free space is 1953525101 sectors (931.5 GiB)
Below I create
sector, and an ending sector. Both start and end sectors can
specified
in
absolute
be
(T);
for
the start of the disk. You can specify locations relative to the
start
or
end
of
the
default
start
sector,
key
Start (sector)
End (sector)
Size
--new=1:2048:8388641 /dev/sdb
--typecode=1:fd00 /dev/sdb
--attributes=1:set:2 /dev/sdb
--new=2:8390656:16777249 /dev/sdb
--typecode=2:fd00 /dev/sdb
new=3:16779264:1953525134 /dev/sdb
Code
Name
of
Now Reboot
After the reboot create the raid:
mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1
mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb2
mdadm --create /dev/md2 --level=1 --raid-devices=2 missing /dev/sdb3
These's command below will format, mount and copy. Make sure you are in / when
you run these commands.
mkfs.ext3 /dev/md0
mount /dev/md0 /mnt
cp -vxpR / /mnt
cd /mnt/root/initrd-raid
zcat initrd-`uname -r`-raid.img | cpio -i
Edit init and insert raidautorun :
sed -i 's/raidautorun \/dev\/md0/raidautorun \/dev\/md0\nraidautorun \/dev\/md1\nraidautorun
\/dev\/md2/' init
rm /mnt/boot/initrd-2.6-xen.img
cd /mnt/boot
ln -s initrd-`uname -r`-raid.img initrd-2.6-xen.img
Replace in /mnt/boot/extlinux.conf string root=LABEL=root- to
root=/dev/md0 in all menu entries.
sed -i 's/LABEL=[a-zA-Z\-]*/\/dev\/md0/' extlinux.conf
Set up MBR for GPT on /dev/sdb
cat /mnt/usr/share/syslinux/gptmbr.bin > /dev/sdb
cd /mnt
extlinux --raid -i boot/
Reboot (IMPORTANT: Set your server to boot from the SECONDARY HDD before booting!)
When XenServer is up again, include /dev/sda in the array with the following commands:
sgdisk --attributes=1:set:2 /dev/sda
sgdisk --typecode=1:fd00 /dev/sda
sgdisk --typecode=2:fd00 /dev/sda
sgdisk --typecode=3:fd00 /dev/sda
mdadm -a /dev/md0 /dev/sda1
mdadm -a /dev/md1 /dev/sda2
mdadm -a /dev/md2 /dev/sda3
When trying to add /dev/sda3 to /dev/md2 array and you encountered an error:
mdadm: Cannot open /dev/sda3: Device or resource busy
To fix it I had to do these commands:
xe sr-list
Below is the display from this command:
[root@flock ~]# xe sr-list
uuid ( RO)
: 066c92ea-52cd-1b34-de7b-ce16376c3afb
name-label ( RW): DVD drives
uuid ( RO)
: 1773cdf2-69e3-ab30-6559-832b9fb2885d
name-label ( RW): Local storage
name-description ( RW):
host ( RO): flock
type ( RO): lvm
content-type ( RO): user
uuid ( RO)
: 2260f315-6cf1-6ce4-7a9a-e6a6410be3d2
name-label ( RW): Removable storage
name-description ( RW):
host ( RO): flock
type ( RO): udev
content-type ( RO): disk
uuid ( RO)
: 848b9e96-df82-cd17-bba8-1a23e5adf830
When its done on all three arrays, copy the RAID setup to /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf