Vagrant vbox image only has a 5GB disk

Hey @javiroman,

The Rocky Linux Vagrant VirtualBox image only provides a 5GB hard disk. As per the Vagrant documentation:

make sure the user will have enough disk space to do interesting things, without being annoying. For example, in VirtualBox, you should create a dynamically resizing drive with a large maximum size.

I’m assuming this was mistake considering there’s not enough space to install Docker engine.

I suggest using a dynamic disk set to a large size such as 100GB or more.

For comparison, the official CentOS image provides 40GB of space while the Alpine Linux image provides 13GB of space. Not sure why they artificially limit the drive size when using dynamic disks.

Thanks

Is this the proper place for a bug report regarding the Vagrant boxes? If there’s a dedicated bug tracker let me know and I can submit this issue there instead.

Thanks

Just a thought, is it really necessary to modify the disk included in the image? If you are using it in a Vagrant setup where you need X GB of disk, cant you just add a secondary disk and mount it somewhere when the machine is bootstrapped?

In this example, it looks like you can do something like:

disk = './secondDisk.vdi'
(...)
    iscsitarget.vm.provider "virtualbox" do |vb|
      unless File.exist?(disk)
        vb.customize ['createhd', '--filename', disk, '--variant', 'Fixed', '--size', 20 * 1024]
      end

There’s ways around it of course but that’s beside the point. The disk image is too small and needs to be increased.

If we disregard Docker Engine, I think it makes more sense to refer to the RHEL 8 general recommendations: Red Hat Enterprise Linux Technology Capabilities and Limits - Red Hat Customer Portal

The recommended disk size is 20GB so I agree that it should be increased, and I think RHEL recommendations is a good place to start now and in the future.

This can be reported at the bug tracker or the kickstart repo at github or RESF Git Service.

Aside from reasonable discussion of what the default disk size should be for Rocky Linux Vagrant images the latest version of Vagrant has experimental support for resizing/adding machine disks, including the machine primary disk.

With a small amount of extra configuration in the Vagrantfile the / (root) filesystem can be resized online.

There will invariably be use cases where more disk space than the default, whatever it may be, will not be enough. For those cases here is an example of how to do this…

Vagrantfile

% cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "rockylinux/8"

  # Disable default shared_folder
  config.vm.synced_folder ".", "/vagrant", disabled: true

  # Resize primary disk, REQUIRES: VAGRANT_EXPERIMENTAL="disks" vagrant up
  config.vm.disk :disk, size: "36GB", primary: true

  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true

    # Customize the amount of memory on the VM:
    vb.memory = "1024"
  end

  config.vm.provision "shell", inline: <<-SHELL
    printf "\nDisk free space before...\n"
    df -lhT /

    printf "\nResizing / partition live with sgdisk...\n"
    dnf install -y gdisk
    sgdisk -g -e /dev/sda
    sgdisk -d 1 /dev/sda
    sgdisk -N 1 /dev/sda
    partprobe /dev/sda
    xfs_growfs /dev/sda1

    printf "\nDisk free space after...\n"
    df -lhT /
  SHELL

end

Command output

% vagrant --version && VAGRANT_EXPERIMENTAL="disks" vagrant up
Vagrant 2.3.2
==> vagrant: You have requested to enabled the experimental flag with the following features:
==> vagrant:
==> vagrant: Features:  disks
==> vagrant:
==> vagrant: Please use with caution, as some of the features may not be fully
==> vagrant: functional yet.
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'rockylinux/8'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'rockylinux/8' version '5.0.0' is up to date...
==> default: Setting the name of the VM: rockylinux_default_1668297802356_19888
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Configuring storage mediums...
    default: Disk 'vagrant_primary' needs to be resized. Resizing disk...
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2200
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Running provisioner: shell...
    default: Running: inline script
    default:
    default: Disk free space before...
    default: Filesystem     Type  Size  Used Avail Use% Mounted on
    default: /dev/sda1      xfs   5.0G  3.5G  1.6G  69% /
    default:
    default: Resizing / partition live with sgdisk...
    default: Rocky Linux 8 - AppStream                       6.6 kB/s | 4.7 kB     00:00
    default: Rocky Linux 8 - AppStream                       8.4 MB/s |  11 MB     00:01
    default: Rocky Linux 8 - BaseOS                           10 kB/s | 4.3 kB     00:00
    default: Rocky Linux 8 - BaseOS                          7.7 MB/s | 9.0 MB     00:01
    default: Rocky Linux 8 - Extras                          6.3 kB/s | 3.1 kB     00:00
    default: Rocky Linux 8 - Extras                           23 kB/s |  12 kB     00:00
    default: Last metadata expiration check: 0:00:01 ago on Sun 13 Nov 2022 12:04:00 AM UTC.
    default: Dependencies resolved.
    default: ================================================================================
    default:  Package         Architecture     Version                Repository        Size
    default: ================================================================================
    default: Installing:
    default:  gdisk           x86_64           1.0.3-9.el8            baseos           239 k
    default:
    default: Transaction Summary
    default: ================================================================================
    default: Install  1 Package
    default:
    default: Total download size: 239 k
    default: Installed size: 810 k
    default: Downloading Packages:
    default: gdisk-1.0.3-9.el8.x86_64.rpm                    1.2 MB/s | 239 kB     00:00
    default: --------------------------------------------------------------------------------
    default: Total                                           724 kB/s | 239 kB     00:00
    default: Running transaction check
    default: Transaction check succeeded.
    default: Running transaction test
    default: Transaction test succeeded.
    default: Running transaction
    default:   Preparing        :                                                        1/1
    default:   Installing       : gdisk-1.0.3-9.el8.x86_64                               1/1
    default:   Running scriptlet: gdisk-1.0.3-9.el8.x86_64                               1/1
    default:   Verifying        : gdisk-1.0.3-9.el8.x86_64                               1/1
    default:
    default: Installed:
    default:   gdisk-1.0.3-9.el8.x86_64
    default:
    default: Complete!
    default:
    default: ***************************************************************
    default: Found invalid GPT and valid MBR; converting MBR to GPT format
    default: in memory.
    default: ***************************************************************
    default:
    default: Warning: The kernel is still using the old partition table.
    default: The new table will be used at the next reboot or after you
    default: run partprobe(8) or kpartx(8)
    default: The operation has completed successfully.
    default: Warning: The kernel is still using the old partition table.
    default: The new table will be used at the next reboot or after you
    default: run partprobe(8) or kpartx(8)
    default: The operation has completed successfully.
    default: Warning: The kernel is still using the old partition table.
    default: The new table will be used at the next reboot or after you
    default: run partprobe(8) or kpartx(8)
    default: The operation has completed successfully.
    default: meta-data=/dev/sda1              isize=512    agcount=4, agsize=327616 blks
    default:          =                       sectsz=512   attr=2, projid32bit=1
    default:          =                       crc=1        finobt=1, sparse=1, rmapbt=0
    default:          =                       reflink=1
    default: data     =                       bsize=4096   blocks=1310464, imaxpct=25
    default:          =                       sunit=0      swidth=0 blks
    default: naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
    default: log      =internal log           bsize=4096   blocks=2560, version=2
    default:          =                       sectsz=512   sunit=0 blks, lazy-count=1
    default: realtime =none                   extsz=4096   blocks=0, rtextents=0
    default: data blocks changed from 1310464 to 9436923
    default:
    default: Disk free space after...
    default: Filesystem     Type  Size  Used Avail Use% Mounted on
    default: /dev/sda1      xfs    36G  3.7G   33G  11% /

Hope that helps.