Adding new disks, including in mirroring of system partitions (md0 and md1)
- Add the new disks as hot spare, then remove them (will create the disklabel, otherwise just do this using parted)
- Check the partition table of a disk already used for system and swap. Find it by checking mdstat (cat /proc/mdstat)
# cat /proc/mdstat Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] md1 : active raid1 sdd2[3] sdb2[1] sdc2[2] sda2[0] 2097088 blocks [5/4] [UUUU_] md0 : active raid1 sdd1[3] sdb1[1] sda1[0] sdc1[2] 2490176 blocks [5/4] [UUUU_] unused devices:
# parted /dev/sda (parted) unit s (parted) p Model: ATA ST3000DM001-1CH1 (scsi) Disk /dev/sda: 5860533168s Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 2048s 4982527s 4980480s ext4 raid 2 4982528s 9176831s 4194304s linux-swap(v1) raid (parted) q
- Run parted on the new disk
# parted /dev/sde (parted) unit s (parted) p Model: ATA ST3000DM001-1CH1 (scsi) Disk /dev/sda: 5860533168s Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags (parted) mkpart system ext4 2048 4982527 (parted) mkpart swap linux-swap 4982528 9176831 (parted) p ... Number Start End Size File system Name Flags 1 2048s 4982527s 4980480s ext4 system 2 4982528s 9176831s 4194304s linux-swap(v1) swap (parted) q
- Add partitions to system and swap
# mdadm --add /dev/md0 /dev/sde1 # mdadm --add /dev/md1 /dev/sde2
- Check rebuild status using ‘cat /proc/mdstat’
- Final result should be something like:
# cat /proc/mdstat Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] md1 : active raid1 sde2[4] sdd2[3] sdb2[1] sdc2[2] sda2[0] 2097088 blocks [5/5] [UUUUU] md0 : active raid1 sde1[4] sdd1[3] sdb1[1] sda1[0] sdc1[2] 2490176 blocks [5/5] [UUUUU] unused devices: