Sunday, December 26, 2010

[kr-en04] Executing VM VirtualBox in background

In order to start a virtual machine in VirtualBox from GUI is necessary to have the virtual machines manager open. When you need to start a virtual machine remotely and only has access from a console, we present an useful procedure to carry on.

Start virtual machine "CGUNO-CentOS-5.2". This has to be the same name assigned during VM creation.
$ VBoxHeadless --startvm "CGUNO-CentOS-5.2" --vrdp=off&

Check process in execution
$ ps aux | grep Box
soporte 6222 75.2 3.1 320292 129004 pts/1 Sl 15:47 7:20 /usr/lib/virtualbox/VBoxHeadless --startvm CGUNO-CentOS-5.2 --vrdp=off
soporte 6236 0.0 0.1 82836 4256 pts/1 S 15:47 0:00 /usr/lib/virtualbox/VBoxXPCOMIPCD
soporte 6243 0.0 0.1 159752 6844 ? Sl 15:47 0:00 /usr/lib/virtualbox/VBoxSVC --pipe 8 --auto-shutdown
soporte 6297 0.0 0.0 7240 820 pts/1 R+ 15:57 0:00 grep Box

Check if you have ping answer from machine previously started
$ ping 192.168.228.252
PING 192.168.228.252 (192.168.228.252) 56(84) bytes of data.
64 bytes from 192.168.228.252: icmp_seq=1 ttl=64 time=2.72 ms
64 bytes from 192.168.228.252: icmp_seq=2 ttl=64 time=0.102 ms
^C
--- 192.168.228.252 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1005ms
rtt min/avg/max/mdev = 0.102/1.415/2.729/1.314 ms

Add a command line in rc.local file in order to start the VM during operating system booting
[root@localhost]# vim /etc/rc.local
#!/bin/sh -e

# CGUNO
VBoxHeadless --startvm "CGUNO-CentOS-5.2" --vrdp=off&

0 comentarios: