Skip to main content

Logical Volume Management (LVM)

Logical Volume Management (LVM)

Date: 18/05/2024

Status: Tested

Logical Volume Management,  or LVM, provides a method of allocating and managing space on  mass-storage devices that is more advanced and flexible than the  traditional method of partitioning storage volumes.

To find out how to set up LVM in Ubuntu, refer to this guide, which will also show you how to resize and move partitions, and how to create snapshots.

Key concepts

There are 3 concepts that LVM manages:

  • Physical volumes ( PV ): correspond to disks. They represent the lowest abstraction level of LVM, and are used to create a volume group.
  • Volume groups ( VG ): are collections of physical volumes. They are pools of disk space that logical volumes can be allocated from.
  • Logical volumes ( LV ): correspond to partitions – they usually hold a filesystem. Unlike partitions though, they can span multiple disks (because of the way volume groups are organised) and do not have to be physically contiguous.

lets open our home lab and try how LVM works.

Requirements:

Linux machine running baremetal or VM.

3 Disk (OS,PV1,PV2)

Simulating:

Create PV

Create VG

Creating LV

Create file system

Mounting

Reduce LV

Remove from VG

Remove from OS

Ubuntu with 3 disk, disk #1 Operating System, disk #2 & #3 alocated for Volume Group

ubuntu@ubuntu:~$ sudo fdisk -l
Disk /dev/sda: 8 GiB, 8589934592 bytes, 16777216 sectors
Disk model: VBOX HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 534EB29B-2FE8-482C-BB79-8C98AE4D1174
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 16775167 16771072 8G Linux filesystem
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VBOX HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdc: 15 GiB, 16106127360 bytes, 31457280 sectors
Disk model: VBOX HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
ubuntu@ubuntu:~$

Disk Capacity

/dev/sda 8G
/dev/sdb 10G
/dev/sdc 15G

 

Creating PV

Creating (PV) Physical Volume for /dev/sdb  and /dev/sdc

ubuntu@ubuntu:~$ sudo lvm

lvm> pvcreate /dev/sdb

Physical volume "/dev/sdb" successfully created.

lvm> pvcreate /dev/sdc

Physical volume "/dev/sdc" successfully created.

lvm> pvdisplay

"/dev/sdb" is a new physical volume of "10.00 GiB"

--- NEW Physical volume ---

PV Name /dev/sdb

VG Name

PV Size 10.00 GiB

Allocatable NO

PE Size 0

Total PE 0

Free PE 0

Allocated PE 0

PV UUID qaRqDq-0MmA-OAAC-4QnH-vvXF-12Fc-EdRep3

"/dev/sdc" is a new physical volume of "15.00 GiB"

--- NEW Physical volume ---

PV Name /dev/sdc

VG Name

PV Size 15.00 GiB

Allocatable NO

PE Size 0

Total PE 0

Free PE 0

Allocated PE 0

PV UUID BgjRNz-7cjU-CpFe-6nNn-OxaV-OZUa-3dLsDh

lvm>

 

Creating VG

Creating Volume Group (VG) and attaching /dev/sdb  into Volume Group

lvm> vgcreate ubuntu-vg /dev/sdb

Volume group "ubuntu-vg" successfully created

lvm> vgs

VG #PV #LV #SN Attr VSize VFree

ubuntu-vg 1 0 0 wz--n- <10.00g <10.00g

lvm> vgdisplay

--- Volume group ---

VG Name ubuntu-vg

System ID

Format lvm2

Metadata Areas 1

Metadata Sequence No 1

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 0

Open LV 0

Max PV 0

Cur PV 1

Act PV 1

VG Size <10.00 GiB

PE Size 4.00 MiB

Total PE 2559

Alloc PE / Size 0 / 0

Free PE / Size 2559 / <10.00 GiB

VG UUID E2OrNE-p76Y-UwIl-NiQs-ozHJ-C8ZT-xc1Mqy

lvm> pvs

PV VG Fmt Attr PSize PFree

/dev/sdb ubuntu-vg lvm2 a-- <10.00g <10.00g

/dev/sdc lvm2 --- 15.00g 15.00g

lvm>

 

Creating LV

Create Logical Volume (LV) and use all (100%) of free space on ubuntu-vg .

lvm> lvcreate -l 100%free -n ubuntu-lv ubuntu-vg

Logical volume "ubuntu-lv" created.

lvm>

lvm> lvdisplay

--- Logical volume ---

LV Path /dev/ubuntu-vg/ubuntu-lv

LV Name ubuntu-lv

VG Name ubuntu-vg

LV UUID d4pPYZ-HwAx-w4wK-NzNr-xd2P-FXPp-fmLaYr

LV Write Access read/write

LV Creation host, time ubuntu, 2024-05-19 09:54:44 +0000

LV Status available

# open 0

LV Size <10.00 GiB

Current LE 2559

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:0

lvm>

 

Creating file system

Create file system and ready to mount.

ubuntu@ubuntu:~$ sudo mkfs -t ext4 /dev/ubuntu-vg/ubuntu-lv

mke2fs 1.46.5 (30-Dec-2021)

Creating filesystem with 2620416 4k blocks and 655360 inodes

Filesystem UUID: 3f80be60-f70e-4fd0-ac0d-4f5995be2c11

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done

Writing inode tables: done

Creating journal (16384 blocks): done

Writing superblocks and filesystem accounting information: done

ubuntu@ubuntu:~$

 

Mounting

Preparing for mounting by create folder /data , change owner folder and mounting the LV.

sudo mkdir /data

sudo chown ubuntu:ubuntu /data

sudo mount /dev/ubuntu-vg/ubuntu-lv /data

continue by updating fstab for automatic mounting every boot

#sudo nano /etc/fstab

#add this line

/dev/ubuntu-vg/ubuntu-lv /data ext4 defaults

test fstab before reboot using sudo mount -a when no error you are good to go.

ubuntu@ubuntu:~$ df -h

Filesystem Size Used Avail Use% Mounted on

tmpfs 392M 764K 391M 1% /run

/dev/sda2 7.8G 2.6G 4.8G 36% /

tmpfs 2.0G 0 2.0G 0% /dev/shm

tmpfs 5.0M 0 5.0M 0% /run/lock

tmpfs 391M 4.0K 391M 1% /run/user/1000

/dev/mapper/ubuntu--vg-ubuntu--lv 9.8G 24K 9.3G 1% /data

ubuntu@ubuntu:~$

now we try to filling disk with data. as you can see the /data usage is 1%  of 9.8G total.

Bellow /data usage 100%  (9.3G of 9.8G) after filling with data/file.

ubuntu@ubuntu:/$ df -h

Filesystem Size Used Avail Use% Mounted on

tmpfs 392M 756K 391M 1% /run

/dev/sda2 7.8G 2.6G 4.8G 36% /

tmpfs 2.0G 0 2.0G 0% /dev/shm

tmpfs 5.0M 0 5.0M 0% /run/lock

tmpfs 391M 4.0K 391M 1% /run/user/1000

/dev/mapper/ubuntu--vg-ubuntu--lv 9.8G 9.3G 0 100% /data

ubuntu@ubuntu:/$

Volume are full and no longer able to add another data/files, we need to add more space by attaching new Physical Volume (PV) into our ubuntu-vg (VG) for expand capacity.

ubuntu@ubuntu:~$ sudo lvm

lvm> pvs

PV VG Fmt Attr PSize PFree

/dev/sdb ubuntu-vg lvm2 a-- <10.00g 0

/dev/sdc lvm2 --- 15.00g 15.00g

lvm> pvdisplay

--- Physical volume ---

PV Name /dev/sdb

VG Name ubuntu-vg

PV Size 10.00 GiB / not usable 4.00 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 2559

Free PE 0

Allocated PE 2559

PV UUID qaRqDq-0MmA-OAAC-4QnH-vvXF-12Fc-EdRep3

"/dev/sdc" is a new physical volume of "15.00 GiB"

--- NEW Physical volume ---

PV Name /dev/sdc

VG Name

PV Size 15.00 GiB

Allocatable NO

PE Size 0

Total PE 0

Free PE 0

Allocated PE 0

PV UUID BgjRNz-7cjU-CpFe-6nNn-OxaV-OZUa-3dLsDh

lvm>

by using pvdisplay command we can see that /dev/sdc is not part of group VG ubuntu-vg.

Now we add PV into VG ubuntu-vg by execute command vgextend ubuntu-vg /dev/sdc .

this time, we only use 8G disk space of 15G total from disk capacity

lvm> pvs

PV VG Fmt Attr PSize PFree

/dev/sdb ubuntu-vg lvm2 a-- <10.00g 0

/dev/sdc lvm2 --- 15.00g 15.00g

lvm>

lvm> vgextend ubuntu-vg /dev/sdc

Volume group "ubuntu-vg" successfully extended

lvm>

lvm> pvs

PV VG Fmt Attr PSize PFree

/dev/sdb ubuntu-vg lvm2 a-- <10.00g 0

/dev/sdc ubuntu-vg lvm2 a-- <15.00g <15.00g

lvm>

lvm> lvextend -L +8G ubuntu-vg/ubuntu-lv

Size of logical volume ubuntu-vg/ubuntu-lv changed from <10.00 GiB (2559 extents) to <18.00 GiB (4607 extents).

Logical volume ubuntu-vg/ubuntu-lv successfully resized.

lvm>

lvm> pvs

PV VG Fmt Attr PSize PFree

/dev/sdb ubuntu-vg lvm2 a-- <10.00g 0

/dev/sdc ubuntu-vg lvm2 a-- <15.00g <7.00g

lvm>

after lvextend command successfully our LV has been expanding to 18G, 10G (/dev/sdb) + 8G (dev/sdc)

lvm> lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert

ubuntu-lv ubuntu-vg -wi-ao---- <18.00g

lvm> lvdisplay

--- Logical volume ---

LV Path /dev/ubuntu-vg/ubuntu-lv

LV Name ubuntu-lv

VG Name ubuntu-vg

LV UUID d4pPYZ-HwAx-w4wK-NzNr-xd2P-FXPp-fmLaYr

LV Write Access read/write

LV Creation host, time ubuntu, 2024-05-19 09:54:44 +0000

LV Status available

# open 1

LV Size <18.00 GiB

Current LE 4607

Segments 2

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:0

but remember, the 18G of LV is just capacity that we allocated, doesn't mean useable until we do resize filesystem by execute command resize2fs .

ubuntu@ubuntu:~$ df -h

Filesystem Size Used Avail Use% Mounted on

tmpfs 392M 756K 391M 1% /run

/dev/sda2 7.8G 2.6G 4.8G 36% /

tmpfs 2.0G 0 2.0G 0% /dev/shm

tmpfs 5.0M 0 5.0M 0% /run/lock

tmpfs 391M 4.0K 391M 1% /run/user/1000

/dev/mapper/ubuntu--vg-ubuntu--lv 9.8G 9.3G 0 100% /data

ubuntu@ubuntu:~$

ubuntu@ubuntu:~$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

resize2fs 1.46.5 (30-Dec-2021)

Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /data; on-line resizing required

old_desc_blocks = 2, new_desc_blocks = 3

The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 4717568 (4k) blocks long.

ubuntu@ubuntu:~$ df -h

Filesystem Size Used Avail Use% Mounted on

tmpfs 392M 756K 391M 1% /run

/dev/sda2 7.8G 2.6G 4.8G 36% /

tmpfs 2.0G 0 2.0G 0% /dev/shm

tmpfs 5.0M 0 5.0M 0% /run/lock

tmpfs 391M 4.0K 391M 1% /run/user/1000

/dev/mapper/ubuntu--vg-ubuntu--lv 18G 9.3G 7.6G 56% /data

ubuntu@ubuntu:~$

sekarang VG ubuntu-vg/ubuntu-lv telah berubah menjadi 18G, untuk membuktikannya mari kita lakukan pengisian data/file kembali.

ubuntu@ubuntu:~$ df -h

Filesystem Size Used Avail Use% Mounted on

tmpfs 392M 756K 391M 1% /run

/dev/sda2 7.8G 2.6G 4.8G 36% /

tmpfs 2.0G 0 2.0G 0% /dev/shm

tmpfs 5.0M 0 5.0M 0% /run/lock

tmpfs 391M 4.0K 391M 1% /run/user/1000

/dev/mapper/ubuntu--vg-ubuntu--lv 18G 14G 2.8G 84% /data

ubuntu@ubuntu:~$

saat ini kita akan simulasikan kebutuuhan menyimpan data sudahlah tidak besar dan kita akan me-reduce (shrink) Volume dan mengeluarkan /dev/sdc dari VG

ubuntu@ubuntu:/data$ df -h

Filesystem Size Used Avail Use% Mounted on

tmpfs 392M 764K 391M 1% /run

/dev/sda2 7.8G 2.6G 4.8G 36% /

tmpfs 2.0G 0 2.0G 0% /dev/shm

tmpfs 5.0M 0 5.0M 0% /run/lock

/dev/mapper/ubuntu--vg-ubuntu--lv 18G 2.0G 15G 12% /data

tmpfs 391M 4.0K 391M 1% /run/user/1000

ubuntu@ubuntu:/data$

terlihat folder /data masih memiki data/file namun isinya sudah tidak sebanyak sebelumnya  yg mencapai 14G.

sebelum proses dilakukan sangat di sarankan untuk membackup dahulu, sebagai pencegahan jika terjadi keadaan yg tidak dinginkan, dan lakukan simulasi di evironmen lain dahulu sebagai gambaran tantangan yg akan di hadapi pada proses didepan.

STOP........!!! LAKUKAN BACKUP DAN SIMULASI dahulu sangat disarankan !

jika sudah yakin mari kita mulai

ubuntu@ubuntu:/$ sudo umount /data

ubuntu@ubuntu:/$ sudo e2fsck -f /dev/ubuntu-vg/ubuntu-lv

e2fsck 1.46.5 (30-Dec-2021)

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/ubuntu-vg/ubuntu-lv: 12/1179648 files (0.0% non-contiguous), 622552/4717568 blocks

ubuntu@ubuntu:/$

ubuntu@ubuntu:/$ sudo lvreduce --resizefs -L 5G /dev/ubuntu-vg/ubuntu-lv

fsck from util-linux 2.37.2

/dev/mapper/ubuntu--vg-ubuntu--lv: clean, 12/1179648 files, 622552/4717568 blocks

resize2fs 1.46.5 (30-Dec-2021)

Resizing the filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv to 1310720 (4k) blocks.

The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 1310720 (4k) blocks long.

Size of logical volume ubuntu-vg/ubuntu-lv changed from <18.00 GiB (4607 extents) to 5.00 GiB (1280 extents).

Logical volume ubuntu-vg/ubuntu-lv successfully resized.

ubuntu@ubuntu:/$

Note: The LVM environment offers three commands to resize: lvresizelvreduce, and lvextend. The resize let you change the size (bigger or smaller), the reduce only allows smaller sizes (i.e. at most X Gb) and the extend only allows larger sizes (i.e. at least X Gb).

ubuntu@ubuntu:/$ sudo mount /data

ubuntu@ubuntu:/$ ls

bin data etc lib lib64 lost+found mnt proc run snap sys usr

boot dev home lib32 libx32 media opt root sbin srv tmp var

ubuntu@ubuntu:/$ cd /data/

ubuntu@ubuntu:/data$ df -h

Filesystem Size Used Avail Use% Mounted on

tmpfs 392M 764K 391M 1% /run

/dev/sda2 7.8G 2.6G 4.8G 36% /

tmpfs 2.0G 0 2.0G 0% /dev/shm

tmpfs 5.0M 0 5.0M 0% /run/lock

tmpfs 391M 4.0K 391M 1% /run/user/1000

/dev/mapper/ubuntu--vg-ubuntu--lv 4.9G 2.0G 2.6G 44% /data

ubuntu@ubuntu:/data$ du -h

ubuntu@ubuntu:/data$ sudo lvm

lvm> lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert

ubuntu-lv ubuntu-vg -wi-ao---- 5.00g

lvm> pvs

PV VG Fmt Attr PSize PFree

/dev/sdb ubuntu-vg lvm2 a-- <10.00g <5.00g

/dev/sdc ubuntu-vg lvm2 a-- <15.00g <15.00g

lvm> pvdisplay

--- Physical volume ---

PV Name /dev/sdb

VG Name ubuntu-vg

PV Size 10.00 GiB / not usable 4.00 MiB

Allocatable yes

PE Size 4.00 MiB

Total PE 2559

Free PE 1279

Allocated PE 1280

PV UUID qaRqDq-0MmA-OAAC-4QnH-vvXF-12Fc-EdRep3

--- Physical volume ---

PV Name /dev/sdc

VG Name ubuntu-vg

PV Size 15.00 GiB / not usable 4.00 MiB

Allocatable yes

PE Size 4.00 MiB

Total PE 3839

Free PE 3839

Allocated PE 0

PV UUID BgjRNz-7cjU-CpFe-6nNn-OxaV-OZUa-3dLsDh

lvm>

dapat di lihat /dev/sdc masih berada dalam VG ubuntu-vg namun tidak digunakan.

lvm> pvdisplay

--- Physical volume ---

PV Name /dev/sdb

VG Name ubuntu-vg

PV Size 10.00 GiB / not usable 4.00 MiB

Allocatable yes

PE Size 4.00 MiB

Total PE 2559

Free PE 1279

Allocated PE 1280

PV UUID qaRqDq-0MmA-OAAC-4QnH-vvXF-12Fc-EdRep3

--- Physical volume ---

PV Name /dev/sdc

VG Name ubuntu-vg

PV Size 15.00 GiB / not usable 4.00 MiB

Allocatable yes

PE Size 4.00 MiB

Total PE 3839

Free PE 3839

Allocated PE 0

PV UUID BgjRNz-7cjU-CpFe-6nNn-OxaV-OZUa-3dLsDh

lvm> pvmove /dev/sdc

No data to move for ubuntu-vg.

lvm> vgdisplay

--- Volume group ---

VG Name ubuntu-vg

System ID

Format lvm2

Metadata Areas 2

Metadata Sequence No 5

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 1

Open LV 1

Max PV 0

Cur PV 2

Act PV 2

VG Size 24.99 GiB

PE Size 4.00 MiB

Total PE 6398

Alloc PE / Size 1280 / 5.00 GiB

Free PE / Size 5118 / 19.99 GiB

VG UUID E2OrNE-p76Y-UwIl-NiQs-ozHJ-C8ZT-xc1Mqy

lvm> vgreduce ubuntu-vg /dev/sdc

Removed "/dev/sdc" from volume group "ubuntu-vg"

lvm>

lvm> vgdisplay

--- Volume group ---

VG Name ubuntu-vg

System ID

Format lvm2

Metadata Areas 1

Metadata Sequence No 6

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 1

Open LV 1

Max PV 0

Cur PV 1

Act PV 1

VG Size <10.00 GiB

PE Size 4.00 MiB

Total PE 2559

Alloc PE / Size 1280 / 5.00 GiB

Free PE / Size 1279 / <5.00 GiB

VG UUID E2OrNE-p76Y-UwIl-NiQs-ozHJ-C8ZT-xc1Mqy

lvm> pvdisplay

--- Physical volume ---

PV Name /dev/sdb

VG Name ubuntu-vg

PV Size 10.00 GiB / not usable 4.00 MiB

Allocatable yes

PE Size 4.00 MiB

Total PE 2559

Free PE 1279

Allocated PE 1280

PV UUID qaRqDq-0MmA-OAAC-4QnH-vvXF-12Fc-EdRep3

"/dev/sdc" is a new physical volume of "15.00 GiB"

--- NEW Physical volume ---

PV Name /dev/sdc

VG Name

PV Size 15.00 GiB

Allocatable NO

PE Size 0

Total PE 0

Free PE 0

Allocated PE 0

PV UUID BgjRNz-7cjU-CpFe-6nNn-OxaV-OZUa-3dLsDh

lvm> lvdisplay

--- Logical volume ---

LV Path /dev/ubuntu-vg/ubuntu-lv

LV Name ubuntu-lv

VG Name ubuntu-vg

LV UUID d4pPYZ-HwAx-w4wK-NzNr-xd2P-FXPp-fmLaYr

LV Write Access read/write

LV Creation host, time ubuntu, 2024-05-19 09:54:44 +0000

LV Status available

# open 1

LV Size 5.00 GiB

Current LE 1280

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:0

lvm>

lvm> lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert

ubuntu-lv ubuntu-vg -wi-ao---- 5.00g

lvm> pvs

PV VG Fmt Attr PSize PFree

/dev/sdb ubuntu-vg lvm2 a-- <10.00g <5.00g

/dev/sdc lvm2 --- 15.00g 15.00g

lvm> vgs

VG #PV #LV #SN Attr VSize VFree

ubuntu-vg 1 1 0 wz--n- <10.00g <5.00g

lvm>

ubuntu@ubuntu:/data$ sudo fdisk -l

Disk /dev/sda: 8 GiB, 8589934592 bytes, 16777216 sectors

Disk model: VBOX HARDDISK

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: gpt

Disk identifier: 534EB29B-2FE8-482C-BB79-8C98AE4D1174

Device Start End Sectors Size Type

/dev/sda1 2048 4095 2048 1M BIOS boot

/dev/sda2 4096 16775167 16771072 8G Linux filesystem

Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors

Disk model: VBOX HARDDISK

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/sdc: 15 GiB, 16106127360 bytes, 31457280 sectors

Disk model: VBOX HARDDISK

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 5 GiB, 5368709120 bytes, 10485760 sectors

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

ubuntu@ubuntu:/data$

ubuntu@ubuntu:/data$ sudo fdisk -l

Disk /dev/sda: 8 GiB, 8589934592 bytes, 16777216 sectors

Disk model: VBOX HARDDISK

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: gpt

Disk identifier: 534EB29B-2FE8-482C-BB79-8C98AE4D1174

Device Start End Sectors Size Type

/dev/sda1 2048 4095 2048 1M BIOS boot

/dev/sda2 4096 16775167 16771072 8G Linux filesystem

Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors

Disk model: VBOX HARDDISK

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 5 GiB, 5368709120 bytes, 10485760 sectors

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

ubuntu@ubuntu:/data$

Peringatan:

LVM memudahkan dalam peng-alokasi-an partisi/volume, mudah untuk di perbesar dan di perkecil ( expand - shrink ), kita dapat menambahkan storage menjadi satu volume sebanyak yg kita mau. walaupun begitu ada yg perlu di perhatikan.

  • LVM bukan penganti RAID
  • LVM tidak menambah performa kecepatan transfer. LVM berkerja sepert RAID 0
  • LVM tidak fault tolerance, dengan kata lain, jika salah satu disk dalam VG rusak maka kita akan kehilangan data atau mungkin malah kehilangan seluruh VG
  • Untuk mereduce LVM diperlukan unmount, oleh sebab itu disarakan Gunakan LVM diluar path default agar bisa di unmount on the fly
  • Gunakan LVM diatas RAID, dimana RAID sebagai Fault tolerance dapat memberikan ketangguhan system dari resiko data lost karena disk rusak/bad sector.

source:

https://ubuntu.com/server/docs/about-logical-volume-management-lvm

https://ubuntu.com/server/docs/how-to-manage-logical-volumes