Resize disk using vagrant builder

27 views
Skip to first unread message

Sergio Alonso

unread,
Oct 30, 2020, 6:08:49 AM10/30/20
to Packer

Hi,

Is there any way to increase the disk size using vagrant builder?

Sometimes the disk space is not enough to do whatever you want in the provision.

For example: debian/buster64 is setting 20G while debian/jessie64 is setting only 10G.

How could I get 20G also using the debian/jessie64 box?

{
    "builders": [{
    "communicator": "ssh",
    "source_path": "debian/buster64",
    "type": "vagrant"
    }],
    "description": "Test  disk size",
    "min_packer_version": "1.6.5",
    "provisioners": [{
    "execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
    "inline": ["lsblk", "df -h"],
    "type": "shell"
    }]
}


==> vagrant: Creating a Vagrantfile in the build directory...
==> vagrant: Adding box using vagrant box add ...
    vagrant: (this can take some time if we need to download the box)
==> vagrant: Calling Vagrant Up (this can take some time)...
==> vagrant: Using ssh communicator to connect: 192.168.121.73
==> vagrant: Waiting for SSH to become available...
==> vagrant: Connected to SSH!
==> vagrant: Provisioning with shell script: /tmp/packer-shell476965872
    vagrant: NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    vagrant: vda    254:0    0   20G  0 disk
    vagrant: `-vda1 254:1    0 18.6G  0 part /
    vagrant: Filesystem      Size  Used Avail Use% Mounted on
    vagrant: udev            228M     0  228M   0% /dev
    vagrant: tmpfs            49M  1.6M   47M   4% /run
    vagrant: /dev/vda1        19G  864M   17G   5% /
    vagrant: tmpfs           242M     0  242M   0% /dev/shm
    vagrant: tmpfs           5.0M     0  5.0M   0% /run/lock
    vagrant: tmpfs           242M     0  242M   0% /sys/fs/cgroup
    vagrant: tmpfs            49M     0   49M   0% /run/user/1000
==> vagrant: Packaging box...
==> vagrant: destroying Vagrant box...
Build 'vagrant' finished after 1 minute 12 seconds.

{
    "builders": [{
    "communicator": "ssh",
    "source_path": "debian/jessie64",
    "type": "vagrant"
    }],
    "description": "Test  disk size",
    "min_packer_version": "1.6.5",
    "provisioners": [{
    "execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
    "inline": ["lsblk", "df -h"],
    "type": "shell"
    }]
}

==> vagrant: Deleting previous output directory...
==> vagrant: Creating a Vagrantfile in the build directory...
==> vagrant: Adding box using vagrant box add ...
    vagrant: (this can take some time if we need to download the box)
==> vagrant: Calling Vagrant Up (this can take some time)...
==> vagrant: Using ssh communicator to connect: 192.168.121.20
==> vagrant: Waiting for SSH to become available...
==> vagrant: Connected to SSH!
==> vagrant: Provisioning with shell script: /tmp/packer-shell536004430
    vagrant: NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    vagrant: vda    254:0    0   10G  0 disk
    vagrant: `-vda1 254:1    0  9.3G  0 part /
    vagrant: Filesystem      Size  Used Avail Use% Mounted on
    vagrant: /dev/vda1       9.2G  732M  8.0G   9% /
    vagrant: udev             10M     0   10M   0% /dev
    vagrant: tmpfs            99M  4.3M   95M   5% /run
    vagrant: tmpfs           248M     0  248M   0% /dev/shm
    vagrant: tmpfs           5.0M     0  5.0M   0% /run/lock
    vagrant: tmpfs           248M     0  248M   0% /sys/fs/cgroup
==> vagrant: Packaging box...
==> vagrant: destroying Vagrant box...
Build 'vagrant' finished after 1 minute 64 milliseconds.


Thanks.

dragon788

unread,
Nov 5, 2020, 9:56:12 PM11/5/20
to Packer
I believe someone had worked on a `vagrant-repack` type builder that let you take an existing box and build on top of it. I'll see if I can find where that has gotten to.

dragon788

unread,
Nov 5, 2020, 10:05:19 PM11/5/20
to Packer

Sergio Alonso

unread,
Nov 6, 2020, 4:09:03 AM11/6/20
to packe...@googlegroups.com
Hi dragon78,

Thanks for the reply. Yes I'm using the vagrant builder.

But my problem is that I could not find a way to resize the disk space using that builder.

As I said in the previous email debian/jessie64 box is defined with a 10GB disk by default. And I need more than that for the provisioning steps.

I could not find a way in vagrant builder to assign, for example, "disk_size"="20G", as qemu builder does.

Regards.


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/LHU3HCn4v1g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/1e48807a-4790-41db-ba61-90f7fa89b8d4n%40googlegroups.com.


--
Sergio Alonso Fernández
Telecommunications Engineer
Reply all
Reply to author
Forward
0 new messages