Resize the root partition of Ubuntu 20.04 with an lvm partition

24,937

Solution 1

Finally, I found it by checking this post: https://www.linuxtechi.com/extend-lvm-partitions/

The idea is to extend the lvm partition to take advantage of the empty space.

Solution 2

The solution provided in the link Riad shared worked for me. However, I'm summing up the steps here in case the link breaks:

  1. use df -h /home/ or df -lh / to check your filesystem space and name. There you can see if there is still space, the name of the mount, etc.

  2. use vgdisplay <thevgname> to display the volume name and details. There you can see VG size (total size), Allocated (used) and Free space. The free space hints on how much you could expand your partition.

  3. use lvextend -L +2G /thename/of/filesystem to extend the size the partition. In this example it was increased by 2Gb... edit this part according to your needs.

  4. the, use resize2fs /thename/of/filesystem to actually expand the used space.

  5. check again with df -l to see the changes done.

Addendum:

Doing similar stuff (resizing, etc) I stumbled with another case, where cfdisk and lsblk did show that my /sda3 had enough size, but happened that my Physical Volume (PV) still needed to be resized.

For that this answer helped me, which suggested to do:

sudo psv

To find the PV name (like /dev/sd3), and then resize it using sudo pvresize /dev/sda3. Modify according to your needs and volume names. I then was able to continue with the steps listed on this answer and proceed with lvextend and later resize2fs

Share:
24,937
Riad C
Author by

Riad C

Updated on September 18, 2022

Comments

  • Riad C
    Riad C over 1 year

    I installed ubuntu 20.04 server recently, and used lvm for partitioning. Here is the output of the command lsblk:

    NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    loop0                       7:0    0 29.9M  1 loop /snap/snapd/8542
    loop1                       7:1    0   55M  1 loop /snap/core18/1880
    loop2                       7:2    0 71.3M  1 loop /snap/lxd/16099
    loop3                       7:3    0 29.9M  1 loop /snap/snapd/8790
    loop4                       7:4    0 55.3M  1 loop /snap/core18/1885
    loop5                       7:5    0 70.6M  1 loop /snap/lxd/16922
    sda                         8:0    0  1.8T  0 disk 
    ├─sda1                      8:1    0    1M  0 part 
    ├─sda2                      8:2    0    1G  0 part /boot
    └─sda3                      8:3    0  1.8T  0 part 
      └─ubuntu--vg-ubuntu--lv 253:0    0  200G  0 lvm  /
    sr0                        11:0    1 1024M  0 rom  
    sr1                        11:1    1 1024M  0 rom  
    

    I am using Nextcloud that is storing information just in the root, is there a way to transfer the sda3 part to the / partition?

    Or should I do a fresh install of the system, and if so, can someone point me on how to use all the 1.8Tb for the root partition?

  • DarkCygnus
    DarkCygnus about 2 years
    Thanks for the Link! Although it's better if you posted here the steps in case the link breaks.