First in the VirtualBox increasing our storage in ubuntu.vdi SATA
First in the VirtualBox increasing our storage in ubuntu.vdi SATA
Then through CLI we follow these steps:
root@kmaster:/home/bberisha# df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 1970368 0 1970368 0% /dev
tmpfs 403088 1420 401668 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 20511312 19440400 5952 100% / =========> before extend
tmpfs 2015420 16 2015404 1% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 2015420 0 2015420 0% /sys/fs/cgroup
/dev/sda2 999320 206908 723600 23% /boot
/dev/loop0 101888 101888 0 100% /snap/core/11420
/dev/loop2 101760 101760 0 100% /snap/core/11316
/dev/loop3 56832 56832 0 100% /snap/core18/2074
/dev/loop1 56832 56832 0 100% /snap/core18/2066
/dev/loop4 63360 63360 0 100% /snap/core20/1081
/dev/loop5 238976 238976 0 100% /snap/google-cloud-sdk/191
/dev/loop6 240000 240000 0 100% /snap/google-cloud-sdk/192
/dev/loop7 101632 101632 0 100% /snap/juju/16808
/dev/loop8 10752 10752 0 100% /snap/helm/344
/dev/loop9 101888 101888 0 100% /snap/juju/16909
/dev/loop10 10752 10752 0 100% /snap/helm/350
/dev/loop11 141312 141312 0 100% /snap/maas/8724
/dev/loop12 14080 14080 0 100% /snap/maas-cli/13
/dev/loop13 216448 216448 0 100% /snap/microk8s/2361
/dev/loop14 33152 33152 0 100% /snap/snapd/12704
/dev/loop15 33152 33152 0 100% /snap/snapd/12398
/dev/loop17 317440 317440 0 100% /snap/multipass/5087
/dev/loop16 216448 216448 0 100% /snap/microk8s/2338
/dev/loop18 69248 69248 0 100% /snap/lxd/20326
/dev/loop19 10880 10880 0 100% /snap/kubectl/1976
/dev/loop20 72064 72064 0 100% /snap/lxd/21029
tmpfs 2015420 12 2015408 1% /var/snap/microk8s/common/var/lib/kubelet/pods/fbdf3f88-e237-46c1-9ad7-bf346edddb44/volumes/kubernetes.io~secret/calico-node-token-8p5kw
shm 65536 0 65536 0% /var/snap/microk8s/common/run/containerd/io.containerd.grpc.v1.cri/sandboxes/194793e668e57953f5b6e1ae83410318658d78fd76ba1f49c035e3000d5afd06/shm
overlay 20511312 19440400 5952 100% /var/snap/microk8s/common/run/containerd/io.containerd.runtime.v2.task/k8s.io/194793e668e57953f5b6e1ae83410318658d78fd76ba1f49c035e3000d5afd06/rootfs
overlay 20511312 19440400 5952 100% /var/snap/microk8s/common/run/containerd/io.containerd.runtime.v2.task/k8s.io/4d5a58aa80909f32f39abe71d474615033efc0a1f585834ca56c51b995388523/rootfs
tmpfs 403084 0 403084 0% /run/user/1000
root@kmaster:/home/bberisha#
root@kmaster:/home/bberisha# du -sm /dev/mapper/ubuntu--vg-ubuntu--lv
0 /dev/mapper/ubuntu--vg-ubuntu--lv
root@kmaster:/home/bberisha#
root@kmaster:/home/bberisha# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 99.4M 1 loop /snap/core/11420
loop1 7:1 0 55.4M 1 loop /snap/core18/2066
loop2 7:2 0 99.4M 1 loop /snap/core/11316
loop3 7:3 0 55.5M 1 loop /snap/core18/2074
loop4 7:4 0 61.8M 1 loop /snap/core20/1081
loop5 7:5 0 233.4M 1 loop /snap/google-cloud-sdk/191
loop6 7:6 0 234.4M 1 loop /snap/google-cloud-sdk/192
loop7 7:7 0 99.2M 1 loop /snap/juju/16808
loop8 7:8 0 10.5M 1 loop /snap/helm/344
loop9 7:9 0 99.5M 1 loop /snap/juju/16909
loop10 7:10 0 10.5M 1 loop /snap/helm/350
loop11 7:11 0 138M 1 loop /snap/maas/8724
loop12 7:12 0 13.7M 1 loop /snap/maas-cli/13
loop13 7:13 0 211.3M 1 loop /snap/microk8s/2361
loop14 7:14 0 32.3M 1 loop /snap/snapd/12704
loop15 7:15 0 32.3M 1 loop /snap/snapd/12398
loop16 7:16 0 211.3M 1 loop /snap/microk8s/2338
loop17 7:17 0 309.9M 1 loop /snap/multipass/5087
loop18 7:18 0 67.6M 1 loop /snap/lxd/20326
loop19 7:19 0 10.5M 1 loop /snap/kubectl/1976
loop20 7:20 0 70.3M 1 loop /snap/lxd/21029
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 29G 0 part
└─ubuntu--vg-ubuntu--lv 253:0 0 20G 0 lvm / ========> this lvm should be extended
sr0 11:0 1 58.2M 0 rom
root@kmaster:/home/bberisha#
root@kmaster:/home/bberisha# df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 1970368 0 1970368 0% /dev
tmpfs 403088 1420 401668 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 20511312 19431908 14444 100% /
tmpfs 2015420 16 2015404 1% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 2015420 0 2015420 0% /sys/fs/cgroup
/dev/sda2 999320 206908 723600 23% /boot
/dev/loop0 101888 101888 0 100% /snap/core/11420
/dev/loop2 101760 101760 0 100% /snap/core/11316
/dev/loop3 56832 56832 0 100% /snap/core18/2074
/dev/loop1 56832 56832 0 100% /snap/core18/2066
/dev/loop4 63360 63360 0 100% /snap/core20/1081
/dev/loop5 238976 238976 0 100% /snap/google-cloud-sdk/191
/dev/loop6 240000 240000 0 100% /snap/google-cloud-sdk/192
/dev/loop7 101632 101632 0 100% /snap/juju/16808
/dev/loop8 10752 10752 0 100% /snap/helm/344
/dev/loop9 101888 101888 0 100% /snap/juju/16909
/dev/loop10 10752 10752 0 100% /snap/helm/350
/dev/loop11 141312 141312 0 100% /snap/maas/8724
/dev/loop12 14080 14080 0 100% /snap/maas-cli/13
/dev/loop13 216448 216448 0 100% /snap/microk8s/2361
/dev/loop14 33152 33152 0 100% /snap/snapd/12704
/dev/loop15 33152 33152 0 100% /snap/snapd/12398
/dev/loop17 317440 317440 0 100% /snap/multipass/5087
/dev/loop16 216448 216448 0 100% /snap/microk8s/2338
/dev/loop18 69248 69248 0 100% /snap/lxd/20326
/dev/loop19 10880 10880 0 100% /snap/kubectl/1976
/dev/loop20 72064 72064 0 100% /snap/lxd/21029
tmpfs 2015420 12 2015408 1% /var/snap/microk8s/common/var/lib/kubelet/pods/fbdf3f88-e237-46c1-9ad7-bf346edddb44/volumes/kubernetes.io~secret/calico-node-token-8p5kw
shm 65536 0 65536 0% /var/snap/microk8s/common/run/containerd/io.containerd.grpc.v1.cri/sandboxes/194793e668e57953f5b6e1ae83410318658d78fd76ba1f49c035e3000d5afd06/shm
overlay 20511312 19431908 14444 100% /var/snap/microk8s/common/run/containerd/io.containerd.runtime.v2.task/k8s.io/194793e668e57953f5b6e1ae83410318658d78fd76ba1f49c035e3000d5afd06/rootfs
overlay 20511312 19431908 14444 100% /var/snap/microk8s/common/run/containerd/io.containerd.runtime.v2.task/k8s.io/4d5a58aa80909f32f39abe71d474615033efc0a1f585834ca56c51b995388523/rootfs
tmpfs 403084 0 403084 0% /run/user/1000
root@kmaster:/home/bberisha#
root@kmaster:/home/bberisha# fdisk /dev/sda
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
GPT PMBR size mismatch (62914559 != 104857599) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Command (m for help): p
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
Disk model: VBOX HARDDISK
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: 62558D9C-BB3D-43CA-84E4-BB61832BC47D
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 62912511 60811264 29G Linux filesystem
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/sda: 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
62912512 104857566 41945055 20G
Command (m for help): d
Partition number (1-3, default 3): >>ENTER
Partition 3 has been deleted.
Command (m for help): n
Partition number (3-128, default 3): >>ENTER
First sector (2101248-104857566, default 2101248): >>ENTER
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2101248-104857566, default 104857566): >>just ENTER to take entire storage
Created a new partition 3 of type 'Linux filesystem' and of size 49 GiB.
Partition #3 contains a LVM2_member signature.
Do you want to remove the signature? [Y]es/[N]o: no
Command (m for help): p
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
Disk model: VBOX HARDDISK
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: 62558D9C-BB3D-43CA-84E4-BB61832BC47D
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 104857566 102756319 49G Linux filesystem
Command (m for help): w
The partition table has been altered.
Syncing disks.
root@kmaster:/home/bberisha# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 99.4M 1 loop /snap/core/11420
loop1 7:1 0 55.4M 1 loop /snap/core18/2066
loop2 7:2 0 99.4M 1 loop /snap/core/11316
loop3 7:3 0 55.5M 1 loop /snap/core18/2074
loop4 7:4 0 61.8M 1 loop /snap/core20/1081
loop5 7:5 0 233.4M 1 loop /snap/google-cloud-sdk/191
loop6 7:6 0 234.4M 1 loop /snap/google-cloud-sdk/192
loop7 7:7 0 99.2M 1 loop /snap/juju/16808
loop8 7:8 0 10.5M 1 loop /snap/helm/344
loop9 7:9 0 99.5M 1 loop /snap/juju/16909
loop10 7:10 0 10.5M 1 loop /snap/helm/350
loop11 7:11 0 138M 1 loop /snap/maas/8724
loop12 7:12 0 13.7M 1 loop /snap/maas-cli/13
loop13 7:13 0 211.3M 1 loop /snap/microk8s/2361
loop14 7:14 0 32.3M 1 loop /snap/snapd/12704
loop15 7:15 0 32.3M 1 loop /snap/snapd/12398
loop16 7:16 0 211.3M 1 loop /snap/microk8s/2338
loop17 7:17 0 309.9M 1 loop /snap/multipass/5087
loop18 7:18 0 67.6M 1 loop /snap/lxd/20326
loop19 7:19 0 10.5M 1 loop /snap/kubectl/1976
loop20 7:20 0 70.3M 1 loop /snap/lxd/21029
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 49G 0 part ==========> after
└─ubuntu--vg-ubuntu--lv 253:0 0 20G 0 lvm /
sr0 11:0 1 58.2M 0 rom
root@kmaster:/home/bberisha#
Now we need to resize the filesystem
Modify (extend) the LVM:
Tell LVM the physical partition size has changed: sudo pvresize /dev/sda3
Find the actual path of the LVM logical volume: sudo lvdisplay – The LV Path is the value needed
Tell LVM to extend the logical volume to use all of the new partition size: sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv – Using the LV Path from above
root@kmaster:/home/bberisha# sudo lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID 0JJp0S-aB6Y-PgC3-NJ43-Kl5W-Tvwq-u0nnLw
LV Write Access read/write
LV Creation host, time ubuntu-server, 2021-06-05 22:10:18 +0000
LV Status available
# open 1
LV Size <22.25 GiB
Current LE 5695
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
root@kmaster:/home/bberisha# lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <22.25 GiB (5695 extents) to <49.00 GiB (12543 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
root@kmaster:/home/bberisha#
Resize the file system:
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
Now, when you run sudo fdisk -l, it will show that the LVM is using all of the space on the physical disk!
Now lvm is extendet and have 41% used:
/dev/mapper/ubuntu--vg-ubuntu--lv 50438688 19492556 28644048 41% /
root@kmaster:/home/bberisha# parted /dev/sda3 print
Error: /dev/sda3: unrecognised disk label
Model: Unknown (unknown)
Disk /dev/sda3: 52.6GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags: