How To Create A RAID1 Setup On An Existing CentOS/RedHat 6.0 System
How To Create A RAID1 Setup On An Existing CentOS/RedHat 6.0 SystemBy: Maurice Hilarius - Hard Data Ltd. - October 12, 2011 This tutorial is for turning a single disk CentOS 6 system into a two disk RAID1 system. The GRUB bootloader will be configured in such a way that the system will still be able to boot if one of the hard drives fails (no matter which one). NOTE: Everything has to be done as root: su - In this example the initial layout for the hard disks was: Disk with installed OS. "Original" Device Mountpoint Size -------------------------------------------------------------------------------- And we will be adding the other hard disk: /dev/sda (~1002GB). "Target disk". 1. Back everything up! You might want to get your data back after you crashed the conversion. Trust me on this! 2. Verify Backup! See above. 3. Create partitions on /dev/sda identical to the partitions on /dev/sdb: sfdisk -d /dev/sdb | sfdisk /dev/sda 4. We load a few kernel modules (to avoid a reboot): modprobe linear 5. Now run: cat /proc/mdstat The output should look as follows: root@server:~# cat /proc/mdstat Here we see now that the RAID kernel modules are working, but there are no RAID sets yet. 6. Run the following commands: mdadm --create /dev/md0 --level=1 --raid-disks=2 /dev/sda1 missing This generates the raid devices 0 to 3 in a degenerated state because the second drive is missing. 7. If you want to use Grub 0.97 (default in CentOS 5 or 6)) on RAID 1, you need to specify an older version of metadata than the default. Add the option "--metadata=0.90" to the above command. Otherwise Grub will respond with "Filesystem type unknown, partition type 0xfd" and refuse to install. This is supposedly not necessary with Grub 2. Like this: mdadm --create /dev/md0 --metadata=0.90 --level=1 --raid-devices=2 /dev/sda1 missing 8. Check the output of cat /proc/mdstat #cat /proc/mdstat md2 : active raid1 sdb5[1] md3 : active raid1 sdb6[1] md0 : active raid1 sdb1[1] unused devices: <none> 9. Create a mdadm.conf from your current configuration: mdadm --detail --scan > /etc/mdadm.conf 10. Display the contents of the file: cat /etc/mdadm.conf At the bottom of the file you should now see details about our (degraded) RAID arrays. 11. We use dracut to rebuild the initramfs with the new mdadm.conf: mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.old dracut --mdadmconf --force /boot/initramfs-$(uname -r).img $(uname -r) 12. Create the filesystems on these new software raid devices: mkfs.ext2 /dev/md0 # For /boot ext2 is good 13. Copy the data from the existing (and still running) partitions to the newly created raid partitions: mkdir /mnt/raid (If SELinux is in use also do this: touch /mnt/raid/.autorelabel ) sync mount /dev/md1 /mnt/raid NOTES: You really do not want to copy files in /tmp and /var/tmp. mount /dev/md2 /mnt/raid mount /dev/md3 /mnt/raid At this point we have our raid system created and the existing data was mirrored manually onto the new devices.
|



Recent comments
20 hours 58 min ago
21 hours 8 min ago
21 hours 54 min ago
23 hours 35 min ago
1 day 12 hours ago
1 day 14 hours ago
1 day 20 hours ago
2 days 7 hours ago
2 days 11 hours ago
2 days 14 hours ago