This document provides an overview of Logical Volume Management (LVM) including its core components and functionality. LVM allows for flexible, online storage management through the creation of logical volumes atop physical volumes. It supports resizing storage pools, online data relocation, disk striping, mirroring volumes, and volume snapshots. The key components are physical volumes (PVs), volume groups (VGs), and logical volumes (LVs). PVs can be partitions or entire disks. VGs pool multiple PVs into a single storage space with extents. LVs are then created within VGs with properties like linear, striped, or mirrored layouts. Device mapper provides access to LVs and handles tasks like mirroring and
2. Common problems
● Resize partition?
● Use space on separated disks?
● Use speed of multiple devices?
● Write same data on more devices?
● Backup used filesystem?
2/29
12. Snapshot
● stores only differences
● origin and snapshot, both are RW
● snapshot != backup
● 100% full is lost completely
● Use
● backup
● fsck
● test/rollback on production data “--merge”
● virtual machines
lvcreate --size 100M --snapshot --name lv_snap /dev/vg0/lv0
12/29
18. $ cd ~/tmp
$ for i in {0..6}; do dd if=/dev/zero of=lvm$i.img bs=1 count=0 /
seek=505M; done
$ ls -lh lvm*
-rw-rw-r-- 1 michal michal 505M 2011-10-20 22:36 lvm0.img
-rw-rw-r-- 1 michal michal 505M 2011-10-20 22:36 lvm1.img
-rw-rw-r-- 1 michal michal 505M 2011-10-20 22:36 lvm2.img
-rw-rw-r-- 1 michal michal 505M 2011-10-20 22:36 lvm3.img
-rw-rw-r-- 1 michal michal 505M 2011-10-20 22:36 lvm4.img
-rw-rw-r-- 1 michal michal 505M 2011-10-20 22:36 lvm5.img
-rw-rw-r-- 1 michal michal 505M 2011-10-20 22:36 lvm6.img
$ for i in {0..6}; do sudo losetup /dev/loop$i lvm$i.img; done
$ sudo losetup -a
/dev/loop0: [0802]:1966260 (/home/michal/tmp/lvm0.img)
/dev/loop1: [0802]:1966347 (/home/michal/tmp/lvm1.img)
/dev/loop2: [0802]:1966350 (/home/michal/tmp/lvm2.img)
/dev/loop3: [0802]:1966351 (/home/michal/tmp/lvm3.img)
/dev/loop4: [0802]:1966354 (/home/michal/tmp/lvm4.img)
/dev/loop5: [0802]:1966355 (/home/michal/tmp/lvm5.img)
/dev/loop6: [0802]:1966356 (/home/michal/tmp/lvm6.img)
18/29
20. $ sudo vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 7
Metadata Sequence No 22
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 7
Act PV 7
VG Size 3,39 GiB
PE Size 4,00 MiB
Total PE 868
Alloc PE / Size 0 / 0
Free PE / Size 868 / 3,39 GiB
VG UUID ggZ5Nq-MTOZ-x43a-kuLZ-xxn0-3JdQ-GNta6g
$ sudo lvcreate -i2 -m1 -L1200m -n lv0 vg0
Using default stripesize 64,00 KiB
Logical volume "lv0" created
20/29
28. Caveats
● Until Linux kernel 2.6.31[1], write barriers were
not supported (fully supported in 2.6.33). This
means that the guarantee against filesystem
corruption offered by journaled file systems like
ext3 and XFS was negated under some
circumstances.[2]
● Device mapper does not honor barriers
● Barriers are disabled by default
● mount -t ext3 -o barrier=1 <device> <mount
point>
28/29