How to grow RAID+LUKS+lvm+xfs

How to grow RAID+LUKS+lvm+xfs
clone partition table, add disk to mdraid, resize mdraid, cryptsetup and Volume Group


If you like to add a new disk to mdadm raid, you should clone the partition layout.

sgdisk -R /dev/sdY /dev/sdX
sgdisk -G /dev/sdY

The first command copies the partition table of sdX to sdY (be careful not to mix these up). The second command randomizes the GUID on the disk and all the partitions. This is only necessary if the disks are to be used in the same machine, otherwise it’s unnecessary.

Add new disks to raid:

mdadm --add /dev/sdb1 

Grow the raid:

mdadm --grow --raid-devices=9 --backup-file=/tmp/grow_md2.bak /dev/md2

Information of reshape:

cat /proc/mdstat                                                                                                                                                                                                                                                                                     
Personalities : [raid1] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid10] 
md1 : active raid1 sdg4[5] sdh4[4] sdi4[3] sdj4[1]
      927603520 blocks super 1.2 [4/3] [UUU_]
md0 : active raid1 sdg2[5] sdi2[0] sdh2[4] sdj2[1]
      976320 blocks super 1.2 [4/3] [UUU_]
md2 : active raid6 sdg5[10](S) sdi5[8] sdj5[9] sdh5[11] sdd1[3] sdb1[0] sdf1[5] sdc1[2] sde1[4] sda1[1]
      20510934528 blocks super 1.2 level 6, 512k chunk, algorithm 2 [10/9] [UUUUUUUU_U]
      [====>................]  reshape = 20.2% (592765952/2930133504) finish=3123.9min speed=12469K/sec
unused devices: 

Speed up the rebuild or reshape:

If you only have 1000, you should set to a higher value.

cat /proc/sys/dev/raid/speed_limit_min                                                                                                                                                                                                                                                           

Set the speed_limit_min to 50000.

echo 50000 > /proc/sys/dev/raid/speed_limit_min

Resize the partition with parted:

parted /dev/md2 resizepart

Resize the LUKS partition:

cryptsetup resize cryptvg

Show the status from the LUKS partition:

cryptsetup status cryptvg

Show the status from the physical volume:


Resize the physical volume

pvresize /dev/mapper/cryptvg 

Show the status from the volume group:


Resize the xfs filesystem:

xfs_growfs /dev/cryptvg/test


Detail information of the mdadm raid.

mdadm --detail /dev/md1

If you have a problem with the raid:

mdadm --stop /dev/md2
mdadm --assemble /dev/md2  /dev/sdh5 /dev/sdb1 /dev/sde1 /dev/sdc1 /dev/sdf1 /dev/sdd1 /dev/sda1 /dev/sdi5 /dev/sdg5
mdadm --run /dev/md2

If it now work, force:

mdadm --assemble --run --force  /dev/md2 /dev/sdb1 /dev/sde1 /dev/sdc1 /dev/sdf1 /dev/sdd1 /dev/sda1 /dev/sdi5 /dev/sdg5 /dev/sdh5

Disk status

mdadm --examine /dev/sd*

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.