Managing VirtualBox Virtual Machines (with examples)
- Windows
- November 5, 2023
VirtualBox is a powerful virtualization software that allows users to run multiple operating systems on a single physical machine. The virtualboxvm
command-line tool provides a convenient way to manage VirtualBox virtual machines. In this article, we will explore different use cases of the virtualboxvm
command, along with code examples and explanations for each argument.
1. Starting a Virtual Machine
To start a virtual machine, use the --startvm
argument followed by the name or UUID of the virtual machine. This command will power on the virtual machine and initiate the boot process.
virtualboxvm --startvm MyVM
Motivation: This example demonstrates how to start a specific virtual machine named “MyVM”. By using the virtualboxvm
command, you can easily initiate the boot process for a specific virtual machine without opening the VirtualBox user interface.
Explanation:
--startvm
: Indicates that the following argument specifies the name or UUID of the virtual machine to start.name|uuid
: Specifies the name or UUID of the virtual machine.
Example Output: The virtual machine specified by the name “MyVM” will be started, and the operating system will begin the boot process.
2. Starting a Virtual Machine in Fullscreen Mode
To start a virtual machine in fullscreen mode, simply add the --fullscreen
argument after the --startvm
argument.
virtualboxvm --startvm MyVM --fullscreen
Motivation: This example demonstrates how to start a virtual machine in fullscreen mode, providing a seamless and immersive experience. By utilizing the --fullscreen
option, the virtual machine will automatically adjust to fit the entire display, maximizing the utilization of the screen real estate.
Explanation:
--fullscreen
: Specifies that the virtual machine should be started in fullscreen mode.
Example Output: The specified virtual machine “MyVM” will be launched in fullscreen mode, occupying the entire screen with the virtual machine display.
3. Mounting a DVD Image File
To mount a DVD image file to a virtual machine, use the --dvd
argument followed by the path to the image file. This will make the DVD image file accessible within the virtual machine.
virtualboxvm --startvm MyVM --dvd C:\path\to\image_file.iso
Motivation: This example showcases how to mount a DVD image file to a specific virtual machine. By using the --dvd
option, you can easily provide the virtual machine with access to the contents of the DVD image file without the need for physical media.
Explanation:
--dvd
: Indicates that the following argument specifies the path to the DVD image file.path\to\image_file
: Specifies the path to the DVD image file.
Example Output: The DVD image file located at “C:\path\to\image_file.iso” will be mounted within the virtual machine specified by “MyVM”, enabling access to its contents.
4. Displaying a Command-Line Window with Debug Information
To display a command-line window with debug information while starting a virtual machine, use the --debug-command-line
argument after the --startvm
argument.
virtualboxvm --startvm MyVM --debug-command-line
Motivation: This example illustrates how to launch a virtual machine while monitoring the underlying processes and debug information. The --debug-command-line
option will spawn a separate command-line window displaying useful debug information, allowing you to observe the startup process and identify any potential issues.
Explanation:
--debug-command-line
: Specifies that a command-line window with debug information should be displayed.
Example Output: When executing the command, a command-line window will appear alongside the virtual machine startup process, providing detailed debug information about the launching process.
5. Starting a Virtual Machine in a Paused State
To start a virtual machine in a paused state, add the --start-paused
argument after the --startvm
argument.
virtualboxvm --startvm MyVM --start-paused
Motivation: This example demonstrates how to start a virtual machine in a paused state, postponing its execution until explicitly resumed. This can be useful for taking snapshots, performing troubleshooting, or preparing the virtual machine before allowing it to continue running.
Explanation:
--start-paused
: Specifies that the virtual machine should be started in a paused state.
Example Output:
The specified virtual machine “MyVM” will be started but will remain in a paused state, halting its execution until manually resumed using the VirtualBox user interface or the vboxmanage
command-line tool.
These examples highlight different use cases of the virtualboxvm
command, providing a comprehensive understanding of its functionalities. By utilizing this command-line tool, managing VirtualBox virtual machines becomes more efficient and accessible, enabling seamless virtualization experiences.