Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I was wondering if it's possible to run an Ubuntu virtual machine using VirtualBox in background, I mean, without any window open.

The idea is to connect via SSH to the Linux host, that would be running in background.

Has anyone ever done something like this? Is it possible?

share|improve this question
    
You mean connect via SSH to the linux guest? You can do this very easily with QEMU which will actually run the guest in your terminal. –  Felix Apr 28 '10 at 12:13
add comment

8 Answers

VBoxManage startvm $VM --type headless will start the specified virtual machine in the background.

To shut it down, request the shut down from the guest.

share|improve this answer
    
You will only be able to SSH into the machine if you've setup networking properly. I think you need to use bridged so that the VM and your machine are on the same network. Also, VirtualBox will still run the gui of the target OS and you can connect to it via remote desktop, "rdesktop" (get from apt since you're in ubuntu) –  basszero Apr 28 '10 at 11:36
1  
True. I assume that the VM is run usually through the VirtualBox GUI first to get it installed and configured. Only use VBoxManage once everything (including networking) works. –  developmentalinsanity Apr 28 '10 at 11:48
add comment

Absolutely! You are looking for a headless installation (Virtualbox). The way to start the machine from the command line is something like:

VBoxHeadless --startvm Debian --vrdp=off

However you will need some way to connect. What I do is mapping ports between guest and host. With this configuration, your host 2222 port will be mapped to port 22 of your guest machine.

VBoxManage setextradata "Debian" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP  
VBoxManage setextradata "Debian" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22  
VBoxManage setextradata "Debian" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222  

After that you can log in with:

ssh localhost -p2222
share|improve this answer
add comment

This is built into VirtualBox 4.2, simply hold down Shift when launching the VM from the Manager.

https://blogs.oracle.com/fatbloke/entry/what_s_new_in_oracle

share|improve this answer
add comment

I don't think seamless mode is quite what he's looking for here, I think the proper thing would be VBoxHeadless which details of you can find in the manual. It runs using a command-lin interface and would be used, for example, if a virtual machine was running on a server but the display was not wanted from the server. You will be able to remote desktop onto the machine (providing you know how to set the option via command line).

I would reccomend asking this in the virtualbox forums. Actually, do a search first as I expect this has already been asked.


VBoxManage was the right thing, sorry. Link the info in the manual http://www.virtualbox.org/manual/ch08.html

share|improve this answer
add comment

I'm using VBoxTool from http://vboxtool.sourceforge.net/ and it works perfectly for me. It can autostart VMs at boot and stop/save VMs at shutdown and provides a simple clean command line interface.

share|improve this answer
add comment

I found that the headless mode seems to work fine when backgrounding in Linux (CentOS 5.6), but you lose access to the RDP functionality as long as the process is backgrounded. Do an 'fg' to bring the process back to the foreground, and RDP functionality is restored. Looks like starting the vm headless is best accomplished through an init script, where interactivity with the console is not required.

share|improve this answer
add comment

Something like "Seamless mode" ? Its very much possible with VMware's Unity mode.

share|improve this answer
add comment

an alternative to VBoxManage startvm "{VMName}" --type headless is
VBoxHeadless -startvm "{VMName}"

Amusingly enough, I just finished figuring out how to run a VM headless, over RDP.

Note - At least on windows, it will block your command window. If you need to continue using your console window, open another to start the VM in.

To shut the VM down, you request the Guest OS to shutdown. VBoxHeadless releases the console when the Guest is fully shut down (You can Ctrl+C, but I think it may be analogus to a hard reset on a real machine).

share|improve this answer
    
The fact that vboxheadless blocks the console very much defeats the purpose of a headless mode. On Mac OS X (and presumably on Linux and Solaris) the headless mode works when you send vboxheadless into the background using &. –  Andrew J. Brehm Apr 28 '10 at 11:48
    
I'd imagine there is a way to do that on windows, I just haven't found it. In any event, a headless vm certainly uses less resources on the server computer than one running a full GUI. –  Fake Name Apr 28 '10 at 12:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.