Running a virtual machine in VirtualBox without a GUI
Sometimes it becomes necessary to run a virtual machine on a host without X. I will talk about how to do this, having access to the host system only via ssh + rdp (Remote Desktop Protocol). the process I will describe for OC Ubuntu 9.10 as a host.
Let's start by installing VirtualBox.
First you need to install the dkms package (Dynamic Kernel Module Support Framework):
The VirtualBox website offers 2 options: register the source of packages (
it may also require dependencies (some libraries for parsing xml, in which configs are stored, but they are much smaller than in the first case). If the installation did not complete due to dependencies, you can simply do it
while installing the dependencies and VirtualBox
approx. VirtualBox delivered. Let's start creating guest machines.
create the machine itself:
(name is the name of the machine, ostype is the type of system. A complete list of all types can be found by the command
configure
everything from a larger view . You can also specify NAT (
create an hdd disk for a virtual machine:
add an IDE controller to our machine
; we hook on to the IDE0 previously created hdd
on IDE1 we hook the installation image,
tell the machine to boot from the disk,
start the machine
in order to install the base system, use the rdp client (I have KDE, KRDC is included in the standard package). connect to the host machine on the port that was specified in the settings (
virtual machine
via ssh we stop the virtual machine via acpi
or
we talk more hard it loads with hdd
you can also unhook the installation disk
and run
some more useful commands again :
view all running machines
view information about the virtual machine
Thus, on one machine with a minimally installed system, you can raise several virtual ones for various purposes and experiments
Let's start by installing VirtualBox.
First you need to install the dkms package (Dynamic Kernel Module Support Framework):
sudo apt-get install dkms
The VirtualBox website offers 2 options: register the source of packages (
deb download.virtualbox.org/virtualbox/debian karmic non-free
) in /etc/apt/sources.list
either download and install the deb package. When I registered the source and made sudo apt-get install virtualbox-3.1
a bunch of packages from dependencies (including some for the GUI interface) I pulled. Therefore, it is better to download the deb package. Download, install:sudo dpkg -i virtualbox-3.1_3.1.0-55467_Ubuntu_karmic_i386.deb
it may also require dependencies (some libraries for parsing xml, in which configs are stored, but they are much smaller than in the first case). If the installation did not complete due to dependencies, you can simply do it
sudo apt-get -f install
while installing the dependencies and VirtualBox
approx. VirtualBox delivered. Let's start creating guest machines.
create the machine itself:
VBoxManage createvm --name ubuntu --ostype Ubuntu --register
(name is the name of the machine, ostype is the type of system. A complete list of all types can be found by the command
VBoxManage list ostypes
) we configure
VBoxManage modifyvm ubuntu --memory 512 --floppy disabled --audio none --nic1 bridged --bridgeadapter1 eth0 --vram 4 --accelerate3d off --boot1 disk --acpi on --cableconnected1 on --usb off --vrdp on --vrdpport 3390
everything from a larger view . You can also specify NAT (
--nic1 nat
) as the network type . also enable rdp create an hdd disk for a virtual machine:
VBoxManage createhd --filename /home/user/vbox/ubuntu.vdi --size 20000 --register
add an IDE controller to our machine
VBoxManage storagectl ubuntu --name "IDE Controller" --add ide
; we hook on to the IDE0 previously created hdd
VBoxManage storageattach ubuntu --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium /home/user/vbox/ubuntu.vdi
on IDE1 we hook the installation image,
VBoxManage storageattach ubuntu --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium /home/user/vbox/iso/ubuntu-9.10-alternate-i386.iso
tell the machine to boot from the disk,
VBoxManage modifyvm ubuntu --boot1 dvd
start the machine
nohup VBoxHeadless --startvm ubuntu &
in order to install the base system, use the rdp client (I have KDE, KRDC is included in the standard package). connect to the host machine on the port that was specified in the settings (
--vrdpport 3390
), put the system in, do it sudo apt-get install openssh-server
. now you can get to the virtual machine
VBoxManage controlvm ubuntu acpipowerbutton
via ssh we stop the virtual machine via acpi
or
VBoxManage controlvm ubuntu poweroff
we talk more hard it loads with hdd
VBoxManage modifyvm ubuntu --boot1 disk
you can also unhook the installation disk
VBoxManage storageattach ubuntu --storagectl "IDE Controller" --port 1 --device 0 --medium none
and run
nohup VBoxHeadless --startvm ubuntu &
some more useful commands again :
VBoxManage list runningvms
view all running machines
VBoxManage showvminfo ubuntu
view information about the virtual machine
Thus, on one machine with a minimally installed system, you can raise several virtual ones for various purposes and experiments