Running headless Linux guests on Windows host

This is for discussing general topics about how to use VirtualBox.

Running headless Linux guests on Windows host

Postby memilanuk » 14. Mar 2010, 02:51

Well... nuts. The motherboard on my physical 'server' box went south on me during a reboot (5-6yr old low-end PC), so my Ubuntu use is going 'virtual' for now until I can scrounge up a replacement. I've already got Ubuntu 9.1.0 Desktop running inside Virtual Box on my Windows Vista-64 desktop without any major problems, and I've installed/ran/deleted several 'server' VMs in Vbox on the same machine - but they've always popped open a display window, even if its a CLI-only display.

I'd like to run a completely 'headless' Ubuntu 9.10 Server VM - no display window at all. It appears from the manual and digging around on the forums that after I have the VM set up and the OS installed and no longer really need a display for that particular 'machine' I should be able to start it via VBoxHeadless from a console window, and no resulting display window should open up for that VM? If I start multiple VMs via VBoxHeadless from the same command-line window, I should still only have that *one* command line window open and active on my Vista desktop, not one display window per VM, which is what I've been getting for each one that I start from the regular GUI Vbox application window. Is this basically correct, or am I headed in the wrong direction?

It would be really slick if it was possible to start VMs in a headless mode from the Windows GUI application... but if I can make it work from the command line, that'd certainly fill the need for now.

Thanks,

Monte
memilanuk
 
Posts: 52
Joined: 1. Jul 2009, 18:16
Location: Wenatchee, WA USA
Primary OS: Linux other
VBox Version: PUEL
Guest OSses: openSuSE, Fedora, Ubuntu, CentOS

Re: Running headless Linux guests on Windows host

Postby Perryg » 14. Mar 2010, 03:26

AFAIK when you open a headless VM in Windows it always leaves behind the command window due to the way Windows handles command windows.
I heard of a hack to the registry a while back on how to make this command window go away after it ran the command (without killing the running program) and tried it once but it did not work for me.

Try searching for "close command window after execution of command". If you find it and get it to work I am sure a lot of people would be happy to hear about it.
Perryg
Site Moderator
 
Posts: 34322
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Running headless Linux guests on Windows host

Postby memilanuk » 14. Mar 2010, 03:46

Hmmm... the only results returned by the search engine for those words is this thread ;)

Is this the one you were referring to? For some reason I got the impression he was starting the command via a batch file or something, but upon re-reading the post again, it appears he just ran the command as listed and it left the window open - and tied up - until the guest VM was done/shutdown. Certainly seems less than ideal... I take it the Windows command line doesn't have anything resembling '&' i.e. 'vboxheadless -startvm "testbox" & '

Monte
memilanuk
 
Posts: 52
Joined: 1. Jul 2009, 18:16
Location: Wenatchee, WA USA
Primary OS: Linux other
VBox Version: PUEL
Guest OSses: openSuSE, Fedora, Ubuntu, CentOS

Re: Running headless Linux guests on Windows host

Postby Perryg » 14. Mar 2010, 04:39

That's not it. I am trying to remember what I searched for. I thought that was it but probably not. I will do some searching but I do know I found it via the search engine by telling it what I wanted and did not want it to do. You can also see all of the commands by opening a command window and typing command /? and cmd /?
The /c and eof seem to come to mind.

Edit: I mean to use the Internet search engines. Not that must about it here.
Perryg
Site Moderator
 
Posts: 34322
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Running headless Linux guests on Windows host

Postby memilanuk » 14. Mar 2010, 08:38

Well... so far that program on the page linked to on the thread I mentioned seems to work.

This page here:
http://www.turtle.dds.nl/run/

I added a directory under C:\Users\Monte\.VirtualBox named 'Scripts'. I downloaded the three files listed, but honestly, for this I don't think the 'stop.exe' file is necessary.

I renamed 'run.exe' to 'StartUbuntuServerHeadless.exe', and 'run.ini' to 'StartUbuntuServerHeadless.ini'. I put the following command after the 'EXECUTE =' stanza:
Code: Select all   Expand viewCollapse view
EXECUTE = "C:\Program Files\Sun\VirtualBox\VboxHeadless.exe" --startvm "Ubuntu Server"


For some reason when I tried adding the flag '--vrdp=no' it wouldn't start and run (at least I couldn't connect to the server via ssh), but it did when ran interactively from the command line?

I didn't seem to need the whole stop.exe or stop.ini thing, as I don't want to just kill the running Vbox process with the machine in it. At least not right now.

Anywho, I was able to (repeatedly) connect to the server via ssh, log in, start a screen session, drop the ssh session, restart a new one, log back in, and resume my screen session. I also tested the same process on my openSuSE Server VM which currently I can ping but I can't seem to ssh into... probably on the firewall on that machine needs tweaked...

To save the state of the VM when I want to not have it running I made another copy of 'run.exe' and 'run.ini', this time naming them 'SaveUbuntuServer.exe' and 'SaveUbuntuServer.ini', with the following in the .ini file:

Code: Select all   Expand viewCollapse view
EXECUTE = "C:\Program Files\Sun\VirtualBox\VboxManage.exe" controlvm "Ubuntu Server" savestate


Again, no stop.ini or stop.exe needed.

I found I can have the GUI control panel up and running, and start/save machines from the command line and watch them start, run, and save just like before... but with no open display window.

I hope this helps somebody out there.

Monte
memilanuk
 
Posts: 52
Joined: 1. Jul 2009, 18:16
Location: Wenatchee, WA USA
Primary OS: Linux other
VBox Version: PUEL
Guest OSses: openSuSE, Fedora, Ubuntu, CentOS


Return to Using VirtualBox

Who is online

Users browsing this forum: No registered users and 12 guests