寻觅生命中的那一片浅草......

VboxHeadless & How To Swing It

About a week ago I posted a guide on how to install VirtualBox 3.0.2. While it is a great desktop virtualization solution there are a few things that leave you wanting more when it comes to a headless server. VMWare in this area still has much better solutions for managing several servers. But for small operations VirtualBox does have some options for managing your headless vm’s. This guide assumes that you already have VirtualBox 3 installed. If not I suggest you go take a look at my guide on how to perform the installation before you continue here.

Most tutorials you find out there will always suggest running thing through the sudo command as a regular user. However for this particular guide does not. The commands run here depend on the user running them. So in essence, if you follow this guide as it is written all VirtualBox settings are written to the ~/.VirtualBox/ directory. But, if you run these as root. All the configuration information would be stored in the /root/.VirtualBox/ directory.

So what we will need to continue are the following,

Remote connection to our host server (ssh is ideal)
rdesktop(linux) or Remote Desktop Connection(windows) installed to remotely connect to our headless vm’s from a remote computer
A .iso installation medium or an existing .vdi image to import.
First I’ll cover how to create a new virtual machine, afterwards I’ll go over how to import an existing virtual machine to your headless server.

Login to your Linux headless server and create a new vm. I’ve chosen to install a gentoo vm as it was the first .iso file I found on my computer.
$ VBoxManage createvm –name “Gentoo” –register
Output from previous commandVirtualBox Command Line Management Interface Version 3.0.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

Virtual machine ‘Gentoo’ is created and registered.
UUID: faa5fe89-f75a-4bc9-93b2-063630353e25
Settings file: ‘/scott/.VirtualBox/Machines/Gentoo/Gentoo.xml’
Next we must set our system settings for the virtual machines use. Here I will configure it with 512 megs of memory, enable ACPI, set the first boot device to a DVD, and configure the network adapter to use NAT instead of Bridged networking.

$ VBoxManage modifyvm “Gentoo” –memory “512” –acpi on –boot1 dvd –nic1 nat
Output from previous commandVirtualBox Command Line Management Interface Version 3.0.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
After defining the system settings, we must create the virtual hard disk. I will be making mine a 10gigabyte virtual disk.$ sudo VBoxManage createhd –filename “Gentoo.vdi” –size 10000 –remember
Output from previous commandVirtualBox Command Line Management Interface Version 3.0.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

0%…10%…20%…30%…40%…50%…60%…70%…80%…90%…100%
Disk image created. UUID: ce4226ed-fc66-4749-ac8e-b08975a66ce8
Attach our newly created virtual hard disk to our newly created virtual machine as the first hard drive.

$ VBoxManage modifyvm “Gentoo” –hda “Gentoo.vdi”

Output from previous commandVirtualBox Command Line Management Interface Version 3.0.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
Register our installation .iso file to our virtual machine so that it may boot from it to begin the installation. Be sure to replace the path with your relevant path.

$ VBoxManage modifyvm “Gentoo” –dvd /path/to/your/install.iso

Output from previous commandVirtualBox Command Line Management Interface Version 3.0.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
We should now be ready to start our vm. This will run the vm in the terminal as a background process.

$ VBoxHeadless –startvm “Gentoo” &

Assuming everything went smoothly you can now connect to your headless vm with a RDP viewer. Be sure to replace the “YOURSERVERIP” with your host server’s IP address.$ rdesktop -a 16 YOURSERVERIP
To stop your vm from command line.

$ VBoxManage controlvm “Gentoo” savestate

Most desktop computers should already have this. Ubuntu users can use the above command to run rdesktop. If you are in Gnome, it is also located under Applications > Internet > Remote Desktop Viewer. Windows user’s can use the Remote Desktop Connection utility found under Start > Programs > Accessories > Remote Desktop Connection.
So as a closing note, I would highly recommend heading over to http://www.virtualbox.org/manual/UserManual.html#id2515738 . Sun’s documentation on VirtualBox is very well written. There are tons of other things you can do from the command line to manage your vm’s.

尚无评论

发表评论

2024年四月
« 5月    
1234567
891011121314
15161718192021
22232425262728
2930