I am keen to know more about the proper way to extend /opt after additional hard disk 5GB with lvm and xfs filesystem. Kindly advised. Many thanks.
1 Answer
Summary
- grow logical volume (if you have space)
- grow filesystem
Details:
I can't grow an /opt FS, I will use /opt2
my initial size is 5G
linux# df -h /opt2
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vgdata-opt2 5.0G 33M 5.0G 1% /opt2
I check for space in vgdata
linux# vgs
VG #PV #LV #SN Attr VSize VFree
vg00 1 9 0 wz--n- <44.51g <10.02g
vgdata 1 2 0 wz--n- <16.00g <8.00g
fine, I have 8G available in vgdata. I use lvresize command to grow logical volume /dev/mapper/vgdata-opt2
linux# lvresize --size=+5G /dev/mapper/vgdata-opt2
Size of logical volume vgdata/opt2 changed from 5.00 GiB (1280 extents) to 10.00 GiB (2560 extents).
Logical volume vgdata/opt2 successfully resized.
however, space is not allocated in FS
linux# df -h /opt2
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vgdata-opt2 5.0G 33M 5.0G 1% /opt2
I expand filesystem, for xfs filesystem, comamnd is xfs_growfs /mountpoint , resizing can be done with FS mounted.
linux# xfs_growfs /opt2
meta-data=/dev/mapper/vgdata-opt2 isize=512 agcount=4, agsize=327680 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 1310720 to 2621440
let's check space.
linux# df -h /opt2
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vgdata-opt2 10G 33M 10G 1% /opt2
linux#
-
If your distribution includes the
fsadmtool and a modern enough version of the LVM tools, you can havelvresizehandle the filesystem extension automatically:lvresize --resizefs --size=+5G /dev/mapper/vgdata-opt2and then it will runxfs_growfsautomatically for you.telcoM– telcoM2022-05-24 09:01:43 +00:00Commented May 24, 2022 at 9:01