In the context of a Windows host and Linux guests.
From the Linux VM:
-
Ensure that the network interface is enabled and connected to the internet.
-
Upgrade all packages:
sudo apt update && sudo apt upgrade
- Install packages required by the Guest Additions builder:
sudo apt install gcc make perl kernel-devel
-
In the VirtualBox menu, trigger the Insert Guest Additions CD Image feature.
-
Build and install the Guest Additions (ensure that no error occurs):
cd /media/*/VBox_GAs_*/ && sudo ./VBoxLinuxAdditions.run
- 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.
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
- From the Linux VM, install
zerofree
utility:
sudo apt install zerofree
- 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
- From a Windows command terminal, run the VirtualBox compacting command:
VBoxManage.exe modifymedium disk vm-disk.vdi --compact
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
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
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)
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
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>/
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.
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