This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
deb11:virtualboxvm [2022/09/24 11:28] – created Bernard Condrau | deb11:virtualboxvm [2025/03/20 14:09] (current) – [Reboot (dead) vm] Bernard Condrau | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== VirtualBox ====== | + | ====== VirtualBox |
- | ===== Host ===== | + | |
- | * I recommend to install VirtualBox from the Oracle repository, as you get the latest version of VirtualBox | + | |
- | * Add " | + | |
- | * Add Oracle VirtualBox public key:< | + | |
- | sudo apt-key add oracle_vbox_2016.asc | + | |
- | wget https:// | + | |
- | sudo apt-key add oracle_vbox.asc</ | + | |
- | * Install Virtualbox:< | + | |
- | sudo apt-get install virtualbox-6.0</ | + | |
- | * Download the [[https:// | + | |
- | * [[https:// | + | |
- | * [[https:// | + | |
- | + | ||
- | ===== Guest ===== | + | |
===== Guest Additions ===== | ===== Guest Additions ===== | ||
- | * To upgrade the Guest Additions after upgrading the host version, download the guest additions pack, close all virtual machines, and start virtualbox | + | * To upgrade the Guest Additions after upgrading the VirtualBox |
- | * After installing the Guest Additions, close virtualbox | + | * After installing the Guest Additions, close VirtualBox |
- | + | ||
- | ===== Guest Additions for a Debian 9 guest on a Debian 7 host ===== | + | |
- | * Add the following line to / | + | |
- | * Install virtualbox-guest-dkms, | + | |
- | sudo apt install virtualbox-guest-dkms virtualbox-guest-x11 linux-headers-$(uname -r)</ | + | |
- | * Reboot the guest system. | + | |
- | * More info: [[https:// | + | |
- | + | ||
- | ===== Autostart and Autostop ===== | + | |
- | There are several options to autostart (and autostop) virtual machines. For a server environment with a Debian host the 1. option through rc.local is preferrable. | + | |
- | - through rc.local | + | |
- | - through X desktop | + | |
- | - through VirtualBox command line | + | |
- | + | ||
- | ==== through rc.local ==== | + | |
- | === startup === | + | |
- | - install [[deb10: | + | |
- | - mount encrypted file systems through rc.local as explained in [[deb9: | + | |
- | - start vms through rc.local headless. Since rc.local runs as root you need to use runuser to start the vm as the user who created the vm. You may also chose to put the startvm code into a script and add execution of the script to rc.local:< | + | |
- | === shutdown === | + | |
- | - put a symlink to the following script into / | + | |
- | while [ " | + | |
- | do | + | |
- | echo waiting for VMs to shutdown | + | |
- | sleep 5 | + | |
- | done | + | |
- | </ | + | |
- | - allow < | + | |
- | < | + | |
- | - the scripts must be run as root so they can be executed through rc.local | + | |
- | - also, the server must be shut down with // | + | |
- | + | ||
- | === links === | + | |
- | * Debian [[deb10: | + | |
- | ==== through XFCE Desktop ==== | + | |
- | === startup === | + | |
- | * On the host, open **Settings -> Session and Startup**, then add a new task under **Application Autostart** with the following command:< | + | |
- | === shutdown === | + | |
- | * On the client, open **Settings -> Power Manager**, then set the desired action under "When power button is pressed" | + | |
- | + | ||
- | ==== through VirtualBox command line ==== | + | |
- | - Configuration< | + | |
- | VBOXAUTOSTART_DB=/ | + | |
- | VBOXAUTOSTART_CONFIG=/ | + | |
- | + | ||
- | sudo vim / | + | |
- | default_policy = deny | + | |
- | # Create an entry for each user allowed to use autostart | + | |
- | username = { | + | |
- | allow = true | + | |
- | startup_delay = 10 | + | |
- | } | + | |
- | + | ||
- | sudo chgrp vboxusers /etc/vbox | + | |
- | sudo chmod 1775 /etc/vbox | + | |
- | sudo usermod -aG vboxusers username</ | + | |
- | - Choose VMs to automatically start and stop< | + | |
- | VBoxManage modifyvm < | + | |
- | VBoxManage modifyvm < | + | |
- | - Restart VirtualBox autostart service< | + | |
- | + | ||
- | ==== Start VM ==== | + | |
- | vboxmanage startvm MachineName | + | |
- | ==== Stop VM ==== | + | |
- | vboxmanage controlvm MachineName acpipowerbutton | + | |
- | In xfce desktop, make sure the action on Power Button is set in Settings --> Power Manager | + | |
- | + | ||
- | ==== Stop VM before powering down host through NUT ==== | + | |
- | Set different timeouts to the shutdown command used by NUT. For example, set +0 for the clients, and +1 for the host. | + | |
- | + | ||
- | ==== Check running VMs ==== | + | |
- | One of the following commands: | + | |
- | VBoxManage list runningvms | + | |
- | vboxmanage list vms --long | grep -e " | + | |
- | + | ||
- | ==== Links ==== | + | |
- | * [[https:// | + | |
- | * [[https:// | + | |
- | * [[https:// | + | |
- | * [[http:// | + | |
- | + | ||
- | ===== Update VirtualBox ===== | + | |
- | * Make sure to update the same way you installed the previous version, either from the Oracle repository, or from the Debian backports | + | |
- | * If you followed my guide, check the VirtualBox version.revision.build (e.g. 6.1.16) | + | |
- | * Updating the build is done by running "apt upgrade"< | + | |
- | sudo apt upgrade</ | + | |
- | * Updating to a new version or revision is done by running "apt install virtualbox-< | + | |
- | sudo apt install virtualbox-6.1</ | + | |
- | + | ||
- | ==== Links ==== | + | |
- | * [[https:// | + | |
- | ===== Manage VirtualBox through CLI ===== | + | |
- | ==== Extension Pack ==== | + | |
- | * Remove old extension pack< | + | |
- | * Download current extension pack from [[https:// | + | |
- | sudo vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.1.30.vbox-extpack</ | + | |
- | + | ||
- | ==== Run VM ==== | + | |
- | * < | + | |
- | ==== Hold back upgrade | + | ===== Install Guest Additions on a Debian 11 guest operating system ===== |
- | | + | |
- | | + | - Install the kernel headers, DKMS framework, and build tools< |
- | ==== Links ==== | + | sudo apt install dkms linux-headers-$(uname -r) build-essential</ |
- | | + | |
- | * [[https://docs.oracle.com/ | + | |
- | * [[https://linoxide.com/exclude-specific-package-apt-get-upgrade/|How to Exclude Specific Package from apt-get Upgrade]] | + | |
+ | | ||
+ | - Uninstall the guest additions< | ||
+ | | ||
+ | * [[https://kifarunix.com/install-virtualbox-guest-additions-on-debian-11/|Install VirtualBox Guest Additions on Debian 11]] | ||
+ | ===== Reboot (dead) vm ===== | ||
+ | - '' | ||
+ | - '' | ||
+ | - '' | ||