### Configuring and using a software RAID1 (mirroring) with mdadm ### | |
Linux has a really nice support for software RAIDs. The backend tool to manage … | |
*** CREATING THE RAID1 MIRROR *** | |
Creating the RAID1 mirror, using two disks: sdb and sdc: | |
# mdadm --create --verbose /dev/md0 --level=mirror --metadata 1.0 --raid-device… | |
You can also build your RAID-1 with only 1 disk, and add the second one later (… | |
# mdadm --create --verbose /dev/md0 --level=mirror --metadata 1.0 --raid-device… | |
Note that I explicitely asked for an array superblock in version 1.0. This is a… | |
Version 1.0 is stored near the end of the device (at least 8K, and less than 12… | |
You will notice that building the array takes a long time - several hours, or e… | |
# mdadm --grow --bitmap=internal /dev/md0 | |
It's important to keep your mdadm.conf up to date. To do it, use the following … | |
# mdadm --detail --scan > /etc/mdadm/mdadm.conf | |
*** MAKE YOUR RAID BOOTABLE *** | |
If you'd like to make your mdadm array bootable, there are a few details to kno… | |
Apparently you need Grub2 to be able to boot from the RAID (incidentally Grub2 … | |
By default, Grub locates disks using their UUID. This can become messy with RAI… | |
GRUB_DISABLE_LINUX_UUID=true | |
Grub needs a so-called 'device map'. It's basically a text file that provides t… | |
(hd0) /dev/disk/by-id/ata-Hitachi_HDT721010SLA360_STF607MH3VJKBK | |
(hd1) /dev/disk/by-id/ata-ST1000DM003-9YN162_S1DAAY5W | |
(hd2) /dev/md0 | |
EDIT: It would seem that the current (as of 26 Dec 2015) version of Grub2 doesn… | |
Once you're done, you can call the 'update-grub2' command that will recompute a… | |
Example: | |
# grub-install --no-floppy /dev/sda | |
# grub-install --no-floppy /dev/sdb | |
Yes, this IS counter-intuitive, because one would think that doing grub-install… | |
But grub is not the only one involved in the boot process - it will only load a… | |
INITRDSTART='all' | |
...And then, update the initramfs image via 'update-initramfs -u'. Since then, … | |
Last note: Not directly related to RAID, but I wasted a few hours on this. Even… | |
*** DAY TO DAY MANAGEMENT OF THE ARRAY *** | |
How do I check the RAID status? | |
# mdadm --detail /dev/md0 | |
# cat /proc/mdstat | |
How to run a consistency check on the array? | |
# echo check > /sys/block/md0/md/sync_action | |
How to remove a failed drive? This is a two steps process. First mark the drive… | |
# mdadm --manage /dev/md0 --fail /dev/sdb | |
# mdadm --manage /dev/md0 --remove /dev/sdb | |
If you'd like to erase the RAID tag from the drive (for example to avoid Linux … | |
# mdadm --zero-superblock /dev/sdb | |
Adding a new drive into the array: | |
# mdadm --manage /dev/md0 --add /dev/sdb | |
Growing the size of an array after replacing disks with bigger ones: | |
# mdadm --grow /dev/md0 --size=max | |