Ubuntu uses LVM to manage disk. Here is an example of how to expand disk space in which the FortiClient EMS server running on the ESXi server.

Change the size of the virtual machine's hard disk:
- Log in to ESXi.
- Select the virtual machine.
- Select Edit.
- Change the size of the Hard Disk and Increase disk size from 25G to 45G.
- Select 'Save'.
Expand disk in EMS server:
# df -T Filesystem Type Size Used Avail Use% Mounted on tmpfs tmpfs 197M 1.3M 196M 1% /run /dev/mapper/ubuntu--vg-ubuntu--lv ext4 20G 18G 1.2G 94% / <----- Show 20G. tmpfs tmpfs 982M 1.3M 981M 1% /dev/shm tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock /dev/vda2 ext4 974M 253M 654M 28% /boot tmpfs tmpfs 197M 4.0K 197M 1% /run/user/1000
# fdisk -l Disk /dev/loop0: 55.38 MiB, 58073088 bytes, 113424 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: 55.66 MiB, 58363904 bytes, 113992 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: 91.88 MiB, 96346112 bytes, 188176 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: 63.95 MiB, 67051520 bytes, 130960 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: 67.75 MiB, 71041024 bytes, 138752 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/loop5: 38.83 MiB, 40714240 bytes, 79520 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 (52428799 != 94371839) will be corrected by write. The backup GPT table is not on the end of the device.
Disk /dev/vda: 45 GiB, 48318382080 bytes, 94371840 sectors <----- Show 45G. 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: 11A769E4-8B08-4155-B11E-12CA9047A878
Device Start End Sectors Size Type /dev/vda1 2048 4095 2048 1M BIOS boot /dev/vda2 4096 2101247 2097152 1G Linux filesystem /dev/vda3 2101248 52426751 50325504 24G Linux filesystem <----- Show 24G.
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 20 GiB, 21474836480 bytes, 41943040 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
# fdisk /dev/vda
Welcome to fdisk (util-linux 2.37.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
GPT PMBR size mismatch (52428799 != 94371839) will be corrected by write. The backup GPT table is not on the end of the device. This problem will be corrected by write. This disk is currently in use - repartitioning is probably a bad idea. It's recommended to umount all file systems, and swapoff all swap partitions on this disk.
Command (m for help): m
Help:
GPT M enter protective/hybrid MBR
Generic d delete a partition F list free unpartitioned space l list known partition types n add a new partition p print the partition table t change a partition type v verify the partition table i print information about a partition
Misc m print this menu x extra functionality (experts only)
Script I load disk layout from sfdisk script file O dump disk layout to sfdisk script file
Save & Exit w write table to disk and exit q quit without saving changes
Create a new label g create a new empty GPT partition table G create a new empty SGI (IRIX) partition table o create a new empty DOS partition table s create a new empty Sun partition table
Command (m for help): F
Unpartitioned space /dev/vda: 20 GiB, 21475868160 bytes, 41945055 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes
Start End Sectors Size 52426752 94371806 41945055 20G
Command (m for help): n Partition number (4-128, default 4): 4 First sector (52426752-94371806, default 52426752): 52426752 Last sector, +/-sectors or +/-size{K,M,G,T,P} (52426752-94371806, default 94371806): 94371806
Created a new partition 4 of type 'Linux filesystem' and of size 20 GiB.
Command (m for help): w The partition table has been altered. Syncing disks.
# fdisk -l Disk /dev/loop0: 55.38 MiB, 58073088 bytes, 113424 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: 55.66 MiB, 58363904 bytes, 113992 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: 91.88 MiB, 96346112 bytes, 188176 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: 63.95 MiB, 67051520 bytes, 130960 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: 67.75 MiB, 71041024 bytes, 138752 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/loop5: 38.83 MiB, 40714240 bytes, 79520 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/vda: 45 GiB, 48318382080 bytes, 94371840 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: 11A769E4-8B08-4155-B11E-12CA9047A878
Device Start End Sectors Size Type /dev/vda1 2048 4095 2048 1M BIOS boot /dev/vda2 4096 2101247 2097152 1G Linux filesystem /dev/vda3 2101248 52426751 50325504 24G Linux filesystem /dev/vda4 52426752 94371806 41945055 20G Linux filesystem <----- Expand 20G.
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 20 GiB, 21474836480 bytes, 41943040 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
# pvdisplay --- Physical volume --- PV Name /dev/vda3 VG Name ubuntu-vg PV Size <24.00 GiB / not usable 0 Allocatable yes PE Size 4.00 MiB Total PE 6143 Free PE 1023 Allocated PE 5120 PV UUID 6Xm7UO-uhhE-rdqB-73zY-C5zB-BeB8-9whA5j
# pvcreate /dev/vda4 Physical volume "/dev/vda4" successfully created.
# pvdisplay --- Physical volume --- PV Name /dev/vda3 VG Name ubuntu-vg PV Size <24.00 GiB / not usable 0 Allocatable yes PE Size 4.00 MiB Total PE 6143 Free PE 1023 Allocated PE 5120 PV UUID 6Xm7UO-uhhE-rdqB-73zY-C5zB-BeB8-9whA5j
"/dev/vda4" is a new physical volume of "20.00 GiB" --- NEW Physical volume --- PV Name /dev/vda4 VG Name PV Size 20.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID ZnECe9-X2VQ-qNNg-5z3K-vOJo-ka43-0RTv1e
# vgdisplay --- Volume group --- VG Name ubuntu-vg 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 <24.00 GiB PE Size 4.00 MiB Total PE 6143 Alloc PE / Size 5120 / 20.00 GiB Free PE / Size 1023 / <4.00 GiB VG UUID oFuZWf-DFkF-Al2m-qXPZ-BP3g-N8NO-fgSVU1
# vgextend ubuntu-vg /dev/vda4 Volume group "ubuntu-vg" successfully extended
# pvdisplay --- Physical volume --- PV Name /dev/vda3 VG Name ubuntu-vg PV Size <24.00 GiB / not usable 0 Allocatable yes PE Size 4.00 MiB Total PE 6143 Free PE 1023 Allocated PE 5120 PV UUID 6Xm7UO-uhhE-rdqB-73zY-C5zB-BeB8-9whA5j
--- Physical volume --- PV Name /dev/vda4 VG Name ubuntu-vg PV Size 20.00 GiB / not usable 4.98 MiB Allocatable yes PE Size 4.00 MiB Total PE 5119 Free PE 5119 Allocated PE 0 PV UUID ZnECe9-X2VQ-qNNg-5z3K-vOJo-ka43-0RTv1e
# 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 43.99 GiB PE Size 4.00 MiB Total PE 11262 Alloc PE / Size 5120 / 20.00 GiB Free PE / Size 6142 / 23.99 GiB VG UUID oFuZWf-DFkF-Al2m-qXPZ-BP3g-N8NO-fgSVU1
# lvdisplay --- Logical volume --- LV Path /dev/ubuntu-vg/ubuntu-lv LV Name ubuntu-lv VG Name ubuntu-vg LV UUID QWZQRo-kZWx-hlqb-uwCQ-CkQB-UZH1-w98wiC LV Write Access read/write LV Creation host, time ubuntu-server, 2021-01-15 01:50:28 +1100 LV Status available # open 1 LV Size 20.00 GiB Current LE 5120 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
# lvresize -l +6142 /dev/mapper/ubuntu--vg-ubuntu--lv Size of logical volume ubuntu-vg/ubuntu-lv changed from 20.00 GiB (5120 extents) to 43.99 GiB (11262 extents). Logical volume ubuntu-vg/ubuntu-lv successfully resized.
# lvdisplay --- Logical volume --- LV Path /dev/ubuntu-vg/ubuntu-lv LV Name ubuntu-lv VG Name ubuntu-vg LV UUID QWZQRo-kZWx-hlqb-uwCQ-CkQB-UZH1-w98wiC LV Write Access read/write LV Creation host, time ubuntu-server, 2021-01-15 01:50:28 +1100 LV Status available # open 1 LV Size 43.99 GiB Current LE 11262 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
# 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 = 3, new_desc_blocks = 6 The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 11532288 (4k) blocks long.
# df -Th Filesystem Type Size Used Avail Use% Mounted on tmpfs tmpfs 197M 1.3M 196M 1% /run /dev/mapper/ubuntu--vg-ubuntu--lv ext4 44G 18G 24G 43% / <----- Increase to 44G. tmpfs tmpfs 982M 1.3M 981M 1% /dev/shm tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock /dev/vda2 ext4 974M 253M 654M 28% /boot tmpfs tmpfs 197M 4.0K 197M 1% /run/user/1000
Related article:
Technical Tip: Increasing Linux disk space for FortiClient EMS running on Ubuntu 22.04 LTS
|