1.3 KiB
1.3 KiB
Linux+ 1.3.5: Software RAID
A RAID 1 mirror with a hot spare, a failed disk, the spare taking over, and the old disk coming back as the new spare.
Before you start
The lab installs mdadm and adds three empty 1 GiB spare disks,
/dev/loop40, /dev/loop41 and /dev/loop42 (the chapter's vdb, vdc
and vdd). They come back at every boot, but the array isn't set up to
start and mount at boot, so do the tasks in one go and run le-lab check
before you clean up.
Tasks
- Build
/dev/md0, a RAID 1 of/dev/loop40and/dev/loop41with/dev/loop42as a spare. Put ext4 on it, mount it at/mnt/raid, and writehelloto/mnt/raid/file. - Mark
/dev/loop40as failed and watch the spare take over. The file is still readable. - Remove the failed disk from the array, wipe its RAID superblock, and add it back as the new spare.
When le-lab check passes, clean up as the chapter shows (unmount, stop the
array, wipe the superblocks), or leave it to le-lab reset.
Hints
mdadm --create /dev/md0 --level=1 --raid-devices=2 --spare-devices=1 --metadata=1.2 ...;cat /proc/mdstat;mdadm --wait /dev/md0waits for a sync to finish.mdadm /dev/md0 --fail DISK;mdadm --detail /dev/md0.mdadm /dev/md0 --remove DISK,mdadm --zero-superblock DISK,mdadm /dev/md0 --add DISK.