Setting “Paravirtualization Interface” in Vagrantfile

前端 未结 2 455
傲寒
傲寒 2021-02-06 07:07

VirtualBox 5 exposes a setting called \"Paravirtualization Interface\" that can improve performance for some specific guest operating systems.

Is there a way to set this

2条回答
  •  孤独总比滥情好
    2021-02-06 07:26

    My Vagrantfile did not have a vb.customize section (maybe the accepted answer uses older format (?)). Based on https://www.vagrantup.com/docs/virtualbox/configuration.html and https://www.virtualbox.org/manual/ch08.html (search for --nictype) the following worked for me. I did not need to set KVM explicitely, because I was on Linux and it was the default.

    Vagrant.configure("2") do |config|
    
        config.vm.box = "ubuntu/bionic64"
        config.vm.hostname = "whatever"
    
        config.vm.provider "virtualbox" do |vb|
            vb.memory = "512"
            vb.cpus = "2"
            vb.default_nic_type = "virtio"
        end
    end
    

    By setting this default_nic_type to virtio, not only the first NAT-ed NIC got this type, but also I defined a second NIC (not shown here) and it also got created as virtio (virtio-net in virtualbox settings GUI).

提交回复
热议问题