Logical Volume Manager Flashcards
What is a physical volume?
Underlying physical storage unit used by LVM
Can use partition or entire block device
*partition type must be initialised/marked as Linux LVM to provide metadata to LVM
What is the structure for LVM?
── Logical Volume
└── Volume Group
├─── Physical Volume 1
└─── Physical Volume 2
What is an extent in a Volume Group?
Smallest amount of space that can be assigned to a volume group, also knows as physical extents. They are mapped to logical volumes
How do you create a Physical Volume?
pvcreate {/block/device}
How do you view Physical Volumes on the system?
pvdisplay
How do you create a Volume Group?
vgcreate {vgname} {/physical/volume}
How do you view Volume Groups on the system?
vgdisplay
How do you create a Logical Volume?
lvcreate -n {name} -L {size} {vgname}
How do you view Logical Volumes?
lvdisplay
On a Logical Volume what are the limitations of xfs vs ext4?
LVM using xfs can only be increased
LVM using ext4 can be increased and decreased
How do you delete a Physical Volume?
pvremove
How do you delete a Volume Group?
vgremove
How do you delete a Logical Volume?
lvremove
How do you format an LVM to be used as swap space?
mkswap {/lv/path}
i. e mkswap /dev/vg1/lvswap1
* formats with swap signature
How do you mount a swap disk?
swapon
i.e swapon /dev/vg1/lvswap1
How do you unmount a swap disk?
swapoff
i.e swapoff /dev/vg1/lvswap1
How do you persistently mount swap a disk?
Edit /etc/fstab
UUID, /block/device
specify path and filetype of: swap
How do you mount all swap disk entries listed in /etc/fstab?
swapon -a
How do you format a partition/volume for swap?
mkswap {/block/device}
Partition must have an id type of Linux swap
How do you get a summary about used swap devices?
swapon -s
*also located in /proc/swaps
How do you add another block device to a volume group?
vgextend {vgname} {/physical/volume}
If there are multiple block devices in a volume group, how do you move the data from one physical volume to others within the group so that it can be removed?
pvmove {/block/device}
Physical extents on the device will be copied to other physical volumes
*useful if changing partition format MBR vs GPT
How do you remove a physical volume from a volume group?
vgreduce {vgname} {/physical/volume}
How do you extend a logical volume?
lvextend {lvname} -L {size}
Once a logical volume is extended how do you increase the filesystem size?
xfs: xfs_growfs {/mount/point}
ext4: resize2fs {/mount/point}
* lv must be mounted to see filesystem