Page 1
1
© David Morgan 2005-17
Logical Volume Manager (LVM)Logical Volume Manager (LVM)
David Morgan
© David Morgan 2005-17
““File systemFile system”” hierarchyhierarchy� A tree structure of directories
� The directory tree is standardized
portions can spread
across
different partitions
Page 2
2
© David Morgan 2005-17
/
home bin bootusr varlib etcdev
bin manlib spoollib runlogtom harrydick
Standard file system hierarchyStandard file system hierarchy
© David Morgan 2005-17
/
tom harrydick
In some piecesIn some pieces
/
spoollib runlog
/
bin manlib
/
home bin bootusr varlib etcdev
Page 3
3
© David Morgan 2005-17
Disks and partitionsDisks and partitions
© David Morgan 2005-17
/
tom harrydick
House the piecesHouse the pieces
/
spoollib runlog
/
bin manlib
/
home bin bootusr varlib etcdev
Page 4
4
© David Morgan 2005-17
/
tom harrydick
Or maybeOr maybe
/
spoollib runlog
/
bin manlib
/
home bin bootusr varlib etcdev
© David Morgan 2005-17
ProblemProblem
� Container (partition) size is rigid
� One partition can fill while another has extra space
� Subtree in filled partition can’t grow into extra space
Page 5
5
© David Morgan 2005-17
/
tom harrydick
RehouseRehouse the piecesthe pieces
/
spoollib runlog
/
bin manlib
/
home bin bootusr varlib etcdev
“Logical
Volumes”
LV for /
LV for /home
LV for /usr
LV for /var
...functional equivalent of partitions
© David Morgan 2005-17
Reorganize the Reorganize the
housing stockhousing stock
---- into volume groupsinto volume groups
physical
volumes,
grouped:
a.k.a, volume groups
Page 6
6
© David Morgan 2005-17
/
tom harrydick
Distribute theDistribute the
stockstock
/
spoollib runlog
/
bin manlib
/
home bin bootusr varlib etcdev
“Logical
volumes:”
“Volume
groups:”
© David Morgan 2005-17
/
tom harrydick
Later, if /Later, if /usrusr gets gets
““fullfull”” –– out of space/gasout of space/gas
/
spoollib runlog
/
bin manlib
/
home bin bootusr varlib etcdev
“Logical
volumes:”
“Volume
groups:”
Page 7
7
© David Morgan 2005-17
/
tom harrydick
Gas in the tankGas in the tank
/
spoollib runlog
/
bin manlib
/
home bin bootusr varlib etcdev
“Logical
volumes:”
“Volume
groups:”
© David Morgan 2005-17
“Logical
volumes:”
“Volume
groups:”
partitions:
disks:
sdb
sda
sdcsdc1
sdb1
sda1
sda2
VGsVGs are like disks, virtuallyare like disks, virtually
LVsLVs are like are like partitonspartitons, virtually, virtually
Page 8
8
© David Morgan 2005-17
An LVM Fedora installationAn LVM Fedora installation
� post-Fedora LVM installation (LVs were auto-created)� disk size is 20GB� partitions occupy 10GB� one is LVM type – what’s inside?
10 GB consumed
© David Morgan 2005-17
2 logical 2 logical volsvols in 1 volume groupin 1 volume group
Symbolic links to them, categorized into
folders by containing volume groups
Global set of logical volumes, as
block devices
Page 9
9
© David Morgan 2005-17
LVMLVM’’ss hierarchy of hierarchy of ““piecespieces””
� Physical volumes
� Volume groups
� Logical volumes
© David Morgan 2005-17
General procedureGeneral procedure
� Acquire more storage units
– install new disks or
– create new partitions
� Turn them into LVM-recognized PVs
� Group them to form new VGs
� Create LVs in the new VGs
� Mount and use the LVs
Page 10
10
© David Morgan 2005-17
Our specific planOur specific plan
� Create 3 new data partitions
� Turn them into PVs
� Put them all in one new VG
� Create an LV 70% the size of the VG
� Favorite beverage
© David Morgan 2005-17
Make more physical volumesMake more physical volumes
� Create partitions from empty space with fdisk
� Set partition type code to 8e with fdisk
� “brand” them with pvcreate command
Page 11
11
© David Morgan 2005-17
Make 3 new data partitionsMake 3 new data partitionsMade another primary partition and a couple logical partitions, with fdisk
Aggregate size is 10GB = 2 + 4 + 4
© David Morgan 2005-17
Set partition type code to 8eSet partition type code to 8e
Tagged them with LVM’s type code 8e, with fdisk
Page 12
12
© David Morgan 2005-17
Brand them with Brand them with pvcreatepvcreate
© David Morgan 2005-17
Group them to form a new VGGroup them to form a new VG
New VG name is “NewVolGrp” size is 10GB
Page 13
13
© David Morgan 2005-17
Make LV, 70% of VGMake LV, 70% of VG
New LV name is “NewLogVol” size is 7GB
© David Morgan 2005-17
3 logical 3 logical volsvols in 2 volume groupsin 2 volume groups
Global set of logical volumes
categorized by their volume groups
Page 14
14
© David Morgan 2005-17
LV is a partitionLV is a partition--equivalentequivalent
Can format (note containing VG’s
constituent partitions are never formatted).
Then can mount.
Characteristic of fresh-formatted partitions
© David Morgan 2005-17
Diagnostic commands for viewingDiagnostic commands for viewing-- physical volumesphysical volumes
-- volume groupsvolume groups
-- logical volumeslogical volumes
� summary output
– pvs
– vgs
– lvs
� more verbose output
– pvdisplay
– vgdisplay
– lvdisplay
Page 15
15
© David Morgan 2005-17
vgdisplayvgdisplay : volume group info: volume group info
© David Morgan 2005-17
lvdisplaylvdisplay: logical volume info: logical volume info
Page 16
16
© David Morgan 2005-17
Practicing on USB storagePracticing on USB storage
� identify the correct name of the device– these activities are data-destructive
– be sure not to mistakenly give the name of your hard disk when manipulating your usb disk
� tools for identifying usb device name after inserting– dmesg
– fdisk -l