VirtualBox: startup guest machine in background
October 31st, 2010 mysurface Posted in VBoxHeadless, VBoxManage, VirtualBox | Hits: 194042 | 13 Comments »
Usually we start our virtual machine by clicking through the GUI. If your guest machine is a server, it would be making more sense to be run as background process.
Well, my case, I have ‘gentoo’ installed in virtual box, which expose to outside world through ssh. I would like it to start as background process, how can I do that?
Virtual Box allows you to start your virtual machine through command line VBoxHeadless, by adding ‘&’, you can make the process run as background.
VBoxHeadless -s [guestname] &
I wrote a bash script to help myself perform the background startup, reboot, poweroff and status query. Assume my guest machine name as ‘gentoo’, I wrote a script name as ‘gentoo’. Now I can do ‘gentoo start’ to start it at background.
#!/bin/bash
if [[ -z "$1" ]]
then
echo "Usage:"
echo " gentoo [status|start|reboot|poweroff]"
exit
fi
if [[ $1 == "status" ]]
then
# print out the machine state
VBoxManage showvminfo gentoo | grep State
elif [[ $1 == "start" ]]
then
# start without vrdp
VBoxHeadless -s gentoo --vrdp=off &
elif [[ $1 == "reboot" ]]
then
# send ctrl+alt+del to guest machine
VBoxManage.exe controlvm gentoo keyboardputscancode 1d 38 53 b8 9d
elif [[ $1 == "poweroff" ]]
then
# simulate pressing power off button, will power cut immediately
VBoxManage controlvm gentoo poweroff
fi
With the capabilities of command line to manipulates the guest machine, it helps to support for more customization and automation. This is the main reason I like about VirtualBox.
Have fun :)
December 26th, 2010 at 5:59 pm
Hi there,
another useful thing is a little bash-function i wrote to get all installed machines with their current state.
—
vboxlist ()
{
vboxmanage list -l vms | egrep -i –color=auto ‘(Name: |State:)’ | sed ‘s/Name:[ \t]*\|State:[ \t]*//’ | sed ‘$!N;s/\n/ – /’
}
—
January 11th, 2011 at 3:37 am
Have you tried VMware??
http://tips-linux.net/en/linux-ubuntu/linux-software/linux-cross-platform/vmware-workstation-linux-full-701
February 28th, 2013 at 3:31 am
Thanks for the script. Works like a charm
May 23rd, 2015 at 3:58 pm
drove machine for a few of thousand kilometer after kilometer byi’d like to see that you identify provided i’m not component quite hard to succeeding, Randolph expressed. “i appreciate continuing a player that has to order his way obtained in this league,I had to work challenging into the category, yet,yet somehow I we had not stumbled upon a manner for you so far. i didn’t would be effective on to obtain tracfone minutes and steps to create the motor coachs dignity my family,permitting nevada T
June 30th, 2016 at 3:55 pm
Thanks for this amazing post!
July 28th, 2016 at 6:25 am
39a810e3-8d58-3dd8-9ab0-798250e7f4d0
November 1st, 2016 at 6:41 pm
I like perusing your internet site. Kudos!
October 19th, 2017 at 6:08 am
Tener más de 18 años. Gracias por sus comentarios.
November 10th, 2017 at 7:51 pm
Debe aceptar las condiciones de privacidad.
November 11th, 2017 at 6:55 pm
Deborafelizn@ si estas interasado escribime……
November 14th, 2017 at 6:45 am
Pero la sociedad condiciona nuestro ser real.
November 21st, 2017 at 2:39 pm
Always keep in mind that the price of diamond reduces as much as ten % on account of lower clarity.
Never pick the ring of the choice as it’s quite obvious that they might not
as if your choice. Twisting, warping or shifting that will loosen the stones is regarded as the
commmon damages which could get lucky and tiffany or prong settings.