preface
I have to learn some usage about lvm on linux, so this is my notice about this. But this is not complete.
extend volume in existing lv
sudo lvdisplay
[sudo] password for debian-buildd:
Sorry, try again.
[sudo] password for debian-buildd:
--- Logical volume ---
LV Path /dev/vg0/swap
LV Name swap
VG Name vg0
LV UUID hmY5Dt-S0GH-wxrN-fE9M-BwU9-bFMP-j2e05Z
LV Write Access read/write
LV Creation host, time unmatched05, 2022-08-10 21:43:43 +0800
LV Status available
# open 2
LV Size 100.00 GiB
Current LE 25600
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
--- Logical volume ---
LV Path /dev/vg0/srv
LV Name srv
VG Name vg0
LV UUID T8nIYl-WdwX-hfYr-Yg3N-FiD1-7M1j-R54cGN
LV Write Access read/write
LV Creation host, time unmatched05, 2022-08-10 21:43:43 +0800
LV Status available
# open 1
LV Size 40.00 GiB
Current LE 10240
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
This is to check lv (logical volume) for existing lv.
sudo vgdisplay
--- Volume group ---
VG Name vg0
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 1.80 TiB
PE Size 4.00 MiB
Total PE 472163
Alloc PE / Size 35840 / 140.00 GiB
Free PE / Size 436323 / 1.66 TiB
VG UUID VCkz6D-Di19-Oh0a-GtaN-d9Th-sAqQ-ODNswr
This is vg (volume group) info. I think it can give you a picture of whole disk from lvm’s view.
From above info, you will get the information about lv with its path.
sudo lvextend -L +200G /dev/vg0/srv
Size of logical volume vg0/srv changed from 40.00 GiB (10240 extents) to 240.00 GiB (61440 extents).
Logical volume vg0/srv successfully resized.
The command is to extend
lv with path.
debian-buildd@unmatched05:~$ sudo resize2fs /dev/vg0/srv
resize2fs 1.46.6-rc1 (12-Sep-2022)
Filesystem at /dev/vg0/srv is mounted on /srv; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 30
The filesystem on /dev/vg0/srv is now 62914560 (4k) blocks long.
Using resize2fs
to resize fs.
Verity again:
debian-buildd@unmatched05:~$ df -h /srv
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg0-srv 236G 479M 226G 1% /srv