The purpose of this article is to extend the Ubuntu disk space. This article will focus on Ubuntu 24.04 LTS, but can likely be used on other Ubuntu versions. You have likely discovered this article because you created a new VM (Virtual Machine) based off of a template and in the creation of the VM the disk space was set to an amount higher than the template. Alternatively you may have discovered this article because you ran out of disk space, added more disk space in your VMWare (or other) instance, and need to apply the new disk space to the server. Either way, this article should help you extend the disk space in your Ubuntu server. These instructions are based on Ubuntu 24.04 and should not be used for production until thoroughly tested on a dev server. Backups should be made before attempting these steps. Please note that these instructions are for a VM and have not been tested on a bare metal server.
Presumably you have already made more disk space available to the VM. These steps will pick up after that.
- Check your existing free space on your volume group.
df -h- Use disk space from an extended virtual disk. Run cfdisk to see if there is free space listed.
cfdisk
- Choose the /dev/sda3 partition from the list and then select “Resize” from the menu on the bottom. Hit the enter key again to confirm. Then select “Write” from the menu on the bottom, type yes, hit enter, then select “Quit“.
- Run
df -hagain to check the disk space. As you can see, the filesystem has not yet been resized. - Resize the partition.
pvresize /dev/sda3
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv- Confirm the filesystem has been resized by running
df -h.
Conclusion – Extend Ubuntu Disk Space
This article has demonstrated how to extend the disk space on an Ubuntu VM. Please leave us a comment if you have any question. Read more of our Linux content.
Leave a Reply