How to Manage Virtual Machines Using 'vboxmanage-controlvm' (with Examples)
The vboxmanage controlvm
command is a versatile tool provided by Oracle’s VirtualBox, allowing users to manage the state and settings of currently running virtual machines (VMs). This command simplifies VM management by offering various options to pause, resume, reset, power off, and perform other actions on VMs, facilitating seamless virtualization operations.
Use case 1: Temporarily Stop the Execution of a Virtual Machine
Code:
VBoxManage controlvm uuid|vm_name pause
Motivation:
This command is particularly useful when you need to temporarily halt a virtual machine’s operations, perhaps to free up system resources temporarily or to investigate a running process without interference. By pausing a VM, you ensure that the VM’s state is preserved without utilizing significant host resources.
Explanation:
VBoxManage
: This is the command-line tool to manage VirtualBox VMs.controlvm
: This sub-command allows various controls over a running VM.uuid|vm_name
: This specifies the unique identifier or name of the virtual machine you want to manage.pause
: This action pauses the execution of the specified VM.
Example output:
VM has been paused.
Use case 2: Resume the Execution of a Paused Virtual Machine
Code:
VBoxManage controlvm uuid|vm_name resume
Motivation:
A paused virtual machine can be resumed to continue its operations from the exact point where it was paused. This can be beneficial for users who previously paused their VM to liberate system resources and now wish to continue their tasks seamlessly.
Explanation:
VBoxManage
: Command-line tool for managing VirtualBox.controlvm
: Allows control over a running VM.uuid|vm_name
: Unique identifier or name of the VM to act upon.resume
: This parameter resumes the VM from its paused state.
Example output:
VM has resumed execution.
Use case 3: Perform a Cold Reset on the Virtual Machine
Code:
VBoxManage controlvm uuid|vm_name reset
Motivation:
Resetting a VM is the equivalent of rebooting a physical machine with the reset button. This action is ideal for recovery when a VM becomes unresponsive and requires a complete restart to resume normal functioning.
Explanation:
VBoxManage
: Manages VirtualBox VMs via command line.controlvm
: Used to control a running VM.uuid|vm_name
: Identifies the target virtual machine.reset
: Forces the VM to reset, similar to a hard reboot.
Example output:
VM has been reset.
Use case 4: Power Off a Virtual Machine
Code:
VBoxManage controlvm uuid|vm_name poweroff
Motivation:
Powering off a VM has the same immediate effect as unplugging a computer’s power cable. This command is crucial during emergencies or when a rapid shutdown of the VM is necessary without consideration for any unsaved data or ongoing processes.
Explanation:
VBoxManage
: VirtualBox command-line management tool.controlvm
: Facilitates control commands for a running VM.uuid|vm_name
: Indicates the specific VM to affect.poweroff
: Instantly powers off the specified virtual machine.
Example output:
VM has been powered off.
Use case 5: Shutdown the Virtual Machine and Save Its Current State
Code:
VBoxManage controlvm uuid|vm_name savestate
Motivation:
This command allows a VM to be saved in its current state, enabling users to shut down their machine without losing progress. When the VM is started again, it resumes right where it was left off. This is particularly useful when users need to preserve the VM’s state for a later session.
Explanation:
VBoxManage
: The command-line interface for VirtualBox management.controlvm
: Executes control commands on a running VM.uuid|vm_name
: Specifies which virtual machine will be affected.savestate
: Saves the current state of the specified VM and shuts it down.
Example output:
VM state has been saved.
Use case 6: Send an ACPI Shutdown Signal to the Virtual Machine
Code:
VBoxManage controlvm uuid|vm_name acpipowerbutton
Motivation:
Sending an ACPI shutdown signal is a graceful way to initiate a shutdown for a VM. This mirrors pressing the power button on a physical computer, allowing running applications to close properly and ensuring that the shutdown process is safely handled by the guest OS.
Explanation:
VBoxManage
: The command-line utility for VirtualBox tasks.controlvm
: Used to issue commands to a running VM.uuid|vm_name
: Identifies the virtual machine in question.acpipowerbutton
: Triggers the ACPI shutdown signal for the specified VM.
Example output:
ACPI shutdown signal sent.
Use case 7: Send a Command to Reboot the Virtual Machine
Code:
VBoxManage controlvm uuid|vm_name reboot
Motivation:
Rebooting a VM is sometimes required after software installations or updates. This command instructs the guest OS to perform a typical restart, akin to manually rebooting a physical machine from its operating system.
Explanation:
VBoxManage
: Command line tool for managing VirtualBox.controlvm
: Issues controls to a running virtual machine.uuid|vm_name
: Specifies the target virtual machine by name or UUID.reboot
: Sends a command to the VM to reboot itself using the guest OS.
Example output:
Reboot signal sent to the VM.
Use case 8: Shutdown the Virtual Machine Without Saving State
Code:
VBoxManage controlvm uuid|vm_name shutdown
Motivation:
Sometimes, users need to shut down a virtual machine quickly without maintaining any current state details. This command provides a straightforward way to perform a standard shutdown through the guest OS.
Explanation:
VBoxManage
: Manages VirtualBox VMs using a command-line interface.controlvm
: Executes commands to control a running virtual machine.uuid|vm_name
: Identifies which virtual machine should be shut down.shutdown
: Initiates a shutdown sequence without saving the VM’s current state.
Example output:
Shutdown command issued.
Conclusion:
The vboxmanage controlvm
command offers comprehensive control over VirtualBox VMs, providing flexibility and power to manage virtual environments effectively. Whether you’re pausing for maintenance, performing a reset due to unresponsiveness, or issuing shutdown commands, this tool is invaluable for both casual users and IT professionals dealing with virtualization.