After an installation you might find some file systems are too large, they are almost empty. When you want to use that space for another file system, here are the steps you can take:
Imagine /opt is now 10 Gb, but 1 Gb would be sufficient.
lsof /optyou will get a list of processes that currently use /opt. Stop these processes.
df -h /optor
mount. In my example, I found /dev/mapper/VolGroup/opt hold files on /opt.
resize2fs /dev/mapper/VolGroup/opt 1G. This frees the "right" part of the disk that LVM will un-allocate in a moment. All data from the file system is on the "left hand side".
lvreduce -L 1G /dev/mapper/VolGroup-optto shrink the logical volume. (It might warn you that you need to run
e2fsck -f /dev/mapper/VolGroup-optbefore you can continue.
For /opt or any other filesystem that can easily be freed from open file handles, the above procedure works fine, but for "busy" filesystems, like /, /var, /usr, and so on, you'd have boot the machine without mounting filesystems. One way to do this is using the installation CD and starting up the "rescue" environment.