Parallels / vagrant-parallels

Vagrant Parallels Provider

Home Page:https://parallels.github.io/vagrant-parallels

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Supporting hard drive size configuration

tolmasky opened this issue · comments

We've been able to get hard drive size configuration working with the following:

class VagrantPlugins::Parallels::Config
    
    # Extend the Vagrant::Parallels::Config class to have the missing size
    # setter. We use prlctl's set --size, and we have to use --no-fs-resize
    # because prlctl doesn't support ext4. Not to worry though, we'll handle
    # that in the shell script below...
    def size=(size)
        customize('pre-boot',
            ['set', :id, '--size', size.to_s + 'M', '--no-fs-resize'])

        customize('post-comm',
        [
            'exec', :id,
            <<-SHELL
                printf "resizepart\n3\nYes\n100%%\nquit" | \
                    sudo parted /dev/sda ---pretend-input-tty && \
                resize2fs /dev/sda3
            SHELL
        ])

    end
end

However, this also requires us to first modify the Parallels box available on vagrant cloud:

$ tar xf parallels-ubuntu-box.box -C ./tmp
$ prlctl --merge `$(find ./tmp -name *pvm)/harddisk1.hdd`
$ tar cvzf parallels-ubuntu-box-resizable.box -C ./tmp ./tmp/*

After this, you can finally treat size just like memory, and you can resize it freely across reboots as well:

  config.vm.provider "parallels" do |box, override|
    box.size = 100000
  end

We've wrapped up that unfortunate prlctl merge stuff in a function that lets you call it directly from Vagrant and caches it:

config.vm.box = resizable_box "generic/ubuntu2004@3.6.14"

Anyways, is this something worth putting into the main parallels plugin? It was certainly hard to put all this information together, but I don't know enough about all this to know if this will work for everything or just happens to work on our installation. We've only tried it with ubuntu 18.04 and 20.04.

This is an essential feature, and I wonder why the parallels vagrant plugin does not support this.