How to use the command 'vboxmanage-controlvm' (with examples)
The vboxmanage-controlvm
command is used to change the state and settings of a currently running virtual machine in VirtualBox. It provides various options to control the virtual machine’s execution, such as pausing, resuming, resetting, powering off, saving state, sending shutdown signals, and rebooting the guest operating system.
Use case 1: Temporarily stop the execution of a virtual machine
Code:
VBoxManage controlvm uuid|vm_name pause
Motivation: Pausing a virtual machine can be useful when you need to temporarily halt the execution, but want to keep the virtual machine in its current state. This can come in handy if you want to free up system resources or pause a running process for further investigation.
Explanation:
uuid|vm_name
: Either the UUID or the name of the virtual machine.pause
: This argument is used to pause the execution of the specified virtual machine.
Example output:
$ VBoxManage controlvm MyVM pause
Virtual machine 'MyVM' paused.
Use case 2: Resume the execution of a paused virtual machine
Code:
VBoxManage controlvm uuid|vm_name resume
Motivation: When you want to continue the execution of a paused virtual machine, you can use the resume
option. This allows the virtual machine to continue from where it was paused, without restarting it.
Explanation:
uuid|vm_name
: Either the UUID or the name of the virtual machine.resume
: This argument is used to resume the execution of the specified virtual machine which has been previously paused.
Example output:
$ VBoxManage controlvm MyVM resume
Virtual machine 'MyVM' resumed.
Use case 3: Perform a cold reset on the virtual machine
Code:
VBoxManage controlvm uuid|vm_name reset
Motivation: Performing a cold reset is akin to forcefully restarting a physical computer by cutting off the power and turning it back on. This can be helpful when you want to restart a virtual machine from scratch.
Explanation:
uuid|vm_name
: Either the UUID or the name of the virtual machine.reset
: This argument is used to initiate a cold reset on the specified virtual machine.
Example output:
$ VBoxManage controlvm MyVM reset
Virtual machine 'MyVM' reset.
Use case 4: Power off a virtual machine with the same effect as pulling the power cable of a computer
Code:
VBoxManage controlvm uuid|vm_name poweroff
Motivation: When you want to forcefully shut down a virtual machine without allowing it to terminate gracefully, you can use the poweroff
option. This is similar to pulling the power cable of a physical computer.
Explanation:
uuid|vm_name
: Either the UUID or the name of the virtual machine.poweroff
: This argument is used to power off the specified virtual machine immediately.
Example output:
$ VBoxManage controlvm MyVM poweroff
Virtual machine 'MyVM' powered off.
Use case 5: Shutdown the virtual machine and save its current state
Code:
VBoxManage controlvm uuid|vm_name savestate
Motivation: Saving the state of a virtual machine allows you to continue its execution from where you left off. This is useful when you need to shut down a virtual machine but want to easily resume its state later without going through the whole startup process.
Explanation:
uuid|vm_name
: Either the UUID or the name of the virtual machine.savestate
: This argument is used to initiate a shutdown of the specified virtual machine and save its current state.
Example output:
$ VBoxManage controlvm MyVM savestate
Virtual machine 'MyVM' saved state.
Use case 6: Send an ACPI (Advanced Configuration and Power Interface) shutdown signal to the virtual machine
Code:
VBoxManage controlvm uuid|vm_name acpipowerbutton
Motivation: Sending an ACPI shutdown signal allows you to trigger a graceful shutdown of the guest operating system running inside the virtual machine. This is similar to the power button functionality on a physical computer.
Explanation:
uuid|vm_name
: Either the UUID or the name of the virtual machine.acpipowerbutton
: This argument is used to send an ACPI shutdown signal to the specified virtual machine, requesting it to shut down gracefully.
Example output:
$ VBoxManage controlvm MyVM acpipowerbutton
Virtual machine 'MyVM' gracefully shutdown.
Use case 7: Send command to reboot itself to the guest OS
Code:
VBoxManage controlvm uuid|vm_name reboot
Motivation: If you need to restart the guest operating system inside the virtual machine, you can use the reboot
option. This sends a reboot command to the guest OS, allowing it to handle the restart process.
Explanation:
uuid|vm_name
: Either the UUID or the name of the virtual machine.reboot
: This argument is used to send a reboot command to the specified virtual machine, requesting it to restart its guest operating system.
Example output:
$ VBoxManage controlvm MyVM reboot
Virtual machine 'MyVM' rebooting.
Use case 8: Shutdown the virtual machine without saving its state
Code:
VBoxManage controlvm uuid|vm_name shutdown
Motivation: When you want to shut down a virtual machine without saving its state, you can use the shutdown
option. This is useful when you don’t need to preserve the current state of the virtual machine and want to start fresh the next time.
Explanation:
uuid|vm_name
: Either the UUID or the name of the virtual machine.shutdown
: This argument initiates a shutdown of the specified virtual machine without saving its state.
Example output:
$ VBoxManage controlvm MyVM shutdown
Virtual machine 'MyVM' shutting down.
Conclusion:
The vboxmanage-controlvm
command is a powerful tool for managing virtual machines in VirtualBox. It provides various options to control their execution, allowing you to pause, resume, reset, power off, save state, send shutdown signals, reboot the guest OS, and shut down without saving state. With these commands, you have greater flexibility in managing your virtual machines and their lifecycles.