How to fix ubuntu disk space issue and how to increase or expand ubuntu virtual disk size in vmware

Md. Mahim Bin Firoj
4 min readNov 8, 2023

--

Let me tell you the scenario first. Altough you already know that I generally post related to cyber security topics. But this topic is a bit side off from cyber security but I thought it will be helpful for you. But I encountered this problem while RnD a cyber security topic. I assigned 40 GB harddisk size of my ubuntu vm and installed docker openvas container.

Initially it was ok but gradually when openvas fetch updates from its parent database then my all storage 40GB started choking suddently. As a result I was unable to access the ubuntu vm because it was not properly booted and lastly I found that only 0 % of free space remained that’s why it behaved like this.

My plan was to add more 20GB with it and merge it using gparted apps but I was totally unable to login. Here is how I fix it.

  1. Reboot the ubuntu vm.
  2. Press and hold Shift key to access Grub boot loader.
  3. In the GRUB menu, select “Advanced options for Ubuntu” or something similar.
  4. Choose the recovery mode with higher version option.

This should allow you to access a root shell with the ability to perform maintenance tasks. Here you will find some options like clear or free up disk space, access shell with root, check file system with fsck etc. You need to access the shell with root and thus you need to provide the root password.

Once you are within the root shell now think about what you had done earlier that cause you to fill up the disk rapidly. You need to revert those. It could be uninstalling any package, removing any large file from the disk. In my case I was deleted docker and its associated openvas related images. Thus I freed 16 GB space instantly. This ends the 1st part of this writeup.

Now let’s see how we can add extra harddisk and merge it with the / (root) directory of ubuntu vm. Follow the below steps:

First of all shutdown the ubuntu vm.

Click here to add hd
Click on Expand

Increase the size from 40 to 60 GB then click on Expand. It will take some time. Please have some patience.

Notice the message here. The disk has successfully been expanded but it will not merged yet with your current / and you need to do that manually. Let’s turn on the vm now. And check what is the total space current now.

39 ~ 40 Gb current now.

Let’s install this. After install is done, use gparted command to open the gui of it.

Right click on /dev/sda3

Click on Resize/Move

We need to unmount it first.

Click on Unmount now.

Don’t worry seeing this error. Actually it is unmounted. Click now ok and again right click on /dev/sda3 > Resize/Move

Now drag this bar to the end of the right side.

Now click on Resize and then Apply all operations.

Click on Apply.

After the operation is done, we can see that our disk has finally been expanded and merged with the previous 40 GB storage.

Thanks. I hope this writeup will help you in future to extend vm virtual disk space when you need. Please subscribe below.

LinkedIn:

https://www.linkedin.com/in/md-mahimbin-firoj-7b8a5a113/

YouTube:

https://www.youtube.com/@mahimfiroj1802/videos

--

--