Stuck Growing mdadm Array: RAID6, LVM, and ext4
In this article, we will discuss the process of growing an existing RAID6 array using mdadm, LVM, and ext4. This guide will help you overcome common issues and provide you with detailed instructions to achieve the desired result.
Background
RAID (Redundant Array of Independent Disks) is a method of storing the same data in different places on multiple hard disks or solid-state drives to protect data in the case of a drive failure. There are several RAID levels, each with its own balance of performance, data protection, and storage capacity.
In this scenario, we will focus on RAID6, which provides a good balance between data protection and storage capacity. It uses block-level striping with double distributed parity to protect against the failure of two drives.
Prerequisites
- A RAID6 array with at least two drives
- Access to the system with root or sudo privileges
- Spare drives to grow the array
Scenario
The user has decided to grow a RAID6 array with 7x2TB drives (giving an usable space of ~9TB ext4/raid6) and 7x4TB drives (giving an usable space of ~18TB ext4/raid6) to increase the storage capacity.
Process
Step 1: Identify the current RAID6 array
Use the following command to display the current RAID arrays:
sudo mdadm --detail /dev/md0
Step 2: Add spare drives to the RAID6 array
Connect the spare drives to the system and use the following command to add them to the RAID6 array:
sudo mdadm --add /dev/md0 /dev/sd[x]
Replace /dev/sd[x] with the device path of the spare drive.
Step 3: Monitor the RAID6 array rebuild process
Use the following command to monitor the progress of the RAID6 array rebuild:
watch cat /proc/mdstat
Step 4: Grow the RAID6 array
Once the spare drives have been added and the RAID6 array has been rebuilt, use the following command to grow the array:
sudo mdadm --grow /dev/md0 --size=max
Step 5: Create a new LVM physical volume
Use the following command to create a new LVM physical volume on the expanded RAID6 array:
sudo pvcreate /dev/md0
Step 6: Extend the LVM volume group
Use the following command to extend the LVM volume group to include the new physical volume:
sudo vgextend vg0 /dev/md0
Step 7: Extend the LVM logical volume
Use the following command to extend the LVM logical volume to use the available space:
sudo lvextend -l +100%FREE /dev/vg0/lv0
Step 8: Resize the ext4 filesystem
Finally, use the following command to resize the ext4 filesystem to use the available space:
sudo resize2fs /dev/vg0/lv0
In this article, we discussed the process of growing an existing RAID6 array using mdadm, LVM, and ext4. We covered the key concepts and provided detailed instructions to achieve the desired result. The steps included identifying the current RAID6 array, adding spare drives, monitoring the rebuild process, growing the RAID6 array, creating a new LVM physical volume, extending the LVM volume group, extending the LVM logical volume, and resizing the ext4 filesystem.