Full Blog TOC

Full Blog Table Of Content with Keywords Available HERE

Wednesday, July 21, 2021

Disk Space issues in Ubuntu VM

 


In this post we will review how to overcome disk space issues in an Ubuntu VM.

This week, we've had our build machine out of disk space due to docker images disk requirements. This occurred since we keep the latest version per each git branch. Even after cleanup of some old images, we realized that we should have more disk space available on the build machine.

The steps to add disk space are listed below.


Add New Disk to the VM

Use the VM management tools to add new disk to the VM.
Notice: reboot the machine after this, to make the OS identify the new added disk.

Create a Partition and a FileSystem

Identify the new added disk using the command: sudo lshw -C disk

An example of output is:



In this case the new disk device is /dev/sdb, which is a shorthand for Scsi Disk B.

To create a partition, run sudo cgdisk /dev/sdb, where the argument is the new disk device. 

  • In the cgdisk utility, create a new partition. 
  • Use the defaults values for the partition creation.
  • Make sure to select "Write" option after the partition creation.

Next we create a filesystem using the command: sudo mkfs -t ext4 /dev/sdb1
Find the UUID of the new filesystem using: sudo blkid | grep /dev/sdb1.
For example:



Copy the UUID, and edit the fstab: sudo vi /etc/fstab.

Duplicate one of the UUID line, and replace the UUID with the one created in the previous step. Also select an existing folder to mount the disk on. In our case we use a new folder for the docker images, hence we use the folder /var/lib/docker/overlay2.




To check that this is working, use the command: sudo mount -av.

Finally reboot the machine to verify that everything works.






No comments:

Post a Comment