Bootstrap FreeKB - LVM (Logical Volume Manager) - What are extents
LVM (Logical Volume Manager) - What are extents


Let's say you use the vgcreate command to add physical volumes to a volume group. In this example, the name of the volume group is "vg001".

vgcreate vg001 /dev/sdb1 /dev/sdc1

 

The vgdisplay command can then be used to display the volume group. Notice in this example that each PE (Physical Extents) is 4 MB, and that there are 3970 Physical Extents. From this we can conclude that an extent is a block of storage.

Doing some simple math, 4 times 3970 is 15880. 15880 divided by 1024 is 15.51, which matches the Volume Group size of 15.51 GB.

--- Volume group ---
VG Name               vg001
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  3
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                1
Act PV                1
VG Size               <15.51 GiB
PE Size               4.00 MiB
Total PE              3970
Alloc PE / Size       3960 / <15.47 GiB
Free  PE / Size       10 / 40.00 MiB
VG UUID               lgHh9m-9iMP-8ltU-2cxz-Y4wL-uwG0-EHiGFr

 

he lvcreate command can be used to create logical volumes from available space in the volume group. One option is to use the --size option, to declare the size in KB or MB or GB of the logical volume.

lvcreate --size 2.6G --name root vg001
lvcreate --size 10G  --name var  vg001
lvcreate --size 50G  --name www  vg001

 

Or the --extents option can be used, to declare the number or percentage of extents to use.

lvcreate --extents 1000     --name root vg001
lvcreate --extents 50%VG    --name var  vg001
lvcreate --extents 100%FREE --name www  vg001

 

The lvdisplay command can then be used to display each logical volume. Notice that each logical volume has Logical Extents (LE). Recall the each extent is 4 MB.

Notice the /dev/vg001/root logical volume has 666 Logical Extents. 666 times 4 is 2664. 2664 divided by 1024 is 2.60, which matches the Logical Volume size of 2.6 GB.

---Logical volume---
LV Path               /dev/vg001/root
LV Name               root
VG Name               vg001
LV UUID               EuBJ3c-Q8EU0M5ef-Qvip-KeyH-m2Sc-MGelKe
LV Creation host,time localhost.localdomain, 2013-10-11 15:40:12 -0500
LV Status             available
# open                1
LV Size               2.60 GiB
Current LE            666
Segments              1
Allocation            inherit
Read ahead sectors    auto
- currently set to    256
Block device          253:9

---Logical volume---
LV Path               /dev/vg001/var
LV Name               var
VG Name               vg001
LV UUID               EuBJ3c-Q8EU0M5ef-Qvip-KeyH-m2Sc-MGelKe
LV Creation host,time localhost.localdomain, 2013-10-11 15:40:12 -0500
LV Status             available
# open                1
LV Size               50.00 GiB
Current LE            12800
Segments              3
Allocation            inherit
Read ahead sectors    auto
- currently set to    256
Block device          253:9

---Logical volume---
LV Path               /dev/vg001/www
LV Name               www
VG Name               vg001
LV UUID               EuBJ3c-Q8EU0M5ef-Qvip-KeyH-m2Sc-MGelKe
LV Creation host,time localhost.localdomain, 2013-10-11 15:40:12 -0500
LV Status             available
# open                1
LV Size               10.00 GiB
Current LE            2560
Segments              3
Allocation            inherit
Read ahead sectors    auto
- currently set to    256
Block device          253:9

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


August 08 2023 by xkcd
after all the searching i finally understood how it actually works. thanks

Add a Comment


Please enter 501d1a in the box below so that we can be sure you are a human.