Eu tenho a seguinte partição LVM:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/data-root 5.3G 4.2G 864M 84% /
...
/dev/mapper/data-install 6.8G 5.7G 783M 89% /install
# vgs
VG #PV #LV #SN Attr VSize VFree
data 1 2 0 wz--n- <12.50g 0
# vgdisplay
--- Volume group ---
VG Name data
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 <12.50 GiB
PE Size 4.00 MiB
Total PE 3199
Alloc PE / Size 3199 / <12.50 GiB
Free PE / Size 0 / 0
VG UUID jSACsC-wGwy-ki0w-nSCn-kxMy-bLOV-dVN68E
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 data lvm2 a-- <12.50g 0
# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name data
PV Size <12.50 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 3199
Free PE 0
Allocated PE 3199
PV UUID CPggVR-sUXw-4gfw-lb2v-cq0j-M5ey-Ct7td3
# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
install data -wi-ao---- 7.00g
root data -wi-ao---- <5.50g
# lvdisplay
--- Logical volume ---
LV Path /dev/data/install
LV Name install
VG Name data
LV UUID ZXQmp5-L17b-eQyS-g3An-msk7-Jqso-MTaTIw
LV Write Access read/write
LV Creation host, time localhost, 2018-09-28 14:42:43 +0000
LV Status available
open 1
LV Size 7.00 GiB
Current LE 1792
Segments 1
Allocation inherit
Read ahead sectors aut
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/data/root
LV Name root
VG Name data
LV UUID i3eMbC-rcm1-H2Gm-JJeF-jRxO-nL9h-toHSHQ
LV Write Access read/write
LV Creation host, time localhost, 2018-09-28 14:42:55 +0000
LV Status available
# open 1
LV Size <5.50 GiB
Current LE 1407
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
Estou removendo um dos volumes lógicos:
# umount /install
# lvremove /dev/data/install
# sed -i 'N;/\/dev\/mapper\/data-install/{s#/dev/mapper/data-install.*\n##}' /etc/fstab
Após a remoção:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/data-root 5.3G 4.2G 867M 84% /
...
# vgs
VG #PV #LV #SN Attr VSize VFre
data 1 1 0 wz--n- <12.50g 7.00g
# vgdisplay
--- Volume group ---
VG Name data
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
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 <12.50 GiB
PE Size 4.00 MiB
Total PE 3199
Alloc PE / Size 1407 / <5.50 GiB
Free PE / Size 1792 / 7.00 GiB
VG UUID jSACsC-wGwy-ki0w-nSCn-kxMy-bLOV-dVN68E
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 data lvm2 a-- <12.50g 7.00g
# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name data
PV Size <12.50 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 3199
Free PE 1792
Allocated PE 1407
PV UUID CPggVR-sUXw-4gfw-lb2v-cq0j-M5ey-Ct7td3
# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root data -wi-ao---- <5.50g
# lvdisplay
--- Logical volume ---
LV Path /dev/data/root
LV Name root
VG Name data
LV UUID i3eMbC-rcm1-H2Gm-JJeF-jRxO-nL9h-toHSHQ
LV Write Access read/write
LV Creation host, time localhost, 2018-09-28 14:42:55 +0000
LV Status available
# open 1
LV Size <5.50 GiB
Current LE 1407
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
Como posso reduzir o volume físico, o grupo de volume e, finalmente, a partição completamente, o que equivale ao espaço livre após a remoção do volume lógico? De preferência, isso deve ser feito especificando valores relativos (para pvresize
?) Ou algo semelhante a lvextend -l 100%FREE <lvolume>
. Também gostaria de realizar isso usando apenas a linha de comando (sem GUI). Também é importante notar que o volume lógico da raiz / sistema está ativo e em uso o tempo todo.