sprotheroe/vagrant-disksize

Does not work with Debian 9

Opened this issue · 8 comments

Hey everyone! @sprotheroe

I've created a repo that creates a Vagrant VM with Debian 9 with some additional packages. The repo is https://github.com/pedrofurtado/vagrant-workspace

Following the instructions, the VM will be created successfully. But, the disk does not have the size defined by plugin.

You can check this typing df -h, inside the vagrant VM, and see that /dev/sda does not have the size configured.

Any ideas about why this happens with Debian? Because here at company we have a very similar repo that uses Ubuntu, and it works well.

I am using Vagrant 2.1.3, Debian 9 and plugin at latest version (at the moment of this issue).

and virtualbox 5.2.16

I have a similar situation. Using the plugin to set disk size to 30 GB on the Debian 9 image. VirtualBox shows the disk correctly size to 30 GB. And inside the VM blockdev --getsize64 /dev/sda shows 30 GB. But blockdev --getsize64 /dev/sda1 still has the old 9.1 GB size.

So it appears that the plugin is sizing the virtual disk device correctly, but it's not setting the partition size to utilize all the space.

I think I see the issue. The Debian9 images includes a swap partition at /dev/sda2, right in front of the the filesystem partition at /dev/sda1. (By comparison the Ubuntu18 image only has a single /dev/sda partition that takes up the whole disk.)

The Vagrant plugin does resize /dev/sda on the image. (This can be verified with fdisk /dev/sda). However /dev/sda1 (the root partition) cannot be resized to take advantage of this added space, because /dev/sda2 is sitting in front of it.

This suggests one of two approaches to fix this problem going forward. One's from the users' side, one's from the plugin side. The first is just to have the user remove the swap partition, then re-rerun the plugin. (Even better would be to have the Debian image maintainer remove swap to begin with. It's mostly useless to have swap space in a VM to begin with. If a VirtualBox user needs more memory, they can just allocate more to the guest, and let their host machine take care of virtual memory allocation.)

The second is to enhance the logic in this plugin. Quite rightly it doesn't go around reformatting hard disks and moving partitions, because of the risk of nuking data. But a swap partition, is inherently ephemeral. There's no risk to repartitioning the disk and moving swap to the end of disk, because there's no persistent data to risk losing. The plugin could check partitions for type, and move non-persistent partitions around by default, if needed to make room for resized root partitions.

I agree that it does not make sense to have a swap partition here. Following https://app.vagrantup.com/debian a bug should be reported at https://tracker.debian.org/pkg/cloud.debian.org

@sprotheroe As a workaround, I changed my repo to use Ubuntu 18.04 LTS instead of Debian 9, that creates the disk with correct size 👍

The Ubuntu image has its own issues (slow startup, weird serial port thingy) so I'd rather like to have this fixed for Debian.

+1 for debian 10