Expanding Storage
Existing System
Number of Hard drives: 3
Partitions per drive: 2
Size of each partition: 250023 bytes
- Shutdown box
sudo halt -p - Install new SATA drive.
- Turn on the power.
- Partition the drive (of the size above) using type: FD
- Maximize the RAID’s minimum build speed:
echo '150000' > /proc/sys/dev/raid/speed_limit_min - Unmount the filesystem underwhich the Volume Group exists
sudo umount /share - Add the partition(s) to each RAID5 array
sudo mdadm --add /dev/md0 /dev/sde1
sudo mdadm --add /dev/md1 /dev/sde2 - Grow the array
sudo mdadm --grow /dev/md0 --raid-disks=4
sudo mdadm --grow /dev/md1 --raid-disks=4 - WAIT TILL THE REBUILDING IS DONE!
Note: One array will be rebuilding while the other is queued until the first one finishes. If for any reason you had to stop the array from rebuilding, you can start it again using:
mdadm -A --force /dev/md0 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm -A --force /dev/md1 /dev/sdb2 /dev/sdc2 /dev/sdd2 /dev/sde2The above is because the config file of mdadm was not updated (yet) and still counts the new partitions as spares. After issuing the commands above, wait untill the array is finished rebuilding.
- Update the mdadm config file:
sudo su
mdadm --misc --detail --brief /dev/md0 > /etc/mdadm/mdadm.conf
mdadm --misc --detail --brief /dev/md1 >> /etc/mdadm/mdadm.conf - Grow the Physical Volume (PV)
sudo pvresize /dev/md0Physical volume "/dev/md0" changed
1 physical volume(s) resized / 0 physical volume(s) not resizedsudo pvdisplay /dev/md0
--- Physical volume ---
PV Name /dev/md0
VG Name arrays
PV Size 698.56 GB / not usable 570.81 MB
Allocatable yes
PE Size (KByte) 1048576
Total PE 698
Free PE 233
Allocated PE 465
PV UUID XpucQy-CP8u-gr5B-trw1-alB3-j25u-RBWs1yNotice the Free PE. The same can be done to md1 or more arrays
- Extend the Logical Volume (LV)
sudo lvextend -l +100%FREE /dev/arrays/zastorajeExtending logical volume zastoraje to 1.36 TB
Logical volume zastoraje successfully resized - Check the Volume Group
sudo vgdisplay--- Volume group ---
VG Name arrays
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 1.36 TB
PE Size 1.00 GB
Total PE 1396
Alloc PE / Size 1396 / 1.36 TB
Free PE / Size 0 / 0
VG UUID 5czGLh-DvVO-nDBa-QTCy-x5zR-QUti-Lz0103 - Remount directory
sudo mount /share - Grow the filesystem
sudo xfs_growfs /sharemeta-data=/dev/mapper/arrays-zastoraje isize=256 agcount=32, agsize=7618560 blks
= sectsz=512 attr=0
data = bsize=4096 blocks=243793920, imaxpct=25
= sunit=0 swidth=0 blks, unwritten=1
naming =version 2 bsize=4096
log =internal bsize=4096 blocks=16384, version=1
= sectsz=512 sunit=0 blks, lazy-count=0
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 243793920 to 365953024 - Check the free space
-
Done!
Updated System
Number of Hard drives: 4
Partitions per drive: 2
Size of each partition: 250023 bytes
or use “–scan” to include all arrays
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 71G 948M 67G 2% /
varrun 502M 188K 502M 1% /var/run
varlock 502M 0 502M 0% /var/lock
udev 502M 112K 502M 1% /dev
devshm 502M 0 502M 0% /dev/shm
/dev/mapper/arrays-zastoraje
1.4T 730G 667G 53% /share