Extend the disk size of a Ubuntu VM
Introduction
Running out of space on your VM and need to increase the storage of your main partition? All you need to do is add more disk capacity in your hypervisor and extend your partition.
Dependencies
Parted must be installed to follow the below steps. If you do not have parted you can install with:
1
sudo apt-get install parted
Steps
- Extend your disk to your desired size in your hypervisor.
- SSH into the VM.
- Run
df -h
to check your current space for refrence. - Run
sudo parted
to enter into parted. - Type
print
and hit Enter. - If asked to fix type
fix
and hit Enter. - You will see your partitions. In most cases if you have the default partition layout we will be working with partition 2. Type
resizepart 2
and hit Enter. - When asked for End value look for the
Disk /dev/sda
value from the print command above and enter in format of80GB
for example. - Type
q
and hit enter. - Run
sudo resize2fs /dev/sda2
. - Run
df -h
to confirm partition expanded.
This post is licensed under CC BY 4.0 by the author.