Problem: You have LVM logical volume configured to hold a lot of data but at some point you ran out of space – you want to expand the logical volume space by adding more disks to the system.
Prerequisites: It would be very wise to use XFS filesystem on the large logical volume from the very beginning – aside from performance improvement it has 2 very important advantages:
- Scheduled or recovery disk check is very fast, regardless of disk size (on disks bigger then 1Tb disk scan on boot takes considerable time – EXT3 takes hours to check)
- You can expand filesystem while it’s mounted and “live” (in fact you have to have it mounted to do so), and this operation is quick and does not put your existing data in the harm way (when you are extending 20Tb logical volume to 40Tb because it’s almost full loosing all this data is not an option).
Now, down to business. Assumed setup:
- Existing logical volume home on volume group vg00 with physical volume /dev/sda2, mounted under /home and formatted with XFS filesystem
- The new disk being added is /dev/sdb1
- Create new physical volume and verify
1234567891011121314151617181920212223pvcreate /dev/sdb1pvdisplay--- Physical volume ---PV Name /dev/sdb1VG Name vg00PV Size 1.82 TB / not usable 4.09 MBAllocatable yesPE Size (KByte) 4096Total PE 476156Free PE 476156Allocated PE 0PV UUID yz3NdE-VgQo-AMbq-76Kk-lY7d-PhUZ-kPrwhP--- Physical volume ---PV Name /dev/sda2VG Name vg00PV Size 1.77 TB / not usable 2.69 MBAllocatable yes (but full)PE Size (KByte) 4096Total PE 463131Free PE 0Allocated PE 463131PV UUID 9vpgT4-nvz4-DtfM-kXn7-TXmO-3bBd-fnomtC - Add new physical volume to the existing volume group and verify
12345678910111213141516171819202122vgextend vg00 /dev/sdb1vgdisplay--- Volume group ---VG Name vg00System IDFormat lvm2Metadata Areas 2Metadata Sequence No 4VG Access read/writeVG Status resizableMAX LV 0Cur LV 1Open LV 1Max PV 0Cur PV 2Act PV 2VG Size 3.58 TBPE Size 4.00 MBTotal PE 939287Alloc PE / Size 469643 / 1.79 TBFree PE / Size 469643 / 1.79VG UUID Ve9RLp-aEQM-ji1X-WCMh-9tP9-ZMOx-OVxYcQ - Expand logical volume and verify
12345678910111213141516lvextend -l +100%FREE /dev/vg00/homelvdisplay--- Logical volume ---LV Name /dev/vg00/homeVG Name vg00LV UUID Ysewsi-Ekdm-ug3M-Dcmd-sJGO-owxC-qNsdBuLV Write Access read/writeLV Status available# open 1LV Size 3.58 TBCurrent LE 939287Segments 2Allocation inheritRead ahead sectors auto- currently set to 256Block device 253:0 - Increase the filesystem size to the full size of the logical volume
123456789xfs_growfs /homemeta-data=/dev/vg00/home isize=256 agcount=64, agsize=15236992 blks= sectsz=512 attr=0data = bsize=4096 blocks=961829888, imaxpct=25= sunit=0 swidth=0 blks, unwritten=1naming =version 2 bsize=4096log =internal bsize=4096 blocks=32768, version=1= sectsz=512 sunit=0 blks, lazy-count=0realtime =none extsz=4096 blocks=0, rtextents=0
You are done – enjoy your bigger logical disk.
0 Comments.