Procedure for using LVM to extend an existing file system.
You
must be user root to perform these steps.
Part I - Checking for Free Space
# /usr/sbin/vgdisplay /dev/vgxxwhere xx is the appropriate number for your volume group. Use
bdf to see a list of all your volume groups
and logical volumes.
If you do not have any free PE's, you will need to create some. You can create free PE's by reducing the number of PE's in an existing logical volume, or by removing a logical volume entirely.
# /etc/umount /dev/vgxx/lvolxwhere xx and x are the appropriate number for your volume group and logical volume.
/tmp directory, you can't unmount the
/tmp logical volume. Change directories to
another directory outside the logical volume.
Additionally, you can use the
fuser command to get a list of process IDs
currently using a specified logical volume:
fuser /dev/vgxx/lvolxThis will return either a blank line, or a list of numbers followed by lower case letters. These numbers are process IDs. Use
/bin/ps -elf | grep pid to find what these
processes are and kill them. Once you've killed the processes
accessing the logical
volume, run the /etc/umount command again.
/etc/umount command will always fail. For
example, the /usr volume can't be unmounted.
In these cases, you will have to boot your system into single
user mode. In single user mode, these volumes will automatically
be unmounted for you. To get to single user mode, run the command
# shutdown
# /usr/sbin/lvremove /dev/vgxx/lvolxYou will be prompted to approve this action.
Note: If you are removing the /usr logical
volume, you must use /sbin/lvremove rather than
/usr/sbin/lvremove, because you just unmounted
the /usr directory.
/usr/sbin/vgdisplay /dev/vgxx
to verify that new free PE's exist. Once you've verified that enough
free PE's exist, skip down to Part IV.
Part III - Reducing the Size of an Existing Logical Volume
/tmp logical volume,
you must back up the /tmp directory tree.
You can make a tape back up of the files, or you can create a tar file
on another disk drive. Either way, make sure your back up is successful
because the process below will destroy all the files on the logical volume.
# /usr/sbin/lvreduce -l 50 /dev/vg00/lvol3Note: If you are reducing the
/usr logical
volume, you must use /sbin/lvreduce rather than
/usr/sbin/lvreduce, because you just unmounted
the /usr directory.
Also note that the number specified on the command line is the final
size of the logical volume, not the amount you want to reduce
it by.
# /usr/sbin/newfs -F hfs /dev/vgxx/rlvolxNote: If you are reducing the
/usr file
system, you must use /sbin/newfs rather than
/usr/sbin/newfs, because you just unmounted
the /usr directory.
# /etc/mount /dev/vgxx/lvolxand restore the files from your back up tape or tar file. This will complete the reduction process and free up some physical extents in the volume group.
/usr/sbin/vgdisplay /dev/vgxx to verify that new free
PE's exist. Once you've verified that enough free PE's exist, continue
with Part IV.
Part IV - Extending the Logical Volume and File System
# /usr/sbin/lvdisplay /dev/vgxx/lvolx
/usr/sbin/lvchange -C n /dev/vgxx/lvolxIf the logical volume is labeled strict, skip this step.
# /usr/sbin/lvextend -l 35 /dev/vgxx/lvolxNote: If you are extending the
/usr logical
volume, you must use /sbin/lvextend rather than
/usr/sbin/lvextend, because you just unmounted
the /usr directory.
Also note that the number specified on the command line is the final
size of the logical volume, not the amount you want to increase
it by.
# /usr/sbin/extendfs -F hfs /dev/vgxx/rlvolxNote: If you are extending the
/usr file
system, you must use /sbin/extendfs rather than
/usr/sbin/extendfs, because you just unmounted
the /usr directory.
# /etc/mount /dev/vgxx/lvolx /mount_pointwhere mount_point is the directory on which the logical volume is mounted. Or, you can simply reboot the system. Use the
bdf command to verify that your changes
have taken affect.