准备box文件
查看box
MINGW64 /d/data/ubuntu-14 $ vagrant box list centos/7 (virtualbox, 0) centos/7-1 (virtualbox, 0) centos/7-2 (virtualbox, 0) centos/7-3 (virtualbox, 0) ubuntu-14 (virtualbox, 0)
准备Vagrantfile
主要是安装一些GUI的依赖包
# -*- mode: ruby -*- # vi: set ft=ruby : # date: 2022年11月1日09:45:21 # author: ninesun Vagrant.configure(2) do |config| # Ubuntu 18.04 config.vm.box = "ubuntu-14" config.vm.provider "virtualbox" do |vb| # Display the VirtualBox GUI when booting the machine vb.gui = true end # Install xfce and virtualbox additions config.vm.provision "shell", inline: "sudo apt-get update" config.vm.provision "shell", inline: "sudo apt-get install -y xfce4 virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11" # Permit anyone to start the GUI config.vm.provision "shell", inline: "sudo sed -i 's/allowed_users=.*$/allowed_users=anybody/' /etc/X11/Xwrapper.config" end
启动虚拟机并开启GUI
vagrant up
Login with username: vagrant, password: vagrant via the login prompt on the virtualbox GUI.
Start xfce
startx
双向拖拉文件和复制
安装其他软件的Vagrantfile
Vagrant.configure("2") do |config| config.vm.box = "ubuntu/bionic64" config.vm.provider :virtualbox do |v| v.gui = true v.memory = 2048 end # Currently "ubuntu/bionic64" on VirtualBox requires `type: "virtualbox"` # to make synced folder works. config.vm.synced_folder ".", "/vagrant", type: "virtualbox" # Add Google Chrome repository config.vm.provision :shell, inline: "wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub|sudo apt-key add -" config.vm.provision :shell, inline: "sudo sh -c 'echo \"deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main\" > /etc/apt/sources.list.d/google.list'" # Update repositories config.vm.provision :shell, inline: "sudo apt update -y" # Upgrade installed packages config.vm.provision :shell, inline: "sudo apt upgrade -y" # Add desktop environment config.vm.provision :shell, inline: "sudo apt install -y --no-install-recommends ubuntu-desktop" config.vm.provision :shell, inline: "sudo apt install -y --no-install-recommends virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11" # Add `vagrant` to Administrator config.vm.provision :shell, inline: "sudo usermod -a -G sudo vagrant" # Add Google Chrome config.vm.provision :shell, inline: "sudo apt install -y google-chrome-stable" # Add Chromium config.vm.provision :shell, inline: "sudo apt install -y chromium-browser" # Add Firefox config.vm.provision :shell, inline: "sudo apt install -y firefox" # Add Japanese support config.vm.provision :shell, inline: "sudo apt install -y fcitx-mozc" config.vm.provision :shell, inline: "sudo apt install -y fonts-noto" # Restart config.vm.provision :shell, inline: "sudo shutdown -r now" end