1. Increase space of disk using VM player option
Increased from 20 GB to 25 GB
2. Start VM image
3. Check the disk space
ubuntu@oktest:~$ sudo fdisk -l
Disk /dev/sda: 25 GiB, 26843545600 bytes, 52428800 sectors
Disk model: VMware Virtual S
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: F036E5A6-57F5-4AB8-8E22-2D4EAE295D62
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 2101247 2097152 1G Linux filesystem
/dev/sda3 2101248 41940991 39839744 19G Linux filesystem
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 19 GiB, 20396900352 bytes, 39837696 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
Current disk space is only 19 GB . It need to increase to 25 GB
4. Create new dummy disk to attach to volume
ubuntu@oktest:~$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
GPT PMBR size mismatch (41943039 != 52428799) will be corrected by write.
Command (m for help): n
Partition number (4-128, default 4):
First sector (41940992-52428766, default 41940992):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (41940992-52428766, default 52428766):
Created a new partition 4 of type 'Linux filesystem' and of size 5 GiB.
Command (m for help): t
Partition number (1-4, default 4): 4
Partition type or alias (type L to list all): 8e
Type of partition 4 is unchanged: Linux filesystem.
Command (m for help):w
The partition table has been altered.
Syncing disks.
8e is for linux
5. After writing reboot the VM
ubuntu@oktest:~$ sudo reboot
Connection to 192.168.132.132 closed by remote host.
Connection to 192.168.132.132 closed.
sterin@sterin-thinkpad:~$ ssh -l ubuntu 192.168.132.132
ubuntu@192.168.132.132's password:
Welcome to Ubuntu 21.04 (GNU/Linux 5.11.0-36-generic x86_64)
6. pvcreate
ubuntu@oktest:~$ sudo pvcreate /dev/sda4
[sudo] password for ubuntu:
Physical volume "/dev/sda4" successfully created.
7. Get volume details
ubuntu@oktest:~$ sudo vgdisplay
--- Volume group ---
VG Name ubuntu-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
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 <19.00 GiB
PE Size 4.00 MiB
Total PE 4863
Alloc PE / Size 4863 / <19.00 GiB
Free PE / Size 0 / 0
VG UUID c77G0M-adxg-UXNw-FOGC-pnyH-RXkW-PY4LAN
8. Extend the volume
ubuntu@oktest:~$ sudo vgextend ubuntu-vg /dev/sda4
Volume group "ubuntu-vg" successfully extended
9. LV path
ubuntu@oktest:~$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID KZD61K-RS0V-MZ2L-2j3J-sR1w-LPSS-R88Arg
LV Write Access read/write
LV Creation host, time ubuntu-server, 2021-09-25 15:37:47 +0000
LV Status available
# open 1
LV Size <19.00 GiB
Current LE 4863
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
10. Extend the volume , by attaching new sda4
ubuntu@oktest:~$ sudo lvextend /dev/ubuntu-vg/ubuntu-lv /dev/sda4
Size of logical volume ubuntu-vg/ubuntu-lv changed from <19.00 GiB (4863 extents) to 23.99 GiB (6142 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
11. resize
ubuntu@oktest:~$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.45.7 (28-Jan-2021)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 3
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 6289408 (4k) blocks long.
12. check new size
ubuntu@oktest:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 793M 1.7M 791M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 24G 16G 7.1G 69% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
/dev/sda2 976M 130M 780M 15% /boot
overlay 24G 16G 7.1G 69% /var/lib/docker/overlay2/cee83ea550ff578659803d97c911c2d0b5053fb1881d335fa630e609a41f52f1/merged
shm 64M 16K 64M 1% /var/lib/docker/containers/c3969a253df470b33fe4814443059ac9b7d398a345b81972705449806ef3494e/mounts/shm
tmpfs 793M 4.0K 793M 1% /run/user/1000