VirtualBox

VirtualBox is a hypervisor used to run operating systems in a special environment, called a virtual machine, on top of the existing operating system. VirtualBox is in constant development and new features are implemented continuously. It comes with a Qt GUI interface, as well as headless and SDL command-line tools for managing and running virtual machines.

In order to integrate functions of the host system to the guests, including shared folders and clipboard, video acceleration and a seamless window integration mode, guest additions are provided for some guest operating systems.

Installation steps for Arch Linux hosts

In order to launch VirtualBox virtual machines on your Arch Linux box, follow these installation steps.

Install the core packages

Install the virtualbox package. You will need to choose a package to provide host modules:

Sign modules

When using a custom kernel with CONFIG_MODULE_SIG_FORCE option enabled, you must sign your modules with a key generated during kernel compilation.

Navigate to your kernel tree folder and execute the following command:

for module in `ls /lib/modules/$(uname -r)/kernel/misc/{vboxdrv.ko,vboxnetadp.ko,vboxnetflt.ko,vboxpci.ko}` ; 
do ./scripts/sign-file sha1 certs/signing_key.pem certs/signing_key.x509 $module ; done 

Note: Hashing algorithm does not have to match the one configured, but it must be built into the kernel.

Load the VirtualBox kernel modules

virtualbox-host-modules-arch and virtualbox-host-dkms use systemd-modules-load.service to load all four VirtualBox modules automatically at boot time. For the modules to be loaded after installation, either reboot or load the modules once manually.

Note: If you do not want the VirtualBox modules to be automatically loaded at boot time, you have to mask the default /usr/lib/modules-load.d/virtualbox-host-modules-arch.conf (or /usr/lib/modules-load.d/virtualbox-host-dkms.conf) by creating an empty file (or symlink to /dev/null) with the same name in /etc/modules-load.d/.

Among the kernel modules VirtualBox uses, there is a mandatory module named vboxdrv, which must be loaded before any virtual machines can run.

To load the module manually, run:

modprobe vboxdrv 

or

sudo nano /etc/modules-load.d/virtualbox.conf

add line

vboxdrv 

and add user group to virtualbox

sudo gpasswd -a [username] vboxusers

 

The following modules are optional but are recommended if you do not want to be bothered in some advanced configurations (precised here after): vboxnetadpvboxnetflt and vboxpci.

  • vboxnetadp and vboxnetflt are both needed when you intend to use the bridged or host-only networking feature. More precisely, vboxnetadp is needed to create the host interface in the VirtualBox global preferences, and vboxnetflt is needed to launch a virtual machine using that network interface.
  • vboxpci is needed when your virtual machine needs to pass through a PCI device on your host.

Note: If the VirtualBox kernel modules were loaded in the kernel while you updated the modules, you need to reload them manually to use the new updated version. To do it, run vboxreload as root.

Accessing host USB devices in guest

To use the USB ports of your host machine in your virtual machines, add users that will be authorized to use this feature to the vboxusers user group.

Guest additions disc

It is also recommended to install the virtualbox-guest-iso package on the host running VirtualBox. This package will act as a disc image that can be used to install the guest additions onto guest systems other than Arch Linux. The .iso file will be located at /usr/lib/virtualbox/additions/VBoxGuestAdditions.iso, and may have to be mounted manually inside the virtual machine. Once mounted, you can run the guest additions installer inside the guest.

Extension pack

The Oracle Extension Pack provides additional features and is released under a non-free license only available for personal use. To install it, the virtualbox-ext-oracleAUR package is available, and a prebuilt version can be found in the seblu repository (Unofficial).

seblu

  • Maintainer: Sébastien Luttringer
  • Description: All seblu useful pre-built packages, some homemade (virtualbox-ext-oracle, linux-seblu-meta, bedup).
  • Key-ID: Not required, as maintainer is a Developer
[seblu]
Server = http://al.seblu.net/$repo/$arch 

If you prefer to use the traditional and manual way: download the extension manually and install it via the GUI (File > Preferences > Extensions) or via VBoxManage extpack install <.vbox-extpack>, make sure you have a toolkit like Polkit to grant privileged access to VirtualBox. The installation of this extension requires root access.

Front-ends

VirtualBox comes with three front-ends:

  • If you want to use VirtualBox with the regular GUI, use VirtualBox.
  • If you want to launch and manage your virtual machines from the command-line, use the VBoxSDL command, which only provides a plain window for the virtual machine without any overlays.
  • If you want to use VirtualBox without running any GUI (e.g. on a server), use the VBoxHeadless command. With the VRDP extension you can still remotely access the displays of your virtual machines.

Finally, you can also use phpVirtualBox to administrate your virtual machines via a web interface.

Refer to the VirtualBox manual to learn how to create virtual machines.

Warning: If you intend to store virtual disk images on a Btrfs file system, before creating any images, you should consider disabling copy-on-write for the destination directory of these images.

Load the VirtualBox kernel modules

To load the modules automatically, enable vboxservice.service which loads the modules and synchronizes the guest’s system time with the host.

To load the modules manually, type:

# modprobe -a vboxguest vboxsf vboxvideo

virtualbox-guest-dkms uses systemd-modules-load.service to load its modules at boot time.

Enable shared folders

Shared folders are managed on the host, in the settings of the Virtual Machine accessible via the GUI of VirtualBox, in the Shared Folders tab. There, Folder Path, the name of the mount point identified by Folder name, and options like Read-onlyAuto-mount and Make permanent can be specified. These parameters can be defined with the VBoxManage command line utility. See there for more details.

No matter which method you will use to mount your folder, all methods require some steps first.

To avoid this issue /sbin/mount.vboxsf: mounting failed with the error: No such device, make sure the vboxsf kernel module is properly loaded. It should be, since we enabled all guest kernel modules previously.

Two additional steps are needed in order for the mount point to be accessible from users other than root:

  • the virtualbox-guest-utils package created a group vboxsf (done in a previous step);
  • your user must be in vboxsf user group.

Manual mounting

Use the following command to mount your folder in your Condres OS guest:

mount -t vboxsf shared_folder_name mount_point_on_guest_system

The vboxsf filesystem offers other options which can be displayed with this command:

 mount.vboxsf

For example if the user was not in the vboxsf group, we could have used this command to give access our mountpoint to him:

mount -t vboxsf -o uid=1000,gid=1000 home /mnt 

Where uid and gid are values corresponding to the users we want to give access to. These values are obtained from the id command run against this user.

Automounting

Note: Automounting requires the vboxservice.service to be enabled/started.

systemctl enable vboxservice.service
systemctl start vboxservice.service

In order for the automounting feature to work you must have checked the auto-mount checkbox in the GUI or used the optional --automount argument with the command VBoxManage sharedfolder.

The shared folder should now appear in /media/sf_shared_folder_name. If users in media cannot access the shared folders, check that media has permissions 755 or has group ownership vboxsf if using permission 750. This is currently not the default if media is created by installing virtualbox-guest-utils.

You can use symlinks if you want to have a more convenient access and avoid to browse in that directory, e.g.:

ln -s /media/sf_shared_folder_name ~/my_documents

 

Calogero Scarnà
Calogero Scarnà
Articoli: 299

Newsletter

Inserisci il tuo nome e il tuo indirizzo email qui sotto e iscriviti alla nostra newsletter