Useful and lesser-known features of VirtualBox
New Warehouses
VBoxManage lets you quickly create empty media in the current directory (Listing 2). The disc
option creates a disk image; alternatively, dvd
creates an empty DVD, or floppy
creates an empty floppy disk image. --size
is the size of the data carrier in megabytes.
Listing 2
Creating Empty Media
For hard disk images, the additional --format
parameter lets you explicitly specify the format: VDI
, VMDK
, or VHD
. The media is automatically registered by VBoxManage, so you will find it immediately in the VirtualBox Manager under File | Virtual Media Manager. If necessary, click on Update.
VBoxManage also lets you convert a hard disk image created with dd
to VDI, VHD, or VMDK format. The commands from Listing 3 load the contents of the disk /dev/sdc
into the disc.raw
image and convert it into the image.vdi
image.
Listing 3
Loading the Disk Contents
VirtualBox can also pass a real hard disk or partition directly into the virtual machine. To do this, you first need to create an image file of your physical data carrier. The command from Listing 4 creates a new image named file.vmdk
in the /home/tim/
folder. If you mount the image on a virtual machine, it directly accesses the /dev/sdc
drive. However, the whole procedure requires VirtualBox to have read and write access to the /dev/sdc
drive.
Listing 4
Creating a New Image
Intervention
If the Guest Additions are installed on the guest system, you can start programs directly on the guest with VBoxManage. The command from Listing 5 logs into the virtual machine with Fedora 29 as the user tim and a password of 123456; when it gets there, it launches the gedit text editor.
Listing 5
Launching an App on the Guest
--exe
is followed by the full path to the program you wish to execute. In the case of a Windows virtual machine, you need to enter the backslashes in the path twice, such as --exe "C:\\Windows\\System32\\calc.exe"
. For a graphical X11 application to launch on a Linux guest, you need to set the DISPLAY
environment variable using the --putenv
parameter. You can also add further parameters to the program (Listing 6).
Listing 6
Adding Parameters
The parameters are always at the end following the two minus signs. In the example, gedit/arg0
indicates that the parameters for the gedit
program follow next. In the example, this is just the complete path to the text file that you want gedit to open.
The guestcontrol
command gives an insight into the state of the guest system if required (Listing 7, first line). Among other things, guestcontrol
also lists the current processes. If a process is hanging, you can kill it with closeprocess
(second line). --session-id
is the ID of the session in which the process is running. The number at the end represents the process ID of the troublemaker.
Listing 7
guestcontrol
Conclusions and Outlook
Additional commands for VBoxManage, including numerous examples, are available in the comprehensive user manual for VirtualBox [1]. If you work regularly with VirtualBox, you should at least browse the table of contents of the user manual: It provides many hints for interesting functions that are often overlooked or forgotten in everyday life.
Infos
- VirtualBox user manual: https://www.virtualbox.org/manual/UserManual.html
« Previous 1 2 3
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.