User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
mdadmxfs [2023/11/06 10:07] – created normanmdadmxfs [2025/10/31 13:56] (current) – [Creating the initial 3 drive array] norman
Line 5: Line 5:
 ===== Creating the initial 3 drive array ===== ===== Creating the initial 3 drive array =====
  
-First, create empty partitions to all drives: +Created a RAID5 array:
- +
-<code>fdisk /dev/sdX +
-n # Create a new partition +
-p # Primary +
-1 # First partition +
-[enter] # Starting point to first sector (default) +
-[enter] # Ending point to last sector (default) +
-t # Change partition type +
-fd # Type: Linux raid autodetect +
-w # Write changes to disc</code> +
- +
-When empty RAID partitions have been created to all three discs, I created a RAID5 array:+
  
 <code>mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1</code> <code>mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1</code>
Line 55: Line 43:
  
 Now the RAID array is ready to use, and mounted automatically to /raid directory after every boot. Now the RAID array is ready to use, and mounted automatically to /raid directory after every boot.
 +
 +====== Debian need: ======
 +
 +<code>
 +update-initramfs -u
 +</code>
 +
 +===== Adding a new drive to the array =====
 +
 +Let's imagine that now you have a new drive, /dev/sde, which you want to add to the previously created array without losing any data.
 +
 +Add to the RAID array:
 +
 +<code>mdadm --add /dev/md0 /dev/sde1</code>
 +
 +Now the RAID5 array includes four drives, which only three are in use currently. The array needs to be expanded to include all four drives:
 +
 +<code>mdadm --grow /dev/md0 --raid-devices=4</code>
 +
 +Then the physical LVM2 volume needs to be expanded:
 +
 +<code>pvresize /dev/md0</code>
 +
 +Now the physical volume is resized by default to cover all available space in the RAID array. We need to find out the new size in physical extents:
 +
 +<code>vgdisplay vd_raid</code>
 +
 +Let's imagine that the new size is now 764 (can be seen from "Total PE"). Now expand the logical volume to cover this:
 +
 +<code>lvextend /dev/mapper/vd_raid-lv_raid -l 764</code>
 +
 +Then expand the XFS file system. This needs to be done during the file system is online and mounted:
 +
 +<code>xfs_growfs /mnt/raid</code>
 +
 +By default it is expanded to cover all available space. Finally the RAID array geometry needs to be updated because the array now includes a new disk. First delete the added line from /etc/mdadm/mdadm.conf and then add a new one:
 +
 +<code>mdadm --detail --scan >> /etc/mdadm/mdadm.conf</code>