Out of disk space in VirtualBox

Background

Was working on compiling mysql server from source on a Oracle Linux 6 virtual machine and the root partition got full. Now what are my alternatives?

 

Options

  1. Increase space by resizing the .vdi disk file
    Tried and failed..
    Ran this command to increase the size of disk

    VBoxManage modifymedium disk  '/Users/robin/VirtualBox VMs/oracle6.10/oracle6.10.vdi' --resize 20480

    Though it did increase the size of the disk, I was not able to make linux aware of the increased size. Tried with resize2fs and fsck command and they complained the partition being mounted or busy. Then I tried with mounting the disk with a live linux disk from PuppyLinux, failed still 🙁 So I thought about next alternative

  2. Install VM from scratch with larger disk
    While this was feasible I did not pursue this one, since I was pressed with time. Umm.. How about adding a new empty disk of larger size? Brilliant? So that is what I tried next
  3. Adding new disk to the current VM
    From the disk manager created a new disk, it was 20GB in my case. Added to the VM, and started the setup. Following is what I had to do to make it available for using,

    1. Run lsblk command to check the new device. You may also do that with fdisk -l
    2. Run fdisk on the new device to create partitions. In my case device was /dev/sdb
      sudo fdisk /dev/sdb

      Then a series of input to interactive fdisk prompt,
      n – to create new partition
      p – to create primary partition
      1 – for the first partition
      I selected the default values for the next two, to indicate the first and last sector. Since I wanted to use the entire disk for this primary partition.
      w – to write the changes

    3. At this time the partition was ready for use, wait, we still neet to tell the format or filesystem type of the partition, so,
      sudo mkfs.ext4 /dev/sdb1

      And now final step to mount the partition for using

      sudo mkdir /data
      sudo mount /dev/sdb1 /data

      That was it! I can now use /data dir mounted from the new disk that was of larger capacity.

 

So of the three options, third one was the fastest and working option for me. It saved my day (well hours of work compared to a fresh install).

This makes me think, may be, I should create smaller OS volumes for my next installs of OS. May be 5GB in size and always mount additional larger disks for my testing. Isolating all concerns relating to disk size. That does make sense to me now. [ My eyes wide open 😉 ]

 

References

  1. Increase VM disk size
  2. Adding new disk to linux

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *