Skip to content

Instantly share code, notes, and snippets.

@gjreasoner
Last active November 10, 2024 14:36
Show Gist options
  • Save gjreasoner/4e93d8743b71babb58dcba4ee049247c to your computer and use it in GitHub Desktop.
Save gjreasoner/4e93d8743b71babb58dcba4ee049247c to your computer and use it in GitHub Desktop.
Expand Ubuntu 20 Proxmox Disk
# Resize the file system in UI, under VM -> Hardware -> Click on the disk to resize, click "Resize disk" button

# Confirm increase in disk space (1TB in my case)
$ lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                         8:0    0    1T  0 disk
├─sda1                      8:1    0    1M  0 part
├─sda2                      8:2    0    1G  0 part /boot
└─sda3                      8:3    0    1T  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0   31G  0 lvm  /

# Resize the partition
$ sudo parted
GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) resizepart 3 100%
(parted) quit
Information: You may need to update /etc/fstab.

# Extend the logical volume now
$ sudo lvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from <31.00 GiB (7935 extents) to 1.03 TiB (270079 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 132
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 276560896 (4k) blocks long.

# Resize the physical volume (may or may not need)
$ sudo pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized

# Confirm resize complete
$ lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                         8:0    0    1T  0 disk
├─sda1                      8:1    0    1M  0 part
├─sda2                      8:2    0    1G  0 part /boot
└─sda3                      8:3    0    1T  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0    1T  0 lvm  /
@jaredearle
Copy link

@egodigitus I also had to do that. Thanks for the help.

@johofer
Copy link

johofer commented May 2, 2022

@egodigitus thanks for the additional step
@gjrdiesel thank you for the writeup, worked perfectly

@alanop
Copy link

alanop commented May 12, 2022

Thanks a lot

@djonko
Copy link

djonko commented Jun 12, 2022

Thanks a lot

@Adrian016
Copy link

Adrian016 commented Jun 14, 2022

I found this solution and initially was unable to get it to run. As @egodigitus mentions, you may need to run the following command after parted.

$ sudo pvresize /dev/sda3

@gjreasoner
Copy link
Author

I found this solution and initially was unable to get it to run. As @egodigitus mentions, you may need to run the following command after parted.

$ sudo pvresize /dev/sda3
@Adrian016

I have updated the gist to now include the pvresize portion, thank you 👍

@vrenaudeau
Copy link

Thank you !

@binaryn3xus
Copy link

Thank you!

@p0zi
Copy link

p0zi commented Aug 6, 2022

I found this solution and initially was unable to get it to run. As @egodigitus mentions, you may need to run the following command after parted.
$ sudo pvresize /dev/sda3
@Adrian016

I have updated the gist to now include the pvresize portion, thank you +1

Hello, i think "sudo pvresize /dev/sda3" should be executed, as @Adrian016 wrote, after "sudo parted". At least only fixed order made effect. Since physical volume contains logical groups and those contains logical volumes.

@paulearley
Copy link

Wow. Saved my bacon after setting up a Ubuntu VM on Proxmox and forgetting to set partitions properly. Kept building complexity in the Ubuntu VM until I ran into the disk size wall. Saved me hours of work!

@Quezler
Copy link

Quezler commented Dec 10, 2022

thanks @gjrdiesel & @egodigitus 👍

@alexandrumihale
Copy link

Thanks, if only the internet showed up this as first results the world would be a better place 👍

@noonething
Copy link

Something I can finally reply to. Thank you!

@shes9610620
Copy link

Thanks!

@p6002
Copy link

p6002 commented Mar 18, 2023

Thanks, works!

@MrHatcherstone
Copy link

Thank you!

@oliparmenter
Copy link

Thanks

@emory
Copy link

emory commented Nov 19, 2023

just wanted to drop a high-five for your gist here. my plex media server VM was undersized for my combined library and i was getting the label on the vdisk right but the lvm piece was eluding my understanding until i got here.

now i have setup a filesystem cache for media via nfs to a filesystem on an ssd and enough disk space for metadata and previews so my kids will stop groaning that i'm rebooting the plex server and they say THANK YOU too <4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment