how to create raid 1 on xenserver-6.2

6
Creating a Raid On A Xenserver 6.2 The command below display basic partition summary data. This includes partition numbers, starting and ending sector numbers, partition sizes, sgdisk’s partition types codes, and partition names. [root@flock /]# sgdisk -p /dev/sda Disk /dev/sda: 1953525168 sectors, 931.5 GiB Logical sector size: 512 bytes Disk identifier (GUID): 5091FFD8-6EE9-433B-8173-04181CEFFAA8 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 6042 sectors (3.0 MiB) Number Start (sector) End (sector) Size Code Name 1 2048 8388641 4.0 GiB 0700 2 8390656 16777249 4.0 GiB 0700 3 16779264 1953525134 923.5 GiB 8E00 The command below --zap-all (destroy) the GPT and MBR data structures and then exit. This option works much like -z, but as it wipes the MBR as well as the GPT, it’s more suitable if you want to repartition a disk after using this option, and completely unsuitable if you’ve already repartitioned the disk. sgdisk --zap-all /dev/sdb The command below convert an MBR or BSD disklabel disk to a GPT disk. As a

Upload: lbonilla3089

Post on 17-Jan-2016

11 views

Category:

Documents


0 download

DESCRIPTION

Instruction on now to set up raid 1 on Xenserver-6.2

TRANSCRIPT

Page 1: How to Create Raid 1 on Xenserver-6.2

Creating a Raid On A Xenserver 6.2

The command below display basic partition summary data. This includes partition numbers, starting and ending sector numbers, partition sizes,

sgdisk’s partition types codes, and partition names.

[root@flock /]# sgdisk -p /dev/sda

Disk /dev/sda: 1953525168 sectors, 931.5 GiB

Logical sector size: 512 bytes

Disk identifier (GUID): 5091FFD8-6EE9-433B-8173-04181CEFFAA8

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 6042 sectors (3.0 MiB)

Number Start (sector) End (sector) Size Code Name

1 2048 8388641 4.0 GiB 0700

2 8390656 16777249 4.0 GiB 0700

3 16779264 1953525134 923.5 GiB 8E00

The command below --zap-all (destroy) the GPT and MBR data structures and then exit.This option works much like -z, but as it wipes the MBR as well

as the GPT, it’s more suitable if you want to repartition a disk

after using this option, and completely unsuitable if you’ve

already repartitioned the disk.

sgdisk --zap-all /dev/sdb

The command below convert an MBR or BSD disklabel disk to a GPT disk. As a safety measure, use of this option is required on MBR or BSD disklabel

disks if you intend to save your changes, in order to prevent

accidentally damaging such disks.

sgdisk --mbrtogpt --clear /dev/sdb

Page 2: How to Create Raid 1 on Xenserver-6.2

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 a new partition. You enter a partition number, starting

sector, and an ending sector. Both start and end sectors can be

specified in absolute terms as sector numbers or as positions

measured in kilobytes (K), megabytes (M), gigabytes (G), or ter-

abytes (T); for instance, 40M specifies a position 40MiB from

the start of the disk. You can specify locations relative to the

start or end of the specified default range by preceding the

number by a ’+’ or ’-’ symbol, as in +2G to specify a point 2GiB

after the default start sector, or -200M to specify a point

200MiB before the last available sector. Pressing the Enter key

with no input specifies the default value, which is the start of

the largest available block for the start sector and the end of

the same block for the end sector.

Number Start (sector) End (sector) Size Code Name

sgdisk --new=1:2048:8388641 /dev/sdbsgdisk --typecode=1:fd00 /dev/sdbsgdisk --attributes=1:set:2 /dev/sdbsgdisk --new=2:8390656:16777249 /dev/sdbsgdisk --typecode=2:fd00 /dev/sdbsgdisk –new=3:16779264:1953525134 /dev/sdb

Page 3: How to Create Raid 1 on Xenserver-6.2

sgdisk --typecode=3:fd00 /dev/sdb

Now Reboot

After the reboot create the raid:

mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb2mdadm --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/md0mount /dev/md0 /mntcp -vxpR / /mnt

This will replace what ever is currently in fstab with /dev/md0:sed -i 's/LABEL=[a-zA-Z\-]*/\/dev\/md0/' /mnt/etc/fstabThis will Create a new boot image and uncompress it. You should still be in / until tell you cd to another folder.mkdir /mnt/root/initrd-raidmkinitrd -v --fstab=/mnt/etc/fstab /mnt/root/initrd-raid/initrd-`uname -r`-raid.img `uname -r`cd /mnt/root/initrd-raidzcat initrd-`uname -r`-raid.img | cpio -iEdit ‘init’ and insert ‘raidautorun …’:sed -i 's/raidautorun \/dev\/md0/raidautorun \/dev\/md0\nraidautorun \/dev\/md1\nraidautorun \/dev\/md2/' initThis copy the new ramdisk to the new location.find . -print | cpio -o -Hnewc | gzip -c > /mnt/boot/initrd-`uname -r`-raid.imgrm /mnt/boot/initrd-2.6-xen.imgcd /mnt/bootln -s initrd-`uname -r`-raid.img initrd-2.6-xen.imgReplace 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/sdbcat /mnt/usr/share/syslinux/gptmbr.bin > /dev/sdbcd /mntextlinux --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/sdasgdisk --typecode=1:fd00 /dev/sdasgdisk --typecode=2:fd00 /dev/sdasgdisk --typecode=3:fd00 /dev/sdamdadm -a /dev/md0 /dev/sda1mdadm -a /dev/md1 /dev/sda2mdadm -a /dev/md2 /dev/sda3

Page 4: How to Create Raid 1 on Xenserver-6.2

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

name-description ( RW): Physical DVD drives

host ( RO): flock

type ( RO): udev

content-type ( RO): iso

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

Page 5: How to Create Raid 1 on Xenserver-6.2

name-label ( RW): XenServer Tools

name-description ( RW): XenServer Tools ISOs

host ( RO): flock

type ( RO): iso

content-type ( RO): iso

Find Your local storage uuid:

The uuid might look like: dce9fc00-3cd9-92c7-be04-be29382dca7f

2) Find uuid of PDB connected to Your local storage (sr-uuid is Your local storage uuid):xe pbd-list sr-uuid=1773cdf2-69e3-ab30-6559-832b9fb2885d

Look for PDB uuid, which is in the first line of the answer.

3) Unplug PDB from local storage:xe pbd-unplug uuid=PDB_UUID

4) Forget the local storage sr:xe sr-forget uuid=dce9fc00-3cd9-92c7-be04-be29382dca7f

5) Now add the sda3 to md2 array:mdadm -a /dev/md2 /dev/sda3

The array needs to complete its initial build/synchronisation. That is gonna take a while. Follow its progress with: watch -n 1 cat /proc/mdstatWhen it finish than do the next step

6) Recreate local storage on md2: [root@flock ~]# pvcreate --metadatasize 10M /dev/md2WARNING: software RAID md superblock detected on /dev/md2. Wipe it? [y/n] y   Wiping software RAID md superblock on /dev/md2.   Physical volume "/dev/md2" successfully created

[root@flock ~]# xe sr-create name-label="Local Storage" type=lvm device-config:device=/dev/md2 shared=false

When it’s done on all three arrays, copy the RAID setup to /etc/mdadm.confmdadm --detail --scan >> /etc/mdadm.conf