mdadm
Created Friday 24 May 2019
Create a configuration file
Upgrade individual disks
Initial state:
sdb and sdc are for RAID array.
Create the array
Check the status
Set up LVM
vgcreate raid /dev/md0
vgdisplay
lvcreate -L 4G raid -n raid1
Create a filesystem, mount it, check it.
mkfs /dev/raid/raid1 mount /dev/raid/raid1 /srv df -h
Add a disk
Add the disk to the array, make it active.
mdadm --add /dev/md0 /dev/sdd mdadm --grow /dev/md0 --raid-devices=3
Monitor for the reshaping to complete.
Adjust the pv to accept the new array size. Confirm it is reflected in the vg.
vgdisplay
Add another, now larger, disk to the array, the first of three to upgrade.
Add the disk to the array, make it active by removing one of the existing ones.
mdadm /dev/md0 --fail /dev/sdb --remove /dev/sdb
Remove the old disk, replace it with another new one
Monitor for the reshaping to complete.
Add the new disk to the array, make it active by removing one of the existing ones.
mdadm --add /dev/md0 /dev/sdb mdadm /dev/md0 --fail /dev/sdc --remove /dev/sdc
Remove the old disk, replace it with another new one
Monitor for the reshaping to complete.
Add the new disk to the array, make it active by removing the last of the existing ones.
mdadm --add /dev/md0 /dev/sdc mdadm /dev/md0 --fail /dev/sdd --remove /dev/sdd
Remove the old disk.
Monitor for the reshaping to complete.
Grow the physical volume.
Confirm it.
Shut down all the things
umount /srv/ lvremove /dev/raid/raid1 vgremove raid pvremove /dev/md0 mdadm --stop /dev/md0 mdadm --remove /dev/md0
Convert SLED to RAID
Initial state:
sdb is the data disk.
sled-data is mounted at /mnt/sled.
Add sdc
Create a RAID1 array with a missing disk.
Create the LVM objects and filesystem
vgcreate raid /dev/md0
lvcreate -L 7G -n data raid
mkfs /dev/raid/data
mount /dev/raid/data /mnt/raid
Copy the data from the SLED disk to the RAID disk.
Unmount the SLED disk.
Destroy the SLED LVM objects.
vgremove sled
pvremove /dev/sdb
Add that disk to the array. Monitor until complete.
watch cat /proc/mdstat
End state:
sdb and sdc are the data disks.
raid-data is mounted at /mnt/raid.
Convert RAID1 to RAID5
Initial state:
sdb and sdc are the data disks.
raid-data is mounted at /mnt/raid.
Add sdd
Add the disk to the array
Change the RAID level to 5
Change the number of active disks in the array
Monitor until complete
End state:
sdb, sdc and sdd are the data disks.
raid-data is mounted at /mnt/raid.