Expanding HPUX 11 Logical volumes
1. The logical volumes in use are displayed as “devices” in a “df” . For example the “/home” file system resides on /dev/vg00/lvol5 in the example below.
# df /home (/dev/vg00/lvol5): 175888 blocks 2739 i-nodes /opt (/dev/vg00/lvol6): 3800048 blocks 59810 i-nodes /tmp (/dev/vg00/lvol4): 399728 blocks 6275 i-nodes /usr (/dev/vg00/lvol7): 1510784 blocks 23761 i-nodes /var (/dev/vg00/lvol8): 2857552 blocks 44928 i-nodes /stand (/dev/vg00/lvol1): 437088 blocks 32702 i-nodes / (/dev/vg00/lvol3): 232128 blocks 3647 i-nodes
2. Assume we decide to expand the “/home” filesystem. Firstly we confirm the amount of space the has been allocated to the logical volume with the “lvdisplay” command as shown below. In this example the volume is 1024MB (Also note the volume is made up of 128 Logical Extents (LE) {128 x 8MB = 1024MB} )
# lvdisplay /dev/vg00/lvol5 --- Logical volumes --- LV Name /dev/vg00/lvol5 VG Name /dev/vg00 LV Permission read/write LV Status available/syncd Mirror copies 0 Consistency Recovery MWC Schedule parallel LV Size (Mbytes) 1024 Current LE 128 Allocated PE 128 Stripes 0 Stripe Size (Kbytes) 0 Bad block on Allocation strict IO Timeout (Seconds) default
3. Before we can extend the volume we need to determine the amount of “spare” space available within the volume group (vg00) available for expansion. To do this we use the “vgdisplay” command as shown below.
# vgdisplay --- Volume groups --- VG Name /dev/vg00 VG Write Access read/write VG Status available Max LV 255 Cur LV 8 Open LV 8 Max PV 16 Cur PV 1 Act PV 1 Max PE per PV 4350 VGDA 2 PE Size (Mbytes) 8 Total PE 4340 Alloc PE 1458 Free PE 2882 Total PVG 0 Total Spare PVs 0 Total Spare PVs in use 0
In this case there are 2882 physical extents (at 8MB each) available. This equates to approximately 23GB. If we wish to expand the lvol5 volume by 5GB there is ample space available
4. To expand the volume we use the “lvextend” command as shown below. Note that the size is the total size of the resized volume not the amount we wish to expand it by.
# lvextend -L 6114 /dev/vg00/lvol5 Warning: rounding up logical volume size to extent boundary at size "6120" MB. Logical volume "/dev/vg00/lvol5" has been successfully extended. Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf
5. Although we have extended the logical volume the file system that was originally created in the volume is unaware of the increase of available space. In order to make use of the new space in the volume we must also expand the filesystem. To expand a filesystem it must be un-mounted. Difficulties may be encountered if users are utilising a file system. Users must vacate a file system before it can be un-mounted. The fuser tool can show which processes are using a file system.
# fuser -cu /export/home/hg1output /export/home/hg1output: 16509c(root)
Finally when the volume can be un-mounted we can extend it with the “extendfs” command. By default extendfs will expand the file system to fill the volume it is allocated in. Once this is done the file systems can be re-mounted as shown below.
#umount /dev/vg00/lvol5 #extendfs /dev/vg00/lvol5 #mount -a Permission denied mount: /dev/vg00/lvol8 is already mounted on /var mount: /dev/vg00/lvol7 is already mounted on /usr mount: /dev/vg00/lvol6 is already mounted on /opt mount: /dev/vg00/lvol4 is already mounted on /tmp mount: /dev/vg00/lvol1 is already mounted on /stand
