Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I used the Vagrant image for Ubuntu 13.04 64-bit from http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-amd64-vagrant-disk1.box to create a new virtual machine on my MacBook (10.8) and can successfully ssh to it. The problem is that though VirtualBox shows the size of the virtual machine's hard drive to be 40 Gb (dynamic), df-h command executed within the virtual machine shows that /dev/sda1 has only 4Gb, which is not enough for my needs:

/dev/sda1 4.0G 970M 2.8G 26% /

How can I ensure that my the Vagrant Ubuntu VM has enough space (e.g. 20Gb) on its sda1 partition?

share|improve this question
add comment

2 Answers 2

Those are automatically built Vagrant Ubuntu Cloud Images, we have no control over how they were built.

You either build your own vagrant box or 1. resize existing virtual HDD 2. Attach additional virtual HDDs, create file systems and mount it (e.g. /ops and install new stuff in this directory).

Personally I think option 2 is easier.

If you want to go with option 1, you'll have to convert the existing virtual HDD (VMDK) to VDI, because VBoxManage modifyhd only works with native VDI image. However, vagrant base boxes are basically exported OVF/OVA using VMDK format.

See VirtualBox Docs

The --resize x option (where x is the desired new total space in megabytes) allows you to change the capacity of an existing image; this adjusts the logical size of a virtual disk without affecting the physical size much.[37] This currently works only for VDI and VHD formats, and only for the dynamically allocated variants, and can only be used to expand (not shrink) the capacity.

Steps to increase the capacity of disk for Vagrant Base Box

  1. To be able to resize the HDD, you'll have to covert it to VDI first, e.g. VBoxManage clonehd in.vmdk out.vdi --format VDI and then re-attached it (using the GUI is easy).
  2. Resize it using VBoxManage modifyhd box.vdi --resize 15360 which increase the capacity to 15GB.
  3. However this only changes the drive capacity, you will have to grow the file system for the guest afterwards. For example, use resize2fs -p -F DEVICE for ext4.

Refer to the answer here for more details => How can I increase disk size on a Vagrant VM?

share|improve this answer
    
Thanks for answer! But I believe, I have a problem of a different kind. I cannot resize my virtual disk to be, e.g. 40Gb, since VirtualBox tells me that it is already 40Gb: VBoxManage showhdinfo box-disk1.vdi shows Logical size: 40960 MBytes. Also, when I try running sudo resize2fs -p -F /dev/sda1 within the VM I get: The filesystem is already 1048320 blocks long. Nothing to do!. So the problem remains - VirtualBox believes the size of the virtual disk is 40Gb and the VM thinks it is 4Gb. My colleague has tried to deploy the same box on his MacBook and is facing the same problem. –  silentser Oct 4 '13 at 8:42
    
The VM thinks that the size of the sda1 partition is 4G, but a partition is only part of the disk. Consider using parted or similar tools to resize the partition to fill the disk, and onlythen use resize2fs. –  Blaisorblade Feb 12 at 5:09
add comment
up vote 0 down vote accepted

It seems there is an issue with this specific Vagrant image. I've used a different one (https://dl.dropboxusercontent.com/u/547671/thinkstack-raring64.box) and there the problem does not occur.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.