Learn how to extend file system or logical volume in LVM under HPUX and Linux without any downtime. Grow your mount point capacity without impacting users.
“Extend file system” is of the common task every Linux Unix sysadmin face in his life. Insufficient capacity planning during deploying systems, un-foreseen grown data, improper data rotation techniques can lead to mount points reaching their capacity limits. Quick solution is to grown those mount point’s total size to get some breathing space till you finalize on final solution about data management.
Extending file system is actually extending related logical volume and then growing FS over it. There are few pre-requisite you should consider befor attempting for file system extension.
- You have free PE available in respective Volume group. (check using vgdisplay)
- If not, you must have free disk/LUN which can be added to that VG
- In case of old HPUX versions, online JFS must be installed (check using swlist)
How to do it :
Lets start with case :We have /data (/dev/vg01/lvol01) mount point of 1024MB in vg01 volume group which needs to be extended by 500MB.
Now, as per pre-requisite we should have free PE available in vg01. You can verify it by checking “free PE” field in vgdisplay output. If its a non-zero number then you have some PE avaibale to use. You need to calculate how much free space exist in VG. For that check “PE size” in vgdisplay output, multiply it with number of PEs, resulting number is MBs you have free in VG. You can extend you file system by these many MB size.
Suppose, you dont have free PE in vg01 then you need to add a new disk or LUN to system. Once detected, you need to add it vg01 using vgextend command. Once your vg01 is extended with new disk/LUN, you will see free PE in vgdisplay output.
Now you verified and confirmed, you have 500MB free in VG. Proceed to extend logical volume of /data mount point i.e. /dev/vg01/lvol01 using lvextend command.
# lvextend -L 1524 /dev/vg01/lvol1
Logical volume "/dev/vg01/lvol1" has been successfully extended.
Volume Group configuration for /dev/vg01 has been saved in /etc/lvmconf/vg01.conf
Existing 1024+500Mb hence 1524 in command.
Now your logical volume is extended to desired size. Still you wont be able to see this space growth in mount point size. You need to extend file system as well for that.
In HPUX, you can use fsadm command (size to be specified in KB) like below :
# fsadm -b 1560576 /data
In RHEL6 you can use resize2fs command like :
# resize2fs /dev/vg01/lvol01
Here, it will grow with maximum size of lvol hence size is not specified.
In RHEL7 you can use :
# xfs_growfs /data -D size
where size is in system block (depends on your config). If you donst specify size (-D) then it grows to maximum available size of lvol. So in our case we dont need to specify size.
Final check :
You are done! Check mount point new size in bdf (HPUX) or df -h (Linux) output. Note that we havnt stopped access of apps/users to the mount point in question. This means, entire operation was done online without any downtime or impacting users.