Expand Linux volume to utilize allotted space on VM
by CardinalGasBag from LinuxQuestions.org on (#6FBBR)
Hello, I am hoping to get some help with an issue I'm having with an Ubuntu 22.04.3 VM running in VMWare. It initially was allocated 80GB HD space in VMWare, but I started getting low disk space alerts in the application (Zabbix) and I noticed that /dev/mapper/ubuntu--vg-ubuntu--lv was only showing 39G total size.
Code:administrator@cf-zabbix:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 794M 1.2M 793M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 39G 34G 2.5G 94% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 251M 1.6G 14% /boot
tmpfs 794M 4.0K 794M 1% /run/user/1000I was able to expand it out to use the full 80GB:
Code:administrator@cf-zabbix:~$ sudo lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <39.00 GiB (9983 extents) to <78.00 GiB (19967 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
administrator@cf-zabbix:~$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 10
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 20446208 (4k) blocks long.
administrator@cf-zabbix:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 794M 1.2M 793M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 77G 35G 39G 48% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 251M 1.6G 14% /boot
tmpfs 794M 4.0K 794M 1% /run/user/1000In order to be proactive, I doubled the VM disk size from 80 to 160G, but using the same as the above commands again, I don't seem to be able to expand the size of /dev/mapper/ubuntu--vg-ubuntu--lv from 80 to 160G:
Code:administrator@cf-zabbix:~$ sudo lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
New size (19967 extents) matches existing size (19967 extents).
administrator@cf-zabbix:~$ sudo sudo lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
New size (19967 extents) matches existing size (19967 extents).
administrator@cf-zabbix:~$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.46.5 (30-Dec-2021)
The filesystem is already 20446208 (4k) blocks long. Nothing to do!
administrator@cf-zabbix:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 794M 1.2M 793M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 77G 35G 39G 48% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 251M 1.6G 14% /boot
tmpfs 794M 4.0K 794M 1% /run/user/1000I do see the 160G showing up under /dev/sda, I'm just not sure what I need to do to use this for /dev/mapper/ubuntu--vg-ubuntu--lv.
Code:administrator@cf-zabbix:~$ sudo fdisk -l
Disk /dev/loop0: 63.45 MiB, 66531328 bytes, 129944 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/loop1: 111.95 MiB, 117387264 bytes, 229272 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/loop2: 63.46 MiB, 66547712 bytes, 129976 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/loop3: 53.26 MiB, 55844864 bytes, 109072 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/loop4: 40.84 MiB, 42827776 bytes, 83648 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
GPT PMBR size mismatch (167772159 != 335544319) will be corrected by write.
The backup GPT table is not on the end of the device.
Disk /dev/sda: 160 GiB, 171798691840 bytes, 335544320 sectors
Disk model: Virtual disk
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: AF7D201F-6D8E-4170-97E5-A355BDB1BB73
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 4198399 4194304 2G Linux filesystem
/dev/sda3 4198400 167770111 163571712 78G Linux filesystem
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 78 GiB, 83747667968 bytes, 163569664 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesTIA!
Code:administrator@cf-zabbix:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 794M 1.2M 793M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 39G 34G 2.5G 94% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 251M 1.6G 14% /boot
tmpfs 794M 4.0K 794M 1% /run/user/1000I was able to expand it out to use the full 80GB:
Code:administrator@cf-zabbix:~$ sudo lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <39.00 GiB (9983 extents) to <78.00 GiB (19967 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
administrator@cf-zabbix:~$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 10
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 20446208 (4k) blocks long.
administrator@cf-zabbix:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 794M 1.2M 793M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 77G 35G 39G 48% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 251M 1.6G 14% /boot
tmpfs 794M 4.0K 794M 1% /run/user/1000In order to be proactive, I doubled the VM disk size from 80 to 160G, but using the same as the above commands again, I don't seem to be able to expand the size of /dev/mapper/ubuntu--vg-ubuntu--lv from 80 to 160G:
Code:administrator@cf-zabbix:~$ sudo lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
New size (19967 extents) matches existing size (19967 extents).
administrator@cf-zabbix:~$ sudo sudo lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
New size (19967 extents) matches existing size (19967 extents).
administrator@cf-zabbix:~$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.46.5 (30-Dec-2021)
The filesystem is already 20446208 (4k) blocks long. Nothing to do!
administrator@cf-zabbix:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 794M 1.2M 793M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 77G 35G 39G 48% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 251M 1.6G 14% /boot
tmpfs 794M 4.0K 794M 1% /run/user/1000I do see the 160G showing up under /dev/sda, I'm just not sure what I need to do to use this for /dev/mapper/ubuntu--vg-ubuntu--lv.
Code:administrator@cf-zabbix:~$ sudo fdisk -l
Disk /dev/loop0: 63.45 MiB, 66531328 bytes, 129944 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/loop1: 111.95 MiB, 117387264 bytes, 229272 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/loop2: 63.46 MiB, 66547712 bytes, 129976 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/loop3: 53.26 MiB, 55844864 bytes, 109072 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/loop4: 40.84 MiB, 42827776 bytes, 83648 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
GPT PMBR size mismatch (167772159 != 335544319) will be corrected by write.
The backup GPT table is not on the end of the device.
Disk /dev/sda: 160 GiB, 171798691840 bytes, 335544320 sectors
Disk model: Virtual disk
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: AF7D201F-6D8E-4170-97E5-A355BDB1BB73
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 4198399 4194304 2G Linux filesystem
/dev/sda3 4198400 167770111 163571712 78G Linux filesystem
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 78 GiB, 83747667968 bytes, 163569664 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesTIA!