Menghapus local-lvm dan menggunakan seluruh disk untuk root pada Proxmox VE

Hi…

Kali ini saya akan mencoba untuk menghapus local-lvm yang ada pada proxmox dan menggunakan seluruh disk untuk root.

Hal ini bermula dari request dari teman, karena local-lvm pada proxmox tidak bisa digunakan untuk menyimpan iso, backup dan template. Hanya bisa menyimpan disk dari VM atau container.

Setiap kali install proxmox, secara default maka storage akan dibuat menjadi 2, yaitu local dan local-lvm

Langsung saja ya…

Cek dulu seluruh disk dari Command line

root@test1:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 395M 5.6M 389M 2% /run
/dev/mapper/pve-root 25G 1.4G 22G 6% /
tmpfs 2.0G 43M 1.9G 3% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/fuse 30M 16K 30M 1% /etc/pve
tmpfs 395M 0 395M 0% /run/user/0

root@test1:~# fdisk -l
Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 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
Disklabel type: gpt
Disk identifier: 77106504-0400-4CFA-9B8E-39FED25E3BDF

Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 528383 524288 256M EFI System
/dev/sda3 528384 209715166 209186783 99.8G Linux LVM

Disk /dev/mapper/pve-swap: 4 GiB, 4294967296 bytes, 8388608 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

Disk /dev/mapper/pve-root: 24.8 GiB, 26575110144 bytes, 51904512 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

Cek LVM yang ada, ada 3 yaitu swap, root dan data. Root untuk system/local storage dan Data untuk Local-lvm

root@test1:~# lvdisplay
--- Logical volume ---
LV Path /dev/pve/swap
LV Name swap
VG Name pve
LV UUID XF0s3T-bAx6-19Jo-mCXD-uMDy-mtJU-5vYewD
LV Write Access read/write
LV Creation host, time proxmox, 2018-12-28 14:04:27 +0700
LV Status available
# open 2
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Path /dev/pve/root
LV Name root
VG Name pve
LV UUID gNxUs3-gd9K-DLSS-bgAh-ng0K-ZHtX-zjXxTz
LV Write Access read/write
LV Creation host, time proxmox, 2018-12-28 14:04:27 +0700
LV Status available
# open 1
LV Size 24.75 GiB
Current LE 6336
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

--- Logical volume ---
LV Name data
VG Name pve
LV UUID bjS0kv-Jtw0-8RjY-yJ5K-27Zh-WzjC-9gkaZd
LV Write Access read/write
LV Creation host, time proxmox, 2018-12-28 14:04:27 +0700
LV Pool metadata data_tmeta
LV Pool data data_tdata
LV Status available
# open 0
LV Size 56.62 GiB
Allocated pool data 0.00%
Allocated metadata 0.03%
Current LE 14495
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:4

Pertama hapus storage local-lvm dari dashboard Proxmox

Setelah hapus dari dashboard, hapus lvm data melalui CLI

root@test1:~# lvremove /dev/pve/data
Do you really want to remove and DISCARD active logical volume pve/data? [y/n]: y
Logical volume "data" successfully removed

Kemudian, resize lvm root untuk dapat menggunakan seluruh kapasitas disk

root@test1:~# lvresize /dev/pve/root /dev/sda3
Size of logical volume pve/root changed from 24.75 GiB (6336 extents) to 95.75 GiB (24511 extents).
Logical volume pve/root successfully resized.

Selanjutnya cek lvm yang ada, setelah hapus lvm data dan resize root

root@test1:~# lvdisplay
--- Logical volume ---
LV Path /dev/pve/swap
LV Name swap
VG Name pve
LV UUID XF0s3T-bAx6-19Jo-mCXD-uMDy-mtJU-5vYewD
LV Write Access read/write
LV Creation host, time proxmox, 2018-12-28 14:04:27 +0700
LV Status available
# open 2
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Path /dev/pve/root
LV Name root
VG Name pve
LV UUID gNxUs3-gd9K-DLSS-bgAh-ng0K-ZHtX-zjXxTz
LV Write Access read/write
LV Creation host, time proxmox, 2018-12-28 14:04:27 +0700
LV Status available
# open 1
LV Size 95.75 GiB
Current LE 24511
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

LVM root sudah bertambah kapasitasnya, selanjutnya resize storage local

root@test1:~# resize2fs /dev/mapper/pve-root
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/mapper/pve-root is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 12
The filesystem on /dev/mapper/pve-root is now 25099264 (4k) blocks long.

Cek kapasitas storage local dari CLI dan dashboard

root@test1:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 395M 5.6M 389M 2% /run
/dev/mapper/pve-root 95G 1.4G 89G 2% /
tmpfs 2.0G 43M 1.9G 3% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/fuse 30M 16K 30M 1% /etc/pve
tmpfs 395M 0 395M 0% /run/user/0