Skip to main content

Rebuild XCP-NG OS RAID

XCP-NG uses mdadm for its software RAID, if you have selected the RAID option during the XCP-NG install. 

To rebuild the mdadm RAID, login to SSH to the XCP-NG host. 

Run the following to check the current mdadm RAID information, and note down the mdadm RAID name. In my case, it is called md127:

cat /proc/mdstat

Screenshot_2024-07-05_221343.png

Next, check the details of the RAID. Here, you can see that I have one of the RAID memebers unavailable. 

mdadm --detail /dev/<md RAID name>

mdadm --detail /dev/md127

Screenshot_2024-07-05_221838.png

If you have an unavailable RAID member, go ahead and replace the drive, and then check the drive number with lsblk. In my case, the repalced drive is nvme0n1.

lsblk

Screenshot_2024-07-05_221854.png

Once you have identify the drive, it is time to add it to the mdadm RAID.

mdadm --manage /dev/<md RAID name> -a /dev/<replacement drive name>

mdadm --manage /dev/md127 -a /dev/nvme0n1

Screenshot_2024-07-05_221839.pngmdadm --grow /dev/md127 --size=max

mdadm --grow /dev/<RAID Name> --size=max

mdadm --grow /dev/md127 --size=max

If you run mdadm --detail again, you will see that the RAID is rebuilding. 

Screenshot_2024-07-05_222018.png

If all members of the RAID set was replaced by a larger drive, you can grow and expand the RAID using the following: 

mdadm --grow /dev/<RAID Name> --size=max

mdadm --grow /dev/md127 --size=max

Screenshot_2024-07-06_200240.png