Installation guide

Shrinking Logical Volumes
47
[root@taft-03 ~]# lvs -a -o +devices
LV VG Attr LSize Log Copy% Devices
mirror taft Mwi-a- 200.00g mirror_mlog 50.16
mirror_mimage_0(0),mirror_mimage_1(0)
[mirror_mimage_0] taft Iwi-ao 200.00g /dev/sdb1(0)
[mirror_mimage_0] taft Iwi-ao 200.00g /dev/sdg1(0)
[mirror_mimage_1] taft Iwi-ao 200.00g /dev/sdc1(0)
[mirror_mimage_1] taft Iwi-ao 200.00g /dev/sdd1(0)
[mirror_mlog] taft lwi-ao 4.00m /dev/sdh1(0)
4.4.13. Shrinking Logical Volumes
To reduce the size of a logical volume, first unmount the file system. You can then use the lvreduce
command to shrink the volume. After shrinking the volume, remount the file system.
Warning
It is important to reduce the size of the file system or whatever is residing in the volume before
shrinking the volume itself, otherwise you risk losing data.
Shrinking a logical volume frees some of the volume group to be allocated to other logical volumes in
the volume group.
The following example reduces the size of logical volume lvol1 in volume group vg00 by 3 logical
extents.
# lvreduce -l -3 vg00/lvol1
4.5. Controlling LVM Device Scans with Filters
At startup, the vgscan command is run to scan the block devices on the system looking for LVM
labels, to determine which of them are physical volumes and to read the metadata and build up a
list of volume groups. The names of the physical volumes are stored in the cache file of each node
in the system, /etc/lvm/cache/.cache. Subsequent commands may read that file to avoiding
rescanning.
You can control which devices LVM scans by setting up filters in the lvm.conf configuration file. The
filters in the lvm.conf file consist of a series of simple regular expressions that get applied to the
device names that are in the /dev directory to decide whether to accept or reject each block device
found.
The following examples show the use of filters to control which devices LVM scans. Note that some of
these examples do not necessarily represent best practice, as the regular expressions are matched
freely against the complete pathname. For example, a/loop/ is equivalent to a/.*loop.*/ and
would match /dev/solooperation/lvol1.
The following filter adds all discovered devices, which is the default behavior as there is no filter
configured in the configuration file: