Advantage of using headless mode

This is for discussing general topics about how to use VirtualBox.
Post Reply
halcyonwild
Posts: 8
Joined: 10. Aug 2016, 14:07

Advantage of using headless mode

Post by halcyonwild »

Hello All, What are the advantages of running a guest VM in headless mode?

It is possible to view the screen by going to VirtualBox Manager, rightclick on machine and click Show. I imply that the VM is still displaying the graphics, just that VirtualBox is probably ignoring the VM graphics output.

Does it make the VM run faster ?
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Advantage of using headless mode

Post by scottgus1 »

In my experiments, the graphics for a headless virtual machine with a GUI in the guest OS are always calculated and "displayed", although there is no window to see them. One can use the Virtualbox Remote Desktop server to see the headless guest while there is no Virtualbox window showing, and the graphics front end of the headless guest appears in the Remote Desktop client.

With version 5, starting Normal always shows the guest window and there is no way to get rid of it while the guest is running. Starting Headless and starting Detachable appear to be two sides of the same coin, do we start with a visible window or not? Regardless of the choice, the window can be turned on and off afterwards. The guest graphics always can be seen by remoting in.

I would expect speed among all three start options to be the same, since the graphics are always there somewhere.
halcyonwild
Posts: 8
Joined: 10. Aug 2016, 14:07

Re: Advantage of using headless mode

Post by halcyonwild »

scottgus1 wrote:In my experiments, the graphics for a headless virtual machine with a GUI in the guest OS are always calculated and "displayed", although there is no window to see them. One can use the Virtualbox Remote Desktop server to see the headless guest while there is no Virtualbox window showing, and the graphics front end of the headless guest appears in the Remote Desktop client.

With version 5, starting Normal always shows the guest window and there is no way to get rid of it while the guest is running. Starting Headless and starting Detachable appear to be two sides of the same coin, do we start with a visible window or not? Regardless of the choice, the window can be turned on and off afterwards. The guest graphics always can be seen by remoting in.

I would expect speed among all three start options to be the same, since the graphics are always there somewhere.
Thanks.
Just as I thought. I had a doubt that the guest additions may stop graphics processing if it detects headless mode, unless some client (guest vbox window or remote desktop client) connects.
Does creating 2 or 3 snapshots (in sequence) slow down the machine, during startup shutdown and normal usage?
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Advantage of using headless mode

Post by socratis »

halcyonwild wrote:Does creating 2 or 3 snapshots (in sequence) slow down the machine, during startup shutdown and normal usage?
Short answer: Yes.

Long answer: Read the following nice explanation about differencing disks and snapshots (which are based on the concept of differencing disks) and you'll pretty much figure it out. Especially the last paragraph.
ChipMcK in a [url=https://forums.virtualbox.org/posting.php?mode=quote&f=1&p=276859#pr276859]recent post[/url] wrote:When a virtual disk is first created for a new virtual machine, it is considered as the base disk for the guest - data for the guest is read from and written to that disk image.

The differencing disk records changes sector-by-sector to the whole disk image, not changes to any file in the disk. VirtualBox does not know what file system is employed on the disk image and therefore can not access any individual file of/on the disk image; only the guest OS is aware of that information.

First SnapShot creates a differencing disk for read/write access while the base disk becomes read-only - as the guest modifies its data, the data is written to the differencing disk and the base disk is untouched.

Second SnapShot creates another, new, differencing disk for read/write access while the first differencing disk becomes read-only along with the base disk.

Subsequent SnapShots create additional differencing disks, with the preceding differencing disk joining the hierarchy (pecking order/chain) of read-only disks.

Keep in mind that access to/from the virtual disks is sector-by-sector, not file-by-file.

When the guest requests that a sector be read, the latest SnapShot is read first. If the sector is not found there (Sector-Not-Found is returned), the next SnapShot in the chain (youngest to oldest), until the base virtual disk is reached. Then the sector on/in the base virtual disk is either read or Sector-Not-Found is returned.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Advantage of using headless mode

Post by scottgus1 »

Snapshots make a guest more delicate and do not work as backups. They are similar to Windows' System Restore points: point-in-past-time markers, not extractable, useless without the base system in place, but easier to corrupt because the files are accessible on the host drive. They should only be used on guests you're experimenting with and with data you wouldn't mind losing. (The forums are replete with users destroying their important data because they did something wrong with a snapshot.)
halcyonwild
Posts: 8
Joined: 10. Aug 2016, 14:07

Re: Advantage of using headless mode

Post by halcyonwild »

Thanks. Helpful replies.
I think I will use snapshots as follows - Take snapshot before an experiment. If experiment fails, revert snapshot and delete snapshot. If experiment succeeds, do not revert to snapshot and delete the snapshot.
Better to use clone if snapshot is to be kept for long period of time. Only disadvantage is more disk space used, and also a longer list of VMs in the VirtualBox Manager.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Advantage of using headless mode

Post by socratis »

halcyonwild wrote:If experiment fails, revert snapshot and delete snapshot. If experiment succeeds, do not revert to snapshot and delete the snapshot.
Just one small correction here, mainly for future readers.
- If the experiment fails, revert to the BaseSnapshot, deleting is a sense the "Current state (changed)".
- If the experiment succeeds delete the BaseSnapshot and stick with the "Current state (changed)". You then make that your base snapshot.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
halcyonwild
Posts: 8
Joined: 10. Aug 2016, 14:07

Re: Advantage of using headless mode

Post by halcyonwild »

1.
Maybe Virtualbox may have this new feature - Disable graphics processing in the guest VM when no graphics client is there (no Remote Desktop Connection, or VirtualBox Window or preview box) in the headless mode. I think the guest additions can detect which graphics clients are connected. If Virtualbox guest additions detect that the virtualbox window is closed, it may stop graphics processing (unless there is an option in settings to override it). If not possible to support third party clients (like vnc or rdc) , then it may be done only for the virtualbox VM window. The setting for "disable graphics processing in headless mode" may be set to false if third party clients are being used.

2.
Graphic processing is being executed in the guest VM even in headless mode. However, if the host is not displaying the graphics, there is some less work for the host to do, which in turn may give more CPU cycles to the guest VM. That may improve guest VM performance, because host is not allocating CPU usage percentage to the Virtualbox Window. Am I right? It may not be a noticeable difference, because I have not experienced it.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Advantage of using headless mode

Post by scottgus1 »

1. Think of how this would work on a real PC, and you'd see the issues trying to implement it in Virtualbox. All that Virtualbox does is provide virtual hardware for the guest OS. What the guest OS does with it is up to the guest OS. Does a graphical OS have a way to stop processing graphical elements? If so that OS could be made to work as you'd like in a headless environment. One thing Virtualbox could be made to do is disconnect the "monitor(s)", but what would the guest OS do on a real PC if all its monitors were unplugged? Figure that out and you'd see what the "true-headless" enhancement you're thinking of would do. (Note that Virtualbox does not now have this "disconnect the monitors" thing, as I am aware; it would have to be programmed in. The minimum monitor count is 1, and you have to completely shut down the guest to change the monitor count.)

2. A hint more host OS processing cycles because of not showing graphics would only benefit the guest if the guest required those cycles. It won't make the guest's cycles run faster. Empty cycles from one process are not used by other processes unless the CPU is fully taxed and the other processes are starved for processor time. This is where those distributed processing projects find the CPU time they need to work. They use unused CPU cycles that the rest of the programs on the computer don't require. So unless your CPU is running 100% at all times, your guest will not benefit from rolling back host graphics processing for the guest window.

Also, Virtualbox enhancements are driven by two things: money from the rich paying customers (one would have to be rich to be a paying customer - the starting price for a paid license with developer support is $6100) and user-submitted code. One can post enhancement requests on the Bugtracker, but if the paying customers aren't all over the idea, too, the developers won't get to the enhancement unless they also think it's a good idea. The only other way to get an idea into Virtualbox is to write it oneself and submit it for consideration. And even then it would have to be profound in its effect.

I believe there are headless OS's that are designed to run on a PC without a video card. I don't know what these OS's do when they run on a video-enabled PC - do they ignore the video? Also, I would think that a text-only OS, even though it has "video", would be very low-impact.
halcyonwild
Posts: 8
Joined: 10. Aug 2016, 14:07

Re: Advantage of using headless mode

Post by halcyonwild »

Thanks.

1. Reducing graphics resolution seems to be one option. So instead of 1280 x 720, I will try 800 x 600.

2. You are right. My situation is slightly different - I am running Virtualbox 5.0.26 on a Windows 2008 server in my organization. It has other users logged in. So even though my CPU utilization is 20%, other users may be using a good amount of CPU cycles. I am running 3 guest VMs here (host only networked), running LinuxMint. I have been tasked with installation of a platform, using Docker. It is an experiment, which if successful, will be deployed on live servers.

The VMs are running really slow. I have done the common things. I have even removed the IDE controller, so that the guest does not run drivers for that. I think I will try a lighter ubuntu based linux - maybe lubuntu or bodhi.
halcyonwild
Posts: 8
Joined: 10. Aug 2016, 14:07

Re: Advantage of using headless mode

Post by halcyonwild »

I spent the whole day trying.
I tried lightweight Linux variants like Lubuntu and Bodhi. Virtualbox seems to have a problem with them. Guest Additions wont install. Window cannot be resized.

I found Linux Mint with XFCE to be the best compromise between lightweight, functionality and UI experience. It resizes automatically when VirtualBox window is maximised. No problems installing guest additions too. Decent speed.
Post Reply