lvm
- Physical Volume(PV)
A physical volume
is any block device (a disk, a partition, a RAID device or even an iSCSI device). All these devices can become a member of a volume group.
- Volume Group(vg)
A volume group
is an abstraction layer between block devices and logical volumes.
- Logical Volume(lv)
A logical volume
is created in a volume group. Logical volumes that contain a file system can be mounted. The use of logical volumes is similar to the use of partitions and is accomplished with the same standard commands (mkfs, mount, fsck, df, …).
Note: lvm will work fine when using the complete device, but another operating system on the same computer (or on the same SAN) will not recognize lvm and will mark the block device as being empty! You can avoid this by creating a partition that spans the whole device, then run pvcreate on the partition instead of the disk.
Volumes that are mounted as vfat or ext2 cannot be extended, so in the example here we use the ext3 file system.
lvm mirror
lvm snapshot
A snapshot is a virtual copy of all the data at a point in time on a volume. A snapshot Logical Volume will retain a copy of all changed files of the snapshotted Logical Volume.
lvm command
pvcreate
Use the pvcreate command to add devices to lvm.
pvresize
When you used fdisk to resize a partition on a disk, then you must use pvresize to make lvm recognize the new size of the physical volume that represents this partition.
pvchange
With pvchange you can prevent the allocation of a Physical Volume in a new Volume Group or Logical Volume. This can be useful if you plan to remove a Physical Volume.
Also, to revert your previous decision, pvresize let you re-enable the Physical Volume to allow allocation.
pvremove
Use the pvremove command to remove physical volumes from lvm. The devices may not be in use.
pvmove
With pvmove you can move Logical Volumes from within a Volume Group to another Physical Volume
. This must be done before removing a Physical Volume.
pvs
The pvscan command will scan all disks for existing Physical Volumes.
pvdisplay
Use pvdisplay to get more information about physical volumes. You can also use pvdisplay without an argument to display information about all physical (lvm) volumes.
vgcreate
Use the vgcreate command to create a volume group.
vgextend
Use the vgextend command to extend an existing volume group with a physical volume.
vgremove
Use the vgremove command to remove volume groups from lvm. The volume groups may not be in use.
vgreduce
Use the vgreduce command to remove a Physical Volume from the Volume Group.
vgchange
Use the vgchange command to change parameters of a Volume Group.
vgmerge
Merging two Volume Groups into one is done with vgmerge.
vgs
vgs to display a quick overview of all volume groups.
vgscan
The vgscan command will scan all disks for existing Volume Groups. It will also update the /etc/lvm/.cache file. This file contains a list of all current lvm devices.
LVM will run the vgscan automatically at boot-up.
vgdisplay
The vgdisplay command will give you more detailed information about a volume group (or about all volume groups if you omit the argument).
lvmdiskscan
To get a list of block devices that can be used with LVM, use lvmdiskscan.
lvcreate
Use the lvcreate command to create Logical Volumes in a Volume Group.
lvremove
Use the lvremove command to remove Logical Volumes from a Volume Group. Removing a Logical Volume requires the name of the Volume Group.
lvextend
Extending the volume is easy with lvextend.
lvrename
Renaming a Logical Volume is done with lvrename.
lvs
The easiest way to verify whether devices are known to lvm is with the pvs command.
Use lvs for a quick look at all existing logical volumes.
lvscan
The lvscan command will scan all disks for existing Logical Volumes.
lvdisplay
More detailed information about logical volumes is available through the lvdisplay(1) command.