I have a VM managed by Vagrant using VirtualBox on a Ubuntu host server. My Vagrant box uses the Puppetlabs Debian 6.0.7 basebox, which uses LVM for its root partition.

By default the disk is 8GB which is too small for my purposes. I would like to:

  1. Increase the size of the existing disk and the file system on it without destroying and recreating my VM.
  2. Configure Vagrant so that in future it will create a larger disk for this project.

Can anyone explain how to do this?


Personally I think it'll be easier to attach an extra virtual HDD and mount it to a proper mount point, for example /opt and move your stuff over using rsync to work around this issue, after all, puppet vagrant boxes are for testing purposes.

Reason why: 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.

To increase the capacity of disk for Vagrant Base Box

Steps are

  1. To be able to resize the HDD, you'll have to convert it to VDI first, e.g. VBoxManage clonehd in.vmdk out.vdi --format VDI and then re-attached it (using the GUI is easier).

  2. Resize it using VBoxManage modifyhd box.vdi --resize 15360 which increases the capacity to 15GB.

  3. However this only changes the drive capacity, you will have to expand the file system for the guest afterwards. For example, use resize2fs -p -F DEVICE for ext{3,4}.

  • 3
    Note that after resizing and before starting up the vagrant box again, you also need to update the VirtualBox storage configuration so it uses the new VDI and not the original VMDK: In VirtualBox > Storage >Remove existing hard disk > Add hard disk (select existing and point to the new VDI image) – Steve Swinsburg Jul 10 '14 at 4:24
  • 1
    For Debian users, I suggest also looking at this post: blog.lenss.nl/2012/09/resize-a-vagrant-vmdk-drive. When I got to step 3 it was not quite as simple as running resize2fs. Good luck! – phirschybar Feb 1 '15 at 21:18
  • 2
    I just wrote a consolidated guide on this: medium.com/@phirschybar/… – phirschybar Feb 1 '15 at 21:47

I found this simplest way to resolve this problem:

  • Install this plugin: vagrant plugin install vagrant-disksize

  • Edit the Vagrantfile:

    Vagrant.configure('2') do |config|
      config.vm.box = 'ubuntu/xenial64'
      config.disksize.size = '50GB'
  • vagrant halt && vagrant up

    • Note: this will not work with vagrant reload
  • 3
    Worked like a charm. Seems to be the easiest solution I've come across. Thank you, sir. – Rico Mar 14 '19 at 21:28
  • 1
    For a Debian9 box this increases the raw disk size, but not the actual partition used by the Debian installation. The increased disk size is not directly usable. – Læti Mar 22 '19 at 12:26
  • @Tonin did you manage to find a solution? – Arjun Jun 17 '19 at 16:41
  • 8
    I used sudo cfdisk /dev/sda tool to resize my /dev/sda1 partition to all newly available space. Then I told my filesystem to take use of that space with sudo resize2fs -p -F /dev/sda1 – tutuDajuju Aug 12 '19 at 10:02
  • 1
    Thank you. This works on my particular configuration too. Host OS: Windows 10, Virtual Box: 6.0, VM OS: Ubuntu Xenial – Binita Bharati Aug 15 '20 at 1:56

I've automated adding the disk in my Vagrantfile:

Vagrant.configure("2") do |config|
    file_to_disk = File.realpath( "." ).to_s + "/disk.vdi"

    if ARGV[0] == "up" && ! File.exist?(file_to_disk) 
       puts "Creating 5GB disk #{file_to_disk}."
       vb.customize [
            '--filename', file_to_disk, 
            '--format', 'VDI', 
            '--size', 5000 * 1024 # 5 GB
       vb.customize [
            'storageattach', :id, 
            '--storagectl', 'SATA Controller', 
            '--port', 1, '--device', 0, 
            '--type', 'hdd', '--medium', 
   config.vm.provision "shell", path: "scripts/add_new_disk.sh"

Where the add_new_disk.sh shell script looks like this:

set -e
set -x

if [ -f /etc/disk_added_date ]
   echo "disk already added so exiting."
   exit 0

sudo fdisk -u /dev/sdb <<EOF


pvcreate /dev/sdb1
vgextend VolGroup /dev/sdb1
lvextend /dev/VolGroup/lv_root
resize2fs /dev/VolGroup/lv_root

date > /etc/disk_added_date

This script is for a centos 6.4 box, but could easily be adapted to ubuntu.

Instead of adding a disk, other options include:

  • using a box with a bigger disk such as opscode bento which have 40Gb disks
  • build your own box using packer. You can use the opscode boxes packer definitions as a starting point
  • Hi There, I would like to try your solution out. Can you confirm where in the Vagrant File this section of code was added in? Kind Regards – Rudi Strydom Sep 16 '14 at 11:48
  • @RudiStrydom I've update the answer - hope it makes more sense now. – Chris Snow Sep 16 '14 at 17:38
  • 2
    This should add in the config.vm.provider :virtualbox do |vb| block to make things more clear – B T Oct 5 '14 at 2:17
  • 1
    If you get an "specify either size or extents" error for lvextend, try lvextend -l +100%FREE /dev/VolGroup/lv_root instead – Andomar Oct 8 '14 at 12:19
  • 1
    Your example would create a 5TB disk (the --size unit is MB, see virtualbox.org/manual/ch08.html#vboxmanage-createvdi). – backflip Jan 31 '15 at 10:00

Install Vagrant plugin vagrant-disksize

vagrant plugin install vagrant-disksize

If you want to add make sure user has the plugin installed when starting vagrant you can add this in the beginning of Vagrantfile

# Install vagrant-disksize to allow resizing the vagrant box disk.
unless Vagrant.has_plugin?("vagrant-disksize")
    raise  Vagrant::Errors::VagrantError.new, "vagrant-disksize plugin is missing. Please install it using 'vagrant plugin install vagrant-disksize' and rerun 'vagrant up'"

Set desired disk size in Vagrantfile

vagrant.configure('2') do |config|
    config.disksize.size = '50GB'

Updating existing vagrant box

  1. Do all of the above
  2. Run vagrant halt & vagrant up (You should see something like "Resized disk: old 32768 MB, req 51200 MB, new 51200 MB")
  3. SSH to vagrant box
  4. Run sudo cfdisk /dev/sda
  5. Use arrows to select your disk probably sdaX. Mine was sda3.
  6. Then select resize using arrow keys. Accept the suggested disk size.
  7. Then select write. And answer yes.
  8. You can select quit now.
  9. Run sudo resize2fs -p -F /dev/sdaX You should see something like: "Filesystem at /dev/sda3 is mounted on /; on-line resizing required old_desc_blocks = 4, new_desc_blocks = 6 The filesystem on /dev/sda3 is now 11933952 (4k) blocks long. "
  10. Run df and see that your disk size has increased.

You can use the plugin, which will enable you to specify the disk size https://github.com/sprotheroe/vagrant-disksize

  • This resized my disk and expanded the partition in only one line of configuration. Very slick! – user1026263 Mar 3 '19 at 15:01

disclaimer: answer most likely applicable only for distros using logical volume management like rhel for which the following use case applies:

I have been using the official Red Hat Enterpise 7.2 vagrant box officially provisioned by red hat.

(you will need a rhel developer account which you can create for free)

Upon installation I was troubled by the fact that only 8GB were also available:

sudo df -h
[vagrant@rhel-cdk ~]$ sudo df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-root   8G  2,5G   6,5G  28% /
devtmpfs                     234M     0  234M   0% /dev
tmpfs                        245M     0  245M   0% /dev/shm
tmpfs                        245M  4,3M  241M   2% /run
tmpfs                        245M     0  245M   0% /sys/fs/cgroup
/dev/sda2                    297M  134M  164M  45% /boot
tmpfs                         49M     0   49M   0% /run/user/1000

And as you can see most of the space had already been consumed by the rhel installation.

However I discovered that the volume group corresponding to the /dev/mapper/VolGroup00-root fileystem did have extra space (which I suppose in terms of virtual box was dynamicaly allocated)

sudo vgdisplay VolGroup00
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  11
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               39,70 GiB
  PE Size               4,00 MiB
  Total PE              10164
  Alloc PE / Size       7872 / 30,75 GiB
  Free  PE / Size       2292 / 8,95 GiB
  VG UUID               JBVwpl-13KX-HbQw-FqUa-CA9w-swpF-dF6glm

So the only things remaining to be done were to:

a) Increase the size of our logical volume by say 10G

sudo lvextend -L+10G /dev/VolGroup00/root


b) Update your root filesystem so that it becomes aware of this change

sudo xfs_growfs /dev/mapper/VolGroup00-root

(pls note that at least for rhel 7.2 resize2fs will not work for the this purpose).

After that, additional space was available to my filesystem:

sudo df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-root   18G  2,5G   16G  14% /
devtmpfs                     234M     0  234M   0% /dev
tmpfs                        245M     0  245M   0% /dev/shm
tmpfs                        245M  4,3M  241M   2% /run
tmpfs                        245M     0  245M   0% /sys/fs/cgroup
/dev/sda2                    297M  134M  164M  45% /boot
tmpfs                         49M     0   49M   0% /run/user/1000

... no intervention on virtualbox level


increase the disk size of VM centos 7

  1. On the host install the plugin:

    vagrant plugin install vagrant-disksize

  2. Edit vagrant file to set the disk size:

    vagrant.configure('2') do |config| 
        config.vm.box = 'centos/7' 
        config.disksize.size = '50GB'

3: Boot up the VM 4: Install the growpart and grow the disk size to full

yum install epel-release -y yum install cloud-utils-growpart.x86_64 -y growpart /dev/sda 1

5: Download gparted live iso image and attach it as a cdrom to the VM and boot into gpartedlive using the Virtualbox GUI reboot with gparted live

6: With gparted check partition to clear the error flag

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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