Jump to content
Aerosol

Software Raid Mirror on RHEL 6

Recommended Posts

Posted

For this let's think that sda is the first HDD and sdb is the second one.

To do this we must do some steps:

- Partitioning

- Configure boot device

- Create the new swap device

- Configure LVM

- Configure Grub

On the first step, Partitioning, we should do the next:


sfdisk -d > disks.out
sfdisk /dev/sdb <disks.out

parted /dev/sda set 1 raid on
parted /dev/sda set 2 raid on
parted /dev/sda set 3 raid on
parted /dev/sda set 5 raid on

parted /dev/sdb set 1 raid on
parted /dev/sdb set 2 raid on
parted /dev/sdb set 3 raid on
parted /dev/sdb set 5 raid on

mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1 --metadata=0.90
mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/sdb2 --metadata=1.0
mdadm --create /dev/md2 --level=1 --raid-disks=2 missing /dev/sdb3 --metadata=1.0
mdadm --create /dev/md3 --level=1 --raid-disks=2 missing /dev/sdb5 --metadata=1.0

After that we must configure the boot device:


mkfs.ext4 /dev/md0

mkdir /mnt/md0
mount /dev/md0 /mnt/md0
cp -dpRx /boot/* /mnt/md0
sync
umount /mnt/md0
rmdir /mnt/md0

umount /boot
mount /dev/md0 /boot

mdadm /dev/md0 -a /dev/sda1

mdadm -D /dev/md0

Finding the UUID using command:


blkid |grep md0
/dev/md0: UUID="d43e4912-57b3-456a-8ef2-af747d37bead" TYPE="ext4"

Uptate it in /etc/fstab:


# grep boot /etc/fstab
#UUID=3428cd4c1-c81b-4d94-240b-12f9020e870e /boot ext4 defaults 1 2
UUID=d43e4912-57b3-456a-8ef2-af747d37bead /boot ext4 defaults 1 2

Verify that both of your disks are listed in*/boot/grub/device.map add them if needed.


cat /boot/grub/device.map
(hd0) /dev/sda
(hd1) /dev/sdb

Install grub on both devices:


grub-install /dev/sda
grub-install /dev/sdb

Create the new swap device

mkswap /dev/md1
swapoff /dev/sda2

mdadm --add /dev/md1 /dev/sda2
swapon /dev/md1
blkid | grep md1

Update the /etc/fstab file.

Configure LVM

pvcreate /dev/md2
pvcreate /dev/md3
vgextend ROOTVOL /dev/md2
vgextend ROOTVOL /dev/md3

pvmove /dev/sda3 /dev/md2
pvmove /dev/sda5 /dev/md3

vgreduce ROOTVOL /dev/sda3
vgreduce ROOTVOL /dev/sda5

pvremove /dev/sda3
pvremove /dev/sda5

mdadm /dev/md2 -a /dev/sda3
mdadm /dev/md3 -a /dev/sda5

mdadm --examine --scan >/etc/mdadm.conf

Configure Grub

Remove rd_NO_MD from lines in /boot/grub/grub.conf

dracut -f

rm -f /etc/lvm/cache/.cache
vgscan

Entering grub:

grub
grub> find /grub/grub.conf
root (hd0,0)
setup (hd0)
root (hd1,)
setup (hd1)
quit grub

Author: razvan1@hy

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...