Friday, January 27, 2012

Creating virtual machines using VBoxManage command

Please visit http://stdioe.blogspot.com/2012/01/install-vbox-with-extpack-on-ubuntu.html to read "Installing VBox with extpack on ubuntu server 11.10" article. This article is explain to installation steps of ubuntu server 11.10 and virtualbox 4.1 with screenshots and videos from zero. If you don't know or don't sure "how to" install them, that's will be helpful..



We can use VBoxManage command to create and manage a virtual machine. If we execute the VBoxManage command alone, It will get an output with all parameters and options as below:


support@tester:~$ VBoxManage
Oracle VM VirtualBox Command Line Management Interface Version 4.1.8
(C) 2005-2011 Oracle Corporation
All rights reserved.

Usage:

VBoxManage [-v|--version] print version number and exit
VBoxManage [-q|--nologo] ... suppress the logo

VBoxManage list [--long|-l] vms|runningvms|ostypes|hostdvds|hostfloppies|
bridgedifs|hostonlyifs|dhcpservers|hostinfo|
hostcpuids|hddbackends|hdds|dvds|floppies|
usbhost|usbfilters|systemproperties|extpacks

VBoxManage showvminfo <uuid>|<name> [--details]
[--machinereadable]
VBoxManage showvminfo <uuid>|<name> --log <idx>

VBoxManage registervm <filename>

VBoxManage unregistervm <uuid>|<name> [--delete]

VBoxManage createvm --name <name>
[--ostype <ostype>]
[--register]
[--basefolder <path>]
[--uuid <uuid>]

VBoxManage modifyvm <uuid|name>
[--name <name>]
[--ostype <ostype>]
[--memory <memorysize in MB>]
[--pagefusion on|off]
[--vram <vramsize in MB>]
[--acpi on|off]
[--pciattach 03:04.0]
[--pciattach 03:04.0@02:01.0]
[--pcidetach 03:04.0]
[--ioapic on|off]
[--pae on|off]
[--hpet on|off]
[--hwvirtex on|off]
[--hwvirtexexcl on|off]
[--nestedpaging on|off]
[--largepages on|off]
[--vtxvpid on|off]
[--synthcpu on|off]
[--cpuidset <leaf> <eax> <ebx> <ecx> <edx>]
[--cpuidremove <leaf>]
[--cpuidremoveall]
[--hardwareuuid <uuid>]
[--cpus <number>]
[--cpuhotplug on|off]
[--plugcpu <id>]
[--unplugcpu <id>]
[--cpuexecutioncap <1-100>]
[--rtcuseutc on|off]
[--monitorcount <number>]
[--accelerate3d on|off]
[--accelerate2dvideo on|off]
[--firmware bios|efi|efi32|efi64]
[--chipset ich9|piix3]
[--bioslogofadein on|off]
[--bioslogofadeout on|off]
[--bioslogodisplaytime <msec>]
[--bioslogoimagepath <imagepath>]
[--biosbootmenu disabled|menuonly|messageandmenu]
[--biossystemtimeoffset <msec>]
[--biospxedebug on|off]
[--boot<1-4> none|floppy|dvd|disk|net>]
[--nic<1-N> none|null|nat|bridged|intnet|hostonly|
generic]
[--nictype<1-N> Am79C970A|Am79C973|
82540EM|82543GC|82545EM|
virtio]
[--cableconnected<1-N> on|off]
[--nictrace<1-N> on|off]
[--nictracefile<1-N> <filename>]
[--nicproperty<1-N> name=[value]]
[--nicspeed<1-N> <kbps>]
[--nicbootprio<1-N> <priority>]
[--nicpromisc<1-N> deny|allow-vms|allow-all]
[--nicbandwidthgroup<1-N> none|<name>]
[--bridgeadapter<1-N> none|<devicename>]
[--hostonlyadapter<1-N> none|<devicename>]
[--intnet<1-N> <network name>]
[--natnet<1-N> <network>|default]
[--nicgenericdrv<1-N> <driver>
[--natsettings<1-N> [<mtu>],[<socksnd>],
[<sockrcv>],[<tcpsnd>],
[<tcprcv>]]
[--natpf<1-N> [<rulename>],tcp|udp,[<hostip>],
<hostport>,[<guestip>],<guestport>]
[--natpf<1-N> delete <rulename>]
[--nattftpprefix<1-N> <prefix>]
[--nattftpfile<1-N> <file>]
[--nattftpserver<1-N> <ip>]
[--natbindip<1-N> <ip>
[--natdnspassdomain<1-N> on|off]
[--natdnsproxy<1-N> on|off]
[--natdnshostresolver<1-N> on|off]
[--nataliasmode<1-N> default|[log],[proxyonly],
[sameports]]
[--macaddress<1-N> auto|<mac>]
[--mouse ps2|usb|usbtablet
[--keyboard ps2|usb
[--uart<1-N> off|<I/O base> <IRQ>]
[--uartmode<1-N> disconnected|
server <pipe>|
client <pipe>|
file <file>|
<devicename>]
[--guestmemoryballoon <balloonsize in MB>]
[--gueststatisticsinterval <seconds>]
[--audio none|null|oss|alsa|pulse]
[--audiocontroller ac97|hda|sb16]
[--clipboard disabled|hosttoguest|guesttohost|
bidirectional]
[--vrde on|off]
[--vrdeextpack default|<name>
[--vrdeproperty <name=[value]>]
[--vrdeport <hostport>]
[--vrdeaddress <hostip>]
[--vrdeauthtype null|external|guest]
[--vrdeauthlibrary default|<name>
[--vrdemulticon on|off]
[--vrdereusecon on|off]
[--vrdevideochannel on|off]
[--vrdevideochannelquality <percent>]
[--usb on|off]
[--usbehci on|off]
[--snapshotfolder default|<path>]
[--teleporter on|off]
[--teleporterport <port>]
[--teleporteraddress <address|empty>
[--teleporterpassword <password>]

VBoxManage clonevm <uuid>|<name>
[--snapshot <uuid>|<name>]
[--mode machine|machineandchildren|all]
[--options link|keepallmacs|keepnatmacs|
keepdisknames]
[--name <name>]
[--basefolder <basefolder>]
[--uuid <uuid>]
[--register]

VBoxManage import <ovf/ova>
[--dry-run|-n]
[--options keepallmacs|keepnatmacs]
[more options]
(run with -n to have options displayed
for a particular OVF)

VBoxManage export <machines> --output|-o <ovf/ova>
[--legacy09]
[--manifest]
[--vsys <number of virtual system>]
[--product <product name>]
[--producturl <product url>]
[--vendor <vendor name>]
[--vendorurl <vendor url>]
[--version <version info>]
[--eula <license text>]
[--eulafile <filename>]

VBoxManage startvm <uuid>|<name>...
[--type gui|sdl|headless]

VBoxManage controlvm <uuid>|<name>
pause|resume|reset|poweroff|savestate|
acpipowerbutton|acpisleepbutton|
keyboardputscancode <hex> [<hex> ...]|
setlinkstate<1-N> on|off |
nic<1-N> null|nat|bridged|intnet|hostonly|generic
[<devicename>] |
nictrace<1-N> on|off
nictracefile<1-N> <filename>
nicproperty<1-N> name=[value]
natpf<1-N> [<rulename>],tcp|udp,[<hostip>],
<hostport>,[<guestip>],<guestport>
natpf<1-N> delete <rulename>
guestmemoryballoon <balloonsize in MB>]
gueststatisticsinterval <seconds>]
usbattach <uuid>|<address> |
usbdetach <uuid>|<address> |
vrde on|off |
vrdeport <port> |
vrdeproperty <name=[value]> |
vrdevideochannelquality <percent>
setvideomodehint <xres> <yres> <bpp> [display] |
screenshotpng <file> [display] |
setcredentials <username> <password> <domain>
[--allowlocallogon <yes|no>] |
teleport --host <name> --port <port>
[--maxdowntime <msec>] [--password password]
plugcpu <id>
unplugcpu <id>
cpuexecutioncap <1-100>

VBoxManage discardstate <uuid>|<name>

VBoxManage adoptstate <uuid>|<name> <state_file>

VBoxManage snapshot <uuid>|<name>
take <name> [--description <desc>] [--pause] |
delete <uuid>|<name> |
restore <uuid>|<name> |
restorecurrent |
edit <uuid>|<name>|--current
[--name <name>]
[--description <desc>] |
list [--details|--machinereadable]
showvminfo <uuid>|<name>

VBoxManage closemedium disk|dvd|floppy <uuid>|<filename>
[--delete]

VBoxManage storageattach <uuid|vmname>
--storagectl <name>
[--port <number>]
[--device <number>]
[--type dvddrive|hdd|fdd]
[--medium none|emptydrive|
<uuid>|<filename>|host:<drive>|iscsi]
[--mtype normal|writethrough|immutable|shareable|
readonly|multiattach]
[--comment <text>]
[--setuuid <uuid>]
[--setparentuuid <uuid>]
[--passthrough on|off]
[--tempeject on|off]
[--nonrotational on|off]
[--bandwidthgroup <name>]
[--forceunmount]
[--server <name>|<ip>]
[--target <target>]
[--tport <port>]
[--lun <lun>]
[--encodedlun <lun>]
[--username <username>]
[--password <password>]
[--intnet]

VBoxManage storagectl <uuid|vmname>
--name <name>
[--add ide|sata|scsi|floppy|sas]
[--controller LSILogic|LSILogicSAS|BusLogic|
IntelAHCI|PIIX3|PIIX4|ICH6|I82078]
[--sataideemulation<1-4> <1-30>]
[--sataportcount <1-30>]
[--hostiocache on|off]
[--bootable on|off]
[--remove]

VBoxManage bandwidthctl <uuid|vmname>
--name <name>
[--add disk|network]
[--limit <megabytes per second>
[--delete]

VBoxManage showhdinfo <uuid>|<filename>

VBoxManage createhd --filename <filename>
--size <megabytes>|--sizebyte <bytes>
[--format VDI|VMDK|VHD] (default: VDI)
[--variant Standard,Fixed,Split2G,Stream,ESX]

VBoxManage modifyhd <uuid>|<filename>
[--type normal|writethrough|immutable|shareable|
readonly|multiattach]
[--autoreset on|off]
[--compact]
[--resize <megabytes>|--resizebyte <bytes>]

VBoxManage clonehd <uuid>|<filename> <uuid>|<outputfile>
[--format VDI|VMDK|VHD|RAW|<other>]
[--variant Standard,Fixed,Split2G,Stream,ESX]
[--existing]

VBoxManage convertfromraw <filename> <outputfile>
[--format VDI|VMDK|VHD]
[--variant Standard,Fixed,Split2G,Stream,ESX]
[--uuid <uuid>
VBoxManage convertfromraw stdin <outputfile> <bytes>
[--format VDI|VMDK|VHD]
[--variant Standard,Fixed,Split2G,Stream,ESX]
[--uuid <uuid>

VBoxManage getextradata global|<uuid>|<name>
<key>|enumerate

VBoxManage setextradata global|<uuid>|<name>
<key>
[<value>] (no value deletes key)

VBoxManage setproperty machinefolder default|<folder> |
vrdeauthlibrary default|<library> |
websrvauthlibrary default|null|<library> |
vrdeextpack null|<library> |
loghistorycount <value>

VBoxManage usbfilter add <index,0-N>
--target <uuid>|<name>|global
--name <string>
--action ignore|hold (global filters only)
[--active yes|no] (yes)
[--vendorid <XXXX>] (null)
[--productid <XXXX>] (null)
[--revision <IIFF>] (null)
[--manufacturer <string>] (null)
[--product <string>] (null)
[--remote yes|no] (null, VM filters only)
[--serialnumber <string>] (null)
[--maskedinterfaces <XXXXXXXX>]

VBoxManage usbfilter modify <index,0-N>
--target <uuid>|<name>|global
[--name <string>]
[--action ignore|hold] (global filters only)
[--active yes|no]
[--vendorid <XXXX>|""]
[--productid <XXXX>|""]
[--revision <IIFF>|""]
[--manufacturer <string>|""]
[--product <string>|""]
[--remote yes|no] (null, VM filters only)
[--serialnumber <string>|""]
[--maskedinterfaces <XXXXXXXX>]

VBoxManage usbfilter remove <index,0-N>
--target <uuid>|<name>|global

VBoxManage sharedfolder add <vmname>|<uuid>
--name <name> --hostpath <hostpath>
[--transient] [--readonly] [--automount]

VBoxManage sharedfolder remove <vmname>|<uuid>
--name <name> [--transient]

VBoxManage guestproperty get <vmname>|<uuid>
<property> [--verbose]

VBoxManage guestproperty set <vmname>|<uuid>
<property> [<value> [--flags <flags>]]

VBoxManage guestproperty enumerate <vmname>|<uuid>
[--patterns <patterns>]

VBoxManage guestproperty wait <vmname>|<uuid> <patterns>
[--timeout <msec>] [--fail-on-timeout]

VBoxManage guestcontrol <vmname>|<uuid>
exec[ute]
--image <path to program>
--username <name> --password <password>
[--dos2unix]
[--environment "<NAME>=<VALUE> [<NAME>=<VALUE>]"]
[--timeout <msec>] [--unix2dos] [--verbose]
[--wait-exit] [--wait-stdout] [--wait-stderr]
[-- [<argument1>] ... [<argumentN>]]

copyfrom
<source on guest> <destination on host>
--username <name> --password <password>
[--dryrun] [--follow] [--recursive] [--verbose]

copyto|cp
<source on host> <destination on guest>
--username <name> --password <password>
[--dryrun] [--follow] [--recursive] [--verbose]

createdir[ectory]|mkdir|md
<director[y|ies] to create on guest>
--username <name> --password <password>
[--parents] [--mode <mode>] [--verbose]

stat
<file element(s) to check on guest>
--username <name> --password <password>
[--verbose]

updateadditions
[--source <guest additions .ISO>] [--verbose]

VBoxManage debugvm <uuid>|<name>
dumpguestcore --filename <name> |
info <item> [args] |
injectnmi |
log [--release|--debug] <settings> ...|
logdest [--release|--debug] <settings> ...|
logflags [--release|--debug] <settings> ...|
osdetect |
osinfo |
getregisters [--cpu <id>] <reg>|all ... |
setregisters [--cpu <id>] <reg>=<value> ... |
statistics [--reset] [--pattern <pattern>]
[--descriptions]

VBoxManage metrics list [*|host|<vmname> [<metric_list>]]
(comma-separated)

VBoxManage metrics setup
[--period <seconds>] (default: 1)
[--samples <count>] (default: 1)
[--list]
[*|host|<vmname> [<metric_list>]]

VBoxManage metrics query [*|host|<vmname> [<metric_list>]]

VBoxManage metrics enable
[--list]
[*|host|<vmname> [<metric_list>]]

VBoxManage metrics disable
[--list]
[*|host|<vmname> [<metric_list>]]

VBoxManage metrics collect
[--period <seconds>] (default: 1)
[--samples <count>] (default: 1)
[--list]
[--detach]
[*|host|<vmname> [<metric_list>]]

VBoxManage hostonlyif ipconfig <name>
[--dhcp |
--ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |
--ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]
create |
remove <name>

VBoxManage dhcpserver add|modify --netname <network_name> |
--ifname <hostonly_if_name>
[--ip <ip_address>
--netmask <network_mask>
--lowerip <lower_ip>
--upperip <upper_ip>]
[--enable | --disable]

VBoxManage dhcpserver remove --netname <network_name> |
--ifname <hostonly_if_name>

VBoxManage extpack install [--replace] <tarball> |
uninstall [--force] <name> |
cleanup

Let's create a sample virtual machine:

1-) The first step is the VM creation, (We are using a "Ubuntu OS + VBox" system that is installed in "http://stdioe.blogspot.com/2012/01/install-vbox-with-extpack-on-ubuntu.html" article. It is recommanded to read that article first.)


support@tester:~$ VBoxManage createvm --name testMachine --ostype Debian --register
Virtual machine 'testMachine' is created and registered.UUID: e2bfd530-14fb-4b8e-8dc2-8523c9bd045e
Settings file: '/home/support/VirtualBox VMs/testMachine/testMachine.vbox'
support@tester:~$

2-) At this point, we can start with checking existing Virtual machine with following command:

support@tester:~$ VBoxManage showvminfo testMachine

Actually, our virtual machine has just been created but It hasn't got any hard drives and some of those settings may not required. For example, the existing virtual machine memory size is 128 megabytes. Probably you want to increase it. You may not want to use NAT mode ethernet device. Right now, let's change some options on our virtual sample.

3-) Change memory and then check it:


support@tester:~$ VBoxManage modifyvm testMachine --memory 256
support@tester:~$
support@tester:~$ VBoxManage showvminfo testMachine | grep "Memory size"
Memory size: 256MB

4-) Change nic (ethernet interface) bridge mode. We need a bridge adapter for this and the bridge adapter needs a physical interface on base OS. I am checking the pysical interface on base OS:

support@tester:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:1a:64:5b:60:2c
inet addr:172.28.202.216 Bcast:172.28.202.255 Mask:255.255.255.0
inet6 addr: fe80::21a:64ff:fe5b:602c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2932762 errors:0 dropped:0 overruns:0 frame:0
TX packets:1149518 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:936032419 (936.0 MB) TX bytes:89178513 (89.1 MB)
Interrupt:17 Memory:da000000-da012800

And I learned that my physical interface's name is "eth0". Right now, I can create a bridge adapter and check with these commands:

support@tester:~$ VBoxManage modifyvm testMachine --bridgeadapter1 eth0
support@tester:~$ VBoxManage modifyvm testMachine --nic1 bridged
support@tester:~$ VBoxManage showvminfo testMachine | grep "NIC 1"
NIC 1: MAC: 080027E31FFE, Attachment: Bridged Interface 'eth0', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny
support@tester:~$


5-) Create an HDD and attach to virtual machine using following commands:


support@tester:~$ VBoxManage createhd --filename testMachine.vdi --size 18000 --format
VDI0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Disk image created. UUID: 970c500d-2476-44ef-b11b-5938b5150c91
support@tester:~$ VBoxManage storagectl testMachine --name "SATA Controller" --add sata --controller IntelAhci
support@tester:~$ VBoxManage storageattach "testMachine" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium testMachine.vdi

and you can find the related information in "VBoxManage showvminfo testMachine" command output:


support@tester:~$
VBoxManage showvminfo testMachine
......
Storage Controller Name (0): SATA Controller
Storage Controller Type (0): IntelAhci
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0): 30
Storage Controller Port Count (0): 30
Storage Controller Bootable (0): on
SATA Controller (0, 0): /home/support/testMachine.vdi (UUID: 970c500d-2476-44ef-b11b-5938b5150c91)
......

Also you can change some of those options on HDD specifications and controller type and all of them. For example, you can select IDE for SATA in my sample. Or size of disk or disk format (VDI, VMDK, VHD) etc.

If you need, you can use "VBoxManage createhd", "VBoxManage modifyhd" or "VBoxManage clonehd" to create a new one, modify the existing one or create a copy of existing one...

6-) We need to mount a cdrom or dvd to our virtual machine to start operation system installation. The following command will download a dvd image from the debian site and do that mounting progress:

support@tester:~$ wget http://cdimage.debian.org/debian-cd/6.0.3/amd64/iso-cd/debian-6.0.3-amd64-netinst.iso
support@tester:~$ VBoxManage storagectl testMachine --name "IDE Controller" --add ide --controller PIIX4
support@tester:~$ VBoxManage storageattach testMachine --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium debian-6.0.3-amd64-i386-netinst.iso
When we execute 'VBoxManage showvminfo testMachine | grep "IDE Controller" ' command to check the last step, we should see following output:

support@tester:~$ VBoxManage showvminfo testMachine | grep "IDE Controller"
Storage Controller Name (1): IDE Controller
IDE Controller (1, 0): /home/support/debian-6.0.3-amd64-i386-netinst.iso (UUID: cbc77834-7434-4a3c-af96-858ae1af1731)
support@tester:~$



7-) Almost all mandatory steps are completed, except "remote display" one. We haven't got any GUI and we need a monitor to watch virtual machine output! We can use following first command to enable remote display feature and the second command to check the vrde option on our virtual machine.

support@tester:~$ VBoxManage modifyvm testMachine --vrde on
support@tester:~$ VBoxManage showvminfo testMachine | grep VRDE
VRDE: enabled (Address 0.0.0.0, Ports 3389, MultiConn: off, ReuseSingleConn: off, Authentication type: null)
VRDE property: TCP/Ports = "3389"
VRDE property: TCP/Address = <not set>
VRDE property: VideoChannel/Enabled = <not set>
VRDE property: VideoChannel/Quality = <not set>
VRDE property: VideoChannel/Downscale Protection = <not set>
VRDE property: Client/DisableDisplay = <not set>
VRDE property: Client/DisableInput = <not set>
VRDE property: Client/DisableAudio = <not set>
VRDE property: Client/DisableUSB = <not set>
VRDE property: Client/DisableClipboard = <not set>
VRDE property: Client/DisableUpstreamAudio = <not set>
VRDE property: H3DRedirect/Enabled = <not set>
VRDE property: Security/Method = <not set>
VRDE property: Security/ServerCertificate = <not set>
VRDE property: Security/ServerPrivateKey = <not set>
VRDE property: Security/CACertificate = <not set>
VRDE Connection: not activesupport@tester:~$

We can boot testMachine but we have only one session right on VRDE. If we connect to virtual machine remote display from more than one clients, we have to change MultiConn option to "on". Also, if the port 3389 is used by another process we have to change it. Let's change the port and the multiConn option and then check it again,

support@tester:~$ VBoxManage modifyvm testMachine --vrdemulticon on --vrdeport 3390
support@tester:~$ VBoxManage showvminfo testMachine | grep VRDE
VRDE: enabled (Address 0.0.0.0, Ports 3390, MultiConn: on, ReuseSingleConn: off, Authentication type: null)
VRDE property: TCP/Ports = "3390"
VRDE property: TCP/Address = <not set>
VRDE property: VideoChannel/Enabled = <not set>
VRDE property: VideoChannel/Quality = <not set>
VRDE property: VideoChannel/DownscaleProtection = <not set>
VRDE property: Client/DisableDisplay = <not set>
VRDE property: Client/DisableInput = <not set>
VRDE property: Client/DisableAudio = <not set>
VRDE property: Client/DisableUSB = <not set>
VRDE property: Client/DisableClipboard = <not set>
VRDE property: Client/DisableUpstreamAudio = <not set>
VRDE property: H3DRedirect/Enabled = <not set>
VRDE property: Security/Method = <not set>
VRDE property: Security/ServerCertificate = <not set>
VRDE property: Security/ServerPrivateKey = <not set>
VRDE property: Security/CACertificate = <not set>
VRDE Connection: not activesupport@tester:~$

8-) Well. Our Virtual Machine is really ready to boot right now. Let's boot it.

support@tester:~$ VBoxHeadless --startvm testMachine
Oracle VM VirtualBox Headless Interface 4.1.8(C) 2008-2011 Oracle Corporation
All rights reserved.

VRDE server is listening on port 3390.

This command does not release the treminal and if we close terminal window or press "ctrl+c", the virtual machine will be aborted. We will come back to this boot issue again.

9-) Connect to virtual machine via RDP client:

ismail@ismail-ThinkPad-T410:~$ rdesktop 172.28.202.216:3390
Autoselected keyboard map en-usWARNING: Remote desktop changed from 800x600 to 640x480.

and you can see something like this :


Ok. Everything is well. But we want to auto start this virtual machine when booting the base operating system that is an Ubuntu server 11.10. In this case we have to write a start-up shell script and apply with updare-rc.d to inittab.

10-) The most important step of writing the start-up shell script is to set the right ownership. Because, we did everything as support user. But root user will execute it, when the base operation system is booting.

#!/bin/bash

u=`/usr/bin/id -u`

case "$1" in
start)
if [ $u -eq 0 ]; then
/bin/su support -c '/usr/bin/VBoxHeadless --startvm prxySMS &'
else
/usr/bin/VBoxHeadless -startvm testMachine &
fi
;;
stop)
# something for shutdown virtual machine via vm OS, somehow ..
;;
restart)
# commands for restarting will come here then...hah?
stop
start
;;
status)
# May be shown running process with ps command with "| grep VBoxHeadless"
;;
*)
echo "Usage: /etc/init.d/prxySMS_starter :) [start|stop|restart|status]"
exit 1
;;
esac
exit 0

This file is recorded with the filename "testMachine_starter" in folder /etc/init.d. We give the execution permission using "chmod +x /etc/init.d/testMachine_starter". Now, we have to add it to startup with update-rc.d command like this,

ismail@ismail-ThinkPad-T410:~$  update-rc.d testMachine_starter defaults 95

I put a "95" option in command shown below because I want to start the virtual machine after others. This number part is not necessary.

11 comments:

  1. Nice step by step guide that got my VM up and running. Only modification for me was that I couldn't connect to the VRDE, not sure why... using VNC instead and that seems to work for me. To do that I added a "-m 9000" to the VBoxHeadless line, so it listened on port 9000 for VNC connections.

    The pictures were a nice touch, broke up the description into easy-to-digest chunks.

    Thanks for posting this, much appreciated.

    ReplyDelete
  2. Actually that was likely due to not having the extpack installed.. whoops.

    ReplyDelete
  3. Yes right, you have to installed extpack and have to use RDP connection to get screen of vm.

    ReplyDelete
  4. i love you man!

    i followed everything on your website and it worked as a charm.... i don't know exactly what i did, but it worked..!!!

    thanks a million!

    ReplyDelete
  5. Hey ...

    The virtual machine starts ok even with the command

    VBoxManage startvm 'pcname' --vrdp

    but how can I be sure that the IP address that I'm using to get the remote logging is the one that's assign to the vm host pc.

    Thanks

    ReplyDelete
  6. Nice question,

    You have got a host operation system and have got virtual systems. You writing that command on host system. You can check ip address of host system on same terminal with ipconfig command, too.

    You will use host ip address to get console of virtual systems ;) Because your VBox software running already on your Host System. you don't need to know ip address of virtual systems because you will not use virtual ip address to get their consoles.

    ReplyDelete
  7. Hello !
    im new here i've follow your instruction & everything work greate but there is a little problem i have encountered, my guest vm can't access internet if i set connection is bridge, vm can't get ip from dhcp. I must say that if i change it to nat it work. But in this case i can't access the guest from outside. Any ideas to solve this.
    Thanks you

    ReplyDelete
  8. Hello !
    im new here i've follow your instruction & everything work greate but there is a little problem i have encountered, my guest vm can't access internet if i set connection is bridge, vm can't get ip from dhcp. I must say that if i change it to nat it work. But in this case i can't access the guest from outside. Any ideas to solve this.
    Thanks you

    ReplyDelete
    Replies
    1. When you use bridged network, you have to be able to obtain IP address for a NEW MAC address. It may not be the case in some enterprise environements, schools or so. Even when you have set up MAC filtering in you home router.

      When you use NAT, you have the option to set up port forwarding, so the host adapter will listen on some ports, whose traffic is then forwarded into the virtual machine.

      Delete
  9. Hello,
    Yes, you can not access your virtual system from outside network when you are using NAT because, your virtual system address is not accessible already. This situation is not related VirtualBox or virtualization system. It's about network mathematics.

    Somehow you should did wrong something when you use bridge configuration.. I am not sure exactly where is the problem. I need data more to say more. If you write your "VBoxManage showvminfo [your-V-system-Name]" command output to me, may be I(or may be some one expect me, why not?) can help more. Normally networking steps are simple than VRDE case so, I didn't focus your case in this article. I didn't say any summarize expression like "| grep network" or something like this on the end of "VBoxManage " command.

    ReplyDelete
  10. I need to add the .vdi file from my disk while creating the vm.
    Is there a way to automate it?
    I mean create the VM and then Virtual hard disk setup I want to pick the USE EXISTING DISK Option by command and attach the image.

    ReplyDelete

Thanks