Skip to content

Latest commit

 

History

History
173 lines (115 loc) · 5 KB

os-virtual-box.md

File metadata and controls

173 lines (115 loc) · 5 KB

VirtualBox notes

In the context of a Windows host and Linux guests.

 

🧬 Install the Guest Additions for advanced VirtualBox integration

From the Linux VM:

  1. Ensure that the network interface is enabled and connected to the internet.

  2. Upgrade all packages:

sudo apt update && sudo apt upgrade
  1. Install packages required by the Guest Additions builder:
sudo apt install gcc make perl kernel-devel
  1. In the VirtualBox menu, trigger the Insert Guest Additions CD Image feature.

  2. Build and install the Guest Additions (ensure that no error occurs):

cd /media/*/VBox_GAs_*/ && sudo ./VBoxLinuxAdditions.run
  1. Restart the VM and check that the following features are working properly:
  • seamless mouse integration
  • adaptative screen size
  • shared clipboard
  • file manager
  • ...

More info here.

 

📈 Convert fixed size VMDK disk image to dynamic size VDI

From a Windows command terminal, run the VirtualBox clone command with options:

VBoxManage.exe clonemedium vm-disk.vmdk vm-disk.vdi --format VDI --variant Standard

 

📉 Shrink size of dynamic size VDI disk image

  1. From the Linux VM, install zerofree utility:
sudo apt install zerofree
  1. From the Linux VM recovery mode, open a root prompt and prepare empty space to compacting:
# Determine the device to work on and the type of file system used
df -Th

# Let say that (to be adapted):
DEVICE=/dev/sda1
FSTYPE=ext4

# Stop services that could be writing on the disk
systemctl stop systemd-journald.socket
systemctl stop systemd-journald.service
sudo swapoff -a

# Remount the device in read-only mode
mount -n -o remount,ro -t $FSTYPE $DEVICE /

# Prepare empty space for compacting
zerofree -v /dev/sda1

# Shut down the VM
shutdown -P now
  1. From a Windows command terminal, run the VirtualBox compacting command:
VBoxManage.exe modifymedium disk vm-disk.vdi --compact

 

✏ Rename a virtual machine

From the GUI:

  • select the virtual machine in the list
  • open the Settings... window
  • under the Basic tab of the General section, use the Name field to set a new name
  • click the OK button to apply the change

 

🚚 Move a virtual machine

From the GUI:

  • select the virtual machine in the list
  • open the Move... window
  • select the desired parent directory for the directory containing the virtual machine
  • click the Select button to apply the change

 

🏷 Rename/move a virtual disk

From the GUI:

  • open the Virtual Media Manager... window from the File menu (or CTRL+D)
  • select the virtual disk in the list
  • under the Attributes tab, use the Location field to set a new name and/or location
  • click the Apply button to apply the change(s)

 

↔ Transfer files between host and guest without mounting a shared folder

From a running virtual machine window:

  • open the File Manager... window from the Machine menu
  • enable all panels (Session, Options, Operations, Log)
  • type a valid user name and password in the dedicated fields
  • click the Create Session button to connect to the virtual machine
  • use the left (host) and right (guest) file explorers to transfer files between host and guest systems
  • click the Close Session button when done

 

📁 Automatically mount a Windows host folder in the Linux guest VM

These are the requirements for a Linux VM user to be able to access automatically mounted shared folders:

  • the Guest Additions must have been installed properly in the VM
  • the user in the VM must belong to the group vboxsf: sudo adduser $USER vboxsf

Provided the requirements are fulfilled:

  • user the Devices > Shared Folders > Shared Folder Settings... window to define a new shared folder
  • choose a name to identify the shared folder from inside the Linux guest VM
  • check options Auto-mount and Make Permanent
  • leave the field Mount point empty
  • save and validate (OK button twice)

A new media should be detected and automatically mounted in the Linux guest, here: /media/sf_<name>/

 

📺 Higher screen resolution at startup

This information is unsure and should be treated cautiously.

It seems that from version 6.1 of VirtualBox, the screen resolution at startup is fixed to 800×600 pixels which is quite low for some modern graphical Linux installers.

A workaround to that is to check the Enable EFI (special OSes only) option in the Motherboard tab of the System settings before installing Linux.

Be carefull: switching EFI on after having already installed Linux may lead to major malfunction of the VM.

 

⏲ Prevent automatic time synchronization of the guest OS by VirtualBox

From a Windows command terminal, run the VirtualBox manage command, on the desired virtual machine, to set its GetHostTimeDisabled property:

VBoxManage.exe setextradata VM-NAME "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1