204.3. Logical Volume Manager

204.3 Logical Volume Manager

Weight: 3
Description: Candidates should be able to create and remove logical volumes, volume groups, and physical volumes. This objective includes snapshots and resizing logical volumes.
Key Knowledge Areas:
    Tools in the LVM suite
    Resizing, renaming, creating, and removing logical volumes, volume groups, and physical volumes
    Creating and maintaining snapshots
    Activating volume groups
Terms and Utilities:
    /sbin/pv*
    /sbin/lv*
    /sbin/vg*
    mount
    /dev/mapper/
    lvm.conf

LVM

In traditional storage management, Operating system searchs for Disk Drives like /dev/sda, /dev/sdb and then looks for what partitions are available on the disks like /dev/sda1, /dev/sdb1 .Partitions are limited to the disks and they are not so flexible. Logical Volume Manager (LVM) bring us flexibility by creating an abstraction layer between Operating System and Disk Devices.
LVM functions by layering abstractions on top of physical storage devices, The basic layers that LVM use are:
    physical volumes(pv):A physical volume is typically a hard disk, though it may be a device that looks like a hard disk (ex:software raid device).It can be a partition or entire of a disk.
    volume groups(vg): The Volume Group is central level and heart of the LVM. It gathers together a collection of Physical Volumes and create a pool of different storage resources.
    logical volumes(lv):The equivalent of a disk partition in a non-LVM system. logical volume takes disk space from disk space which is available on volume group. On top of logical volumes we create File Systems( xfs, ext4, ...)
LVM is capable of doing operations such as increasing, decreasing the size of a logical volume(which we will be discussing later) because the physical volume is made up of small chunks which are always of fixed size. Each physical disk that combinely makes up a volume group will have a number of small chunks of equal size, where data will reside.
This small chunks of equal size, which makes up the physical volumes are called as Physical Extents. Creating a volume group simply combines all the physical extents of all the physical volumes to form one large logical volume group.
Redhat base Systems use LVM by default, they setup LVM during installation, so here we use ubuntu to create lvm :
1
[email protected]:~# apt-get install lvm2
Copied!

Working with physical volumes(pv)

Here we use sdb, sdc to create pv. In order to prepare a partition to be a physical volume in LVM, it is recommended to format it with LVM tag:
1
[email protected]:~# ls -l /dev/sd*
2
brw-rw---- 1 root disk 8, 0 Jan 13 21:55 /dev/sda
3
brw-rw---- 1 root disk 8, 1 Jan 13 21:55 /dev/sda1
4
brw-rw---- 1 root disk 8, 2 Jan 13 21:55 /dev/sda2
5
brw-rw---- 1 root disk 8, 5 Jan 13 21:55 /dev/sda5
6
brw-rw---- 1 root disk 8, 16 Jan 13 22:02 /dev/sdb
7
brw-rw---- 1 root disk 8, 32 Jan 13 22:02 /dev/sdc
8
9
[email protected]:~# fdisk /dev/sdb
10
11
Welcome to fdisk (util-linux 2.27.1).
12
Changes will remain in memory only, until you decide to write them.
13
Be careful before using the write command.
14
15
16
Command (m for help): n
17
Partition type
18
p primary (0 primary, 0 extended, 4 free)
19
e extended (container for logical partitions)
20
Select (default p): p
21
Partition number (1-4, default 1):
22
First sector (2048-2097151, default 2048):
23
Last sector, +sectors or +size{K,M,G,T,P} (2048-2097151, default 2097151):
24
25
Created a new partition 1 of type 'Linux' and of size 1023 MiB.
26
27
Command (m for help): t
28
Selected partition 1
29
Partition type (type L to list all types): L
30
31
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
32
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
33
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
34
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
35
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
36
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
37
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
38
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
39
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
40
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
41
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
42
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
43
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Rufus alignment
44
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
45
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
46
10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
47
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
48
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor
49
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor
50
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
51
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS
52
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE
53
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto
54
1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep
55
1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT
56
Partition type (type L to list all types): 8e
57
Changed type of partition 'Linux' to 'Linux LVM'.
58
59
Command (m for help): w
60
The partition table has been altered.
61
Calling ioctl() to re-read partition table.
62
Syncing disks.
63
64
[email protected]:~# fdisk /dev/sdc
65
66
Welcome to fdisk (util-linux 2.27.1).
67
Changes will remain in memory only, until you decide to write them.
68
Be careful before using the write command.
69
70
71
Command (m for help): n
72
Partition type
73
p primary (0 primary, 0 extended, 4 free)
74
e extended (container for logical partitions)
75
Select (default p): p
76
Partition number (1-4, default 1):
77
First sector (2048-4194303, default 2048):
78
Last sector, +sectors or +size{K,M,G,T,P} (2048-4194303, default 4194303):
79
80
Created a new partition 1 of type 'Linux' and of size 2 GiB.
81
82
Command (m for help): t
83
Selected partition 1
84
Partition type (type L to list all types): 8e
85
Changed type of partition 'Linux' to 'Linux LVM'.
86
87
Command (m for help): w
88
The partition table has been altered.
89
Calling ioctl() to re-read partition table.
90
Syncing disks.
Copied!
Now lets chek weather any LVM has been setup or not and start:
1
[email protected]:~# pvdisplay
2
[email protected]:~# pvcreate /dev/sdb1 /dev/sdc1
3
Physical volume "/dev/sdb1" successfully created
4
Physical volume "/dev/sdc1" successfully created
5
[email protected]:~# pvdisplay
6
"/dev/sdc1" is a new physical volume of "2.00 GiB"
7
--- NEW Physical volume ---
8
PV Name /dev/sdc1
9
VG Name
10
PV Size 2.00 GiB
11
Allocatable NO
12
PE Size 0
13
Total PE 0
14
Free PE 0
15
Allocated PE 0
16
PV UUID 5XaGvK-vjWs-lzNk-IPMA-grXi-yFZ8-AeLUBk
17
18
"/dev/sdb1" is a new physical volume of "1023.00 MiB"
19
--- NEW Physical volume ---
20
PV Name /dev/sdb1
21
VG Name
22
PV Size 1023.00 MiB
23
Allocatable NO
24
PE Size 0
25
Total PE 0
26
Free PE 0
27
Allocated PE 0
28
PV UUID JZ3DkI-goy7-tNIW-MpgH-NC3T-02dT-YB2WTL
Copied!
physical volume commands
Description
pvdisplay
display physical volume details
pvscan
scan all disks for physical volume
pvs
report info about physical volumes
pvcreate /dev/sdb1 /dev/sdc1
create physical volume
pvchange
Activate, de-Activate physical volume
pvmove
move data from one pv to another pv
pvremove /dev/sdc1
remove a physical volume

Working with volume group(vg)

Now we create a volume group consist of two pv, /dev/sdb1 and /dev/sdc1:
1
[email protected]:~# vgdisplay
2
[email protected]:~# vgcreate myfirstvg /dev/sdb1 /dev/sdc1
3
Volume group "myfirstvg" successfully created
4
[email protected]:~# vgdisplay
5
--- Volume group ---
6
VG Name myfirstvg
7
System ID
8
Format lvm2
9
Metadata Areas 2
10
Metadata Sequence No 1
11
VG Access read/write
12
VG Status resizable
13
MAX LV 0
14
Cur LV 0
15
Open LV 0
16
Max PV 0
17
Cur PV 2
18
Act PV 2
19
VG Size 2.99 GiB
20
PE Size 4.00 MiB
21
Total PE 766
22
Alloc PE / Size 0 / 0
23
Free PE / Size 766 / 2.99 GiB
24
VG UUID pBA82t-uB9F-VGpT-PKjn-HL9K-1KyN-Yo1VLg
Copied!
volume group commands
Description
vgdisplay
Display volume group details
vgscan
scans disk devices in the system looking for PV and VG
vgs
Report info about volume groups
vgcreate myfirstvg /dev/sdb1 /dev/sdc1
Create a volume group
vgextend myfirstvg /dev/sdd1 /dev/sde1
Add a new PV to VG
vgreduce myfirstvg /dev/sde1
Remove PV from VG
vgexport myfirstvg
Export VG to system
vgimport myfirstvg /dev/sdb1 /dev/sdd1
Import VG system
vgchange -a y myfirstvg
Activate VG, use "-a n" to deactivate
vgremove myfirstvg
Remove VG from the system
vgrename myfirstvg myvg00
Rename VG
vgsync /dev/myfirstvg
Sync stale PE in VG

Working with logical volume(lv)

1
[email protected]:~# lvdisplay
2
[email protected]:~# lvcreate --name myfirstlv --size 1G myfirstvg
3
Logical volume "myfirstlv" created.
4
[email protected]:~# lvdisplay
5
--- Logical volume ---
6
LV Path /dev/myfirstvg/myfirstlv
7
LV Name myfirstlv
8
VG Name myfirstvg
9
LV UUID g75etD-o9YW-iAeM-sU2d-nKat-K84V-yle2qv
10
LV Write Access read/write
11
LV Creation host, time server2, 2018-01-13 22:47:49 -0800
12
LV Status available
13
# open 0
14
LV Size 1.00 GiB
15
Current LE 256
16
Segments 1
17
Allocation inherit
18
Read ahead sectors auto
19
- currently set to 256
20
Block device 253:0
Copied!
And lets format it and mount it:
1
[email protected]:~# mkfs.ext4 /dev/myfirstvg/myfirstlv
2
mke2fs 1.42.13 (17-May-2015)
3
Creating filesystem with 262144 4k blocks and 65536 inodes
4
Filesystem UUID: fe539cb4-596c-456d-b337-9e90b6e47b28
5
Superblock backups stored on blocks:
6
32768, 98304, 163840, 229376
7
8
Allocating group tables: done
9
Writing inode tables: done
10
Creating journal (8192 blocks): done
11
Writing superblocks and filesystem accounting information: done
12
13
[email protected]:~# mount /dev/myfirstvg/myfirstlv /mnt/
15
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
16
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
17
udev on /dev type devtmpfs (rw,nosuid,relatime,size=474520k,nr_inodes=118630,mode=755)
18
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
19
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=99492k,mode=755)
20
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
21
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
22
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
23
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
24
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
25
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
26
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
27
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
28
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
29
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
30
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
31
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
32
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
33
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
34
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
35
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
36
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
37
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=25,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=15263)
38
mqueue on /dev/mqueue type mqueue (rw,relatime)
39
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
40
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
41
sunrpc on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
42
nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
43
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
44
configfs on /sys/kernel/config type configfs (rw,relatime)
45
vmware-vmblock on /run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other)
46
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=99492k,mode=700,uid=1000,gid=1000)
47
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
48
/dev/mapper/myfirstvg-myfirstlv on /mnt type ext4 (rw,relatime,data=ordered)
Copied!
We can now easily resize volume group with lvresize:
1
[email protected]:~# lvresize --help
2
lvresize: Resize a logical volume
3
4
lvresize
5
[-A|--autobackup y|n]
6
[--alloc AllocationPolicy]
7
[--commandprofile ProfileName]
8
[-d|--debug]
9
[-f|--force]
10
[-h|--help]
11
[-i|--stripes Stripes [-I|--stripesize StripeSize]]
12
{-l|--extents [+|-]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}] |
13
-L|--size [+|-]LogicalVolumeSize[bBsSkKmMgGtTpPeE]}
14
--poolmetadatasize [+]MetadataVolumeSize[bBsSkKmMgG]}
15
[-n|--nofsck]
16
[--noudevsync]
17
[-r|--resizefs]
18
[-t|--test]
19
[--type VolumeType]
20
[-v|--verbose]
21
[--version]
22
LogicalVolume[Path] [ PhysicalVolumePath... ]
23
25
Filesystem Size Used Avail Use% Mounted on
26
udev 464M 0 464M 0% /dev
27
tmpfs 98M 6.2M 92M 7% /run
28
/dev/sda1 49G 4.6G 42G 10% /
29
tmpfs 486M 212K 486M 1% /dev/shm
30
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
31
tmpfs 486M 0 486M 0% /sys/fs/cgroup
32
tmpfs 98M 60K 98M 1% /run/user/1000
33
/dev/mapper/myfirstvg-myfirstlv 978M 1.3M 915M 1% /mnt
34
35
[email protected]:~# lvresize -L +999M -r /dev/myfirstvg/myfirstlv
36
Rounding size to boundary between physical extents: 1000.00 MiB
37
Size of logical volume myfirstvg/myfirstlv changed from 1.00 GiB (256 extents) to 1.98 GiB (506 extents).
38
Logical volume myfirstlv successfully resized.
39
resize2fs 1.42.13 (17-May-2015)
40
Filesystem at /dev/mapper/myfirstvg-myfirstlv is mounted on /mnt; on-line resizing required
41
old_desc_blocks = 1, new_desc_blocks = 1
42
The filesystem on /dev/mapper/myfirstvg-myfirstlv is now 518144 (4k) blocks long.
43
45
Filesystem Size Used Avail Use% Mounted on
46
udev 464M 0 464M 0% /dev
47
tmpfs 98M 6.2M 92M 7% /run
48
/dev/sda1 49G 4.6G 42G 10% /
49
tmpfs 486M 212K 486M 1% /dev/shm
50
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
51
tmpfs 486M 0 486M 0% /sys/fs/cgroup
52
tmpfs 98M 60K 98M 1% /run/user/1000
53
/dev/mapper/myfirstvg-myfirstlv 2.0G 1.5M 1.9G 1% /mnt
Copied!
if we havn't used -rswitch then we had to use resizefs /dev/myfirstvg/myfirstlvcommand inorder to get File System .informed about size changes.
logical volume commands
Description
lvdisplay
Display logical volume details
lvscan
Scan for logical volumes
lvs
show logical volume info
lvcreate --name --size 1G my2ndlv
Create logical volume
lvremove /dev/myfirstvg/myfirstlv
Remove logical volume
lvrename my2ndlv my3rdlv
Rename logical volume
lvextend -L1G /dev/myfirstvg/myfirstlv
Increase size of logical volume
lvreduce -L1G /dev/myfirstvg/myfirstlv
Decrease size of logical volume
lvchange -ay /dev/myfirstvg/myfirstlv
Active logical volume, use "-an" to Deactivate
lvsync /dev/myfirstvg/myfirstlv
Sync stale LE of logical volume
lvlnboot [-b/-d/-r/-s/-R/-v] /dev/myfirstvg/myfirstlv
Set lv as root, boot, swap, dump volume

LVM snapshots

snapshots lets us to freeze the current state of logical volume.Every thing which is added or removed doesn't make any changes in our snapshot and we can easily reverse to previous stat of volume. snapshots can help us to create a short term backup when no files are open. For creating snap shots we should define the size of snap shot, so we should consider amount of future changes:
2
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
3
sdb 8:16 0 1G 0 disk
4
└─sdb1 8:17 0 1023M 0 part
5
sr0 11:0 1 1024M 0 rom
6
sdc 8:32 0 2G 0 disk
7
└─sdc1 8:33 0 2G 0 part
8
└─myfirstvg-myfirstlv 253:0 0 2G 0 lvm /mnt
9
sda 8:0 0 50G 0 disk
10
├─sda2 8:2 0 1K 0 part
11
├─sda5 8:5 0 1021M 0 part [SWAP]
12
└─sda1 8:1 0 49G 0 part /
13
[email protected]:~# cp /etc/[abc]* /mnt/
14
cp: omitting directory '/etc/acpi'
15
cp: omitting directory '/etc/alternatives'
16
cp: omitting directory '/etc/apm'
17
cp: omitting directory '/etc/apparmor'
18
cp: omitting directory '/etc/apparmor.d'
19
cp: omitting directory '/etc/apport'
20
cp: omitting directory '/etc/apt'
21
cp: omitting directory '/etc/aptdaemon'
22
cp: omitting directory '/etc/at-spi2'
23
cp: omitting directory '/etc/avahi'
24
cp: omitting directory '/etc/bash_completion.d'
25
cp: omitting directory '/etc/binfmt.d'
26
cp: omitting directory '/etc/bluetooth'
27
cp: omitting directory '/etc/brltty'
28
cp: omitting directory '/etc/ca-certificates'
29
cp: omitting directory '/etc/calendar'
30
cp: omitting directory '/etc/chatscripts'
31
cp: omitting directory '/etc/compizconfig'
32
cp: omitting directory '/etc/console-setup'
33
cp: omitting directory '/etc/cracklib'
34
cp: omitting directory '/etc/cron.d'
35
cp: omitting directory '/etc/cron.daily'
36
cp: omitting directory '/etc/cron.hourly'
37
cp: omitting directory '/etc/cron.monthly'
38
cp: omitting directory '/etc/cron.weekly'
39
cp: omitting directory '/etc/cups'
40
cp: omitting directory '/etc/cupshelpers'
41
42
[email protected]:~# lvcreate -s --size 100M --name myfirstsnap /dev/myfirstvg/myfirstlv
43
Logical volume "myfirstsnap" created.
44
46
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
47
myfirstlv myfirstvg owi-aos--- 1.98g
48
myfirstsnap myfirstvg swi-a-s--- 100.00m myfirstlv 0.01
Copied!
Lets remove some data and restore snap shot, do not forget to unmount before restoring snap shot:
1
[email protected]:~# cd /mnt/
3
adduser.conf appstream.conf bindresvport.blacklist ca-certificates.conf
4
anacrontab bash.bashrc brlapi.key crontab
5
apg.conf bash_completion brltty.conf lost+found
6
7
[email protected]:/mnt# rm a*
9
bash.bashrc bindresvport.blacklist brltty.conf crontab
10
bash_completion brlapi.key ca-certificates.conf lost+found
12
13
[email protected]:~# umount /mnt
14
15
[email protected]:~# lvconvert --merg /dev/myfirstvg/myfirstsnap
16
Merging of volume myfirstsnap started.
17
myfirstlv: Merged: 100.0%
18
19
[email protected]:~# mount /dev/myfirstvg/myfirstlv /mnt
20
[email protected]:~# ls /mnt/
21
adduser.conf appstream.conf bindresvport.blacklist ca-certificates.conf
22
anacrontab bash.bashrc brlapi.key crontab
23
apg.conf bash_completion brltty.conf lost+found
Copied!

/etc/lvm/*

Lets take a look at /etc/lvm/ directory:
1
[email protected]:~# tree /etc/lvm/
2
/etc/lvm/
3
├── archive ###where automatic archives go after a volume group change
4
│ ├── myfirstvg_00000-1093593173.vg
5
│ ├── myfirstvg_00001-830021442.vg
6
│ ├── myfirstvg_00002-880534144.vg
7
│ ├── myfirstvg_00003-1582663489.vg
8
│ ├── myfirstvg_00004-912884793.vg
9
│ ├── myfirstvg_00005-61387558.vg
10
│ ├── myfirstvg_00006-950931226.vg
11
│ ├── myfirstvg_00007-1556055507.vg
12
│ ├── myfirstvg_00008-122687836.vg
13
│ ├── myfistvg_00000-1042362796.vg
14
│ ├── myfistvg_00001-1480349148.vg
15
│ ├── myvg_00000-1839154512.vg
16
│ ├── myvg_00001-1559838799.vg
17
│ ├── myvg_00002-477252563.vg
18
│ └── myvg_00003-455796415.vg
19
├── backup ###where the automatic backups go
20
│ └── myfirstvg
21
└── lvm.conf
Copied!
lvm.conf is loaded during the initialisation phase of lvm. This file can in turn lead to other files being loaded - settings read in later override earlier settings. File timestamps are checked between commands and if any have changed, all the files are reloaded.
Metadata backups and archives are automatically created on every volume group and logical volume configuration change unless disabled in the lvm.conf file. By default, the metadata backup is stored in the /etc/lvm/backup file and the metadata archives are stored in the /etc/lvm/archive file. How long and how many meta data archive are kept? it is determined by parameters we can set in the lvm.conf file.

Logical Volume Backup

A daily system backup should include the contents of the /etc/lvm directory in the backup. Note that a metadata backup does not back up the user and system data contained in the logical volumes.We can manually back up the metadata to the /etc/lvm/backup file with the vgcfgbackup command.And we can restore metadata with the vgcfgrestore command.

/dev/mapper

The Device mapper is a generic interface to the linux kernel that can be used by different storage solutions.
Lets Take a look:
1
[email protected]:~# ls -l /dev/myfirstvg/myfirstlv
2
lrwxrwxrwx 1 root root 7 Jan 14 00:22 /dev/myfirstvg/myfirstlv -> ../dm-0
3
[email protected]:~# ls -l /dev/dm-0
4
brw-rw---- 1 root disk 253, 0 Jan 14 00:22 /dev/dm-0
Copied!
By using LVM or RAID or LUKS more md-X devices are created and used. Nice interface to that is:
1
[email protected]:~# ls -l /dev/mapper/
2
total 0
3
crw------- 1 root root 10, 236 Jan 13 21:55 control
4
lrwxrwxrwx 1 root root 7 Jan 13 22:55 myfirstvg-myfirstlv -> ../dm-0
Copied!
Some Device Mapper Devices might be created just for the system to do it things. We can work with Device Mapper Directly with dmsetup command but thats not straightforward and it is beyond the scope of LPIC exam.
1
[email protected]:/dev# dmsetup ls
2
myfirstvg-myfirstlv (253:0)
3
[email protected]:/dev# dmsetup info myfirstvg-myfirstlv
4
Name: myfirstvg-myfirstlv
5
State: ACTIVE
6
Read Ahead: 256
7
Tables present: LIVE
8
Open count: 1
9
Event number: 0
10
Major, minor: 253, 0
11
Number of targets: 1
12
UUID: LVM-pBA82tuB9FVGpTPKjnHL9K1KyNYo1VLgg75etDo9YWiAeMsU2dnKatK84Vyle2qv
Copied!
so we have seen while using RAID can give us performance and reliability, LVM cause flexibility.
Last modified 2yr ago