martedì 31 gennaio 2023

UBUNTU - Extend LVM Partition

Issue


Few months ago I installed Ubuntu on my MAC M1 apple Silicon to practice with a K8s LAB. I proceeded with a simple installation (for beginner) leaving any options set by default, choosing to use the entire disk (30 GB). I made up my configuration, set up minikube, realized some YAML file (just to test some environment in K8s), than weeks later upgraded the kernel .... and now a warnig telling me that I have terminated the space .... what the hell ... how i did?
Watching better the output of the "df -h" command, I realized that the size of the disk wasn't as expected.

Solution


During the initial installation phase I didn't pay to much attention on how the disk was really partitioned.
Let's perform a couple of commands to be sure on the real size of the disk.

lorenzo@ubuntu:~$ sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL

lorenzo@ubuntu:~$ sudo fdisk -l

Verified that we have the original 30GB disk and space not allocated, what we have to do is to extend or resize the LVM partition to the available free space with the lvextend command.
Let's proceed by steps:
  1. Locate the partition to extend running the "df -h" command. We have seen that in our case is the root "/" (93% Used).
  2. With the following command, let's check in the volume group where are the free space:
    root@ubuntu:~# vgdisplay
  3. Let's run the below lvextend command to extend the file system.
    root@ubuntu:~# lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
  4. With previous lvextend command we have extended the file system to use 100% of the free space availabe, but still the file system is not updated untill we execute the following resize2fs command:
    root@ubuntu:~# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
  5. Last but not least, check that the space has been expanded as desired, performing "df -h" command again.

That's it.

Nessun commento:

Posta un commento