Basic VM setup for linux - theory vs. reality question.

Discussions about using Linux guests in VirtualBox.
Post Reply
Leetmeymayk
Posts: 6
Joined: 10. Aug 2022, 18:10

Basic VM setup for linux - theory vs. reality question.

Post by Leetmeymayk »

Anyone could suggest best settings (from experience) for reasonably stable and performing Linux VM (LUbuntu, used for development, with basic 3D present):

A. Paravirtualization
B. Graphics Controller
C. Chipset
D. Network Card
# Audio (that one is not really important)

Also, do I need to enable USB (host) access for other reasons than actually using it? (like OS'es assuming it will be always there and going mad if it isn't)?

----------------------------------------------------------------------------------------------------------------------------------------------------------
Longstory (for the curious): so I have been trying to get myself a new linux VM for work, and managed to whatever reason to fail each and every time because guest distros seem to have 1000 reasons not to work properly inside vm, first try being simply no compatible VM additions available (too new) then I installed different one and manually installed additions died after first update to never rise again, then I tried using additions that come with a distro and those works for a while while outdated, but 2-3 boots after it got updated those too similarly just died for no reason. All the while I saw in a log bunch of VMWARE driver errors.

At the same time aging windows VMs could run around them in circles without issues (although they crash occasionally when idle, reducing number of cores seemed to fix that). And just for comparison, when linux drivers were working, benchmark showed to work around ~0.2% performance of host machine, this is minimum I would like to achieve and I don't think this is unreasonable level of expectations to have (when drivers are not working, VMs are basically unusable, everything is way too laggy, and if it isn't everything still sits on CPU, which result in persistent high CPU core utilization even though there is nothing running on them). Generally too big of an negative to justify using VM for anything beyond security and even that has its challenges these days.

While occasionally running Linux on my Windows VMs or more random configurations, I have noticed that recommended configuration settings seem to be, let say "quite unreliable" and are possibly outdated (state at 2022.08). And I assume even most basic settings can make a huge difference, I listed my main suspects in the beginning, if anyone has any recommendation which of their settings result in somehow usable and stable linux guest it would be really appreciated (options from commandline config would be acceptable too, but I doubt there is some miracle cure out there, and they tend to come with a price (or at least a risk) so I'm thinking of them as a last resort).

Just to clarify, I am aware that official recommendations are for those (read through that documentation page), I'm asking about practice and that is completely different matter. After testing manjaro, debian, ubuntu, opensuse am currently thinking about settling at Lubuntu (assume that sticking with X will get me around ubuntu driver support issue, not happy about it as after testing wayland seem unreasonable faster), and if everything fail some partial knoppix installation making OS lifespan too short for it to "brick" (not technically bricking, still useless though).

Ps. I use AMD-V, there is also some old iommu present, below requirements for GPU pass-trough, and I couldn't find any information on its capacities. I think it is not really used (supported) based from some system log notice when I was setting up vulcan..

Edit: Got straight to the point, not to waste people's time
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Basic VM setup for linux - theory vs. reality question.

Post by scottgus1 »

The defaults chosen by Virtualbox for Linux VMs are good, except for disk size, processor count and RAM/video RAM.

Disk size should be 50GB-ish, depending on what you're planning to install in it. The default is too small in my opinion. When Ubuntu-based OS's run out of disk space, they go black-screen, even on real PCs, because the desktop environment can't start. An apt-get update often fills the drive, then folks think Virtualbox is broken.

2 processors is the sweet spot for modern OS's, unless you plan to install multi-processor-aware 3rd-party apps in the VM.

RAM: use what is reasonable for the VM load and the apps, but never more than the host has, minus what the host & other VMs need.

Video RAM: if you're planning to install 3D acceleration in the VM, max the video RAM. Otherwise 32MB may be good, or even 8 for text-only.

The "log error" seen at the beginning of the VM boot is from the Linux drivers for the VMSVGA video card used by Virtualbox for the VM. It is a recoverable error and the VM continues to boot fine if there are no other problems.

Guest Additions have prerequisites in Linux, same as Virtualbox on the host, see https://www.virtualbox.org/manual/ch04. ... ions-linux and https://www.virtualbox.org/manual/ch02. ... nux-prereq. Also, watch the terminal installation report when running the GAs installer. Error messages will show if the install ran into a problem.

Many Linux distros put their forked Virtualbox and Guest Additions in the OS ISO's they distribute. These forks may work, but we only support official Virtualbox from http://www.virtualbox.org. And when you use official, the Guest Additions are bundled with the installer, so no separate download needed.

Virtualbox also has an Extension Pack that should be the same version as the installed Virtualbox in the host. Guest Additions can be allowed to fall behind, if 3D acceleration is not being used and no new features are needed. With 3D, Guest Additions should also stay up to date with the host Virtualbox version. To the best of my knowledge, only Mac OS pitches a fit if USB 3 is not present.

Please use the above to try a VM, then if you run into trouble, please do this:

Start the VM from full normal shutdown, not save-state. Run until you see the problem happen, then shut down the VM from within the VM's OS if possible. If not possible, close the Virtualbox window for the VM with the Power Off option set.

Right-click the VM in the main Virtualbox window's VM list, choose Show Log. Save the far left tab's log, zip it, and post the zip file, using the forum's Upload Attachment tab.
Leetmeymayk
Posts: 6
Joined: 10. Aug 2022, 18:10

Re: Basic VM setup for linux - theory vs. reality question.

Post by Leetmeymayk »

@scottgus1
Thanks for the answer, every step to the point is what I have been doing (exactly :) ). What I have experienced however is (random?) performance/stability gains resulting from not doing what we are supposed to be doing and this is what I am trying to investigate here. I can make 3 guesses as to why paradox like this could be the case:
1. Drivers provided for those virtualbox configurations are less polished than the ones they provide for their own virtualization and devices.
2. Then another possible problem could be combining together elements used previously by 2(3) separate virtualization solutions, when everyone of 3 standards may have advantage of better testing bug testing and targeted optimization.
3. This may also happens on the OS level, since linux distributions developers may have prepared it to run in either of options but not necessarily in something (hybrid) between, and recommended VMWARE-VirtualBox-QEMU setting may be considered one.
fth0
Volunteer
Posts: 5661
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Basic VM setup for linux - theory vs. reality question.

Post by fth0 »

FWIW, I have no problem with Linux guests on Linux and Windows hosts, and the performance usually is between 80% and 100% of the host's performance.

If you are on a Windows host, look at the status bar of the VM's window. If you see a green turtle, you're running under the Hyper-V hypervisor, and VirtualBox cannot show its real potential.
Leetmeymayk
Posts: 6
Joined: 10. Aug 2022, 18:10

Re: Basic VM setup for linux - theory vs. reality question.

Post by Leetmeymayk »

@ftho0
> Linux guests on Linux and Windows hosts, and the performance usually is between 80% and 100% of the host's performance.

Then my friend you have found the golden grail of paravirtualization :P but more seriously even 80% is realm of myth outside of GPU pass through which from what I understand VirtualBox don't support, and that assume only tasks that could not utilize more than a subset of host CPU cores were taken into account (unfair but so is life). I should probably mention that benchmark involved to extend desktop (nowadays GPU heavy load), so there is a chance that pure commandline use will be possibly close to 100% (it was a case in the past) although the few commands that I used VM for had run time extended by about 200% (so I guess driver issue? or at least some of CPU capabilities being restricted inside guest for other reason).

Regardless, I did some research (trial and error on multiple configuration and OS's) conclusion were that VMWARE without 3D enabled is (at least within task scope) ~80% faster in 3D tests that when 3D is actually enabled (although possibly this could be some software anomaly where unhindered CPU cores permed better than GPU on drivers/limitations present, hidden by constantly high CPU utilization from whatever source) more exotic settings did not seem to affect performance as much as the chance VM crash and how bad it go. So after some thinking, I am assuming this mostly issue with guest drivers (both the ones provided by additions CD, and available in software repositories) and to be fair drivers not working correctly or getting automatically disabled was pretty consistent finding in hardware analysis tools. Another possibility would be their interactions with security features implemented in guest, host and VBox itself.

I do hope those issues are not a symptom of oracle loosing interest in VBox, it would be a shame as in my opinion this is wasted opportunity of potentially owning popular standard in form of frozen in time and well supported "hardware" configuration sets in more interesting generations. Which could be an immense boon in case "progress" drove tech industry into a dead end, and consequently switch of technologies kind of reset, if said new technologies were something most had not expected since what is expected to be the new thing may be riding into same dead end alongside current driver... Regardless, I will be honest, I expect to use virtualbox for a while since my old machines still perform rather well, but performance hit in modern linux desktop environments, that is desktop applications (and I know its likely their own fault for shoving GPU acceleration wherever they can) is too severe of an issue for me (performance loss from using VM exceeding maintenance savings if offer).

Just FYI: I consider my original question answered (through trial and error mentioned). Will check this thread, and forums in general, periodically for updates on the subject, but likely won't post so I would like to say thanks now to everyone responding. As, since we are talking about running same software on "same hardware" both people experiencing same problems (and receiving solution) or not having one and therefore greatly narrowing out possible causes, whatever will happen should be sufficiently helpful.
fth0
Volunteer
Posts: 5661
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Basic VM setup for linux - theory vs. reality question.

Post by fth0 »

A real gamer wouldn't even consider using a VM for gaming, because they wouldn't want to miss a single percent of GPU performance. :lol:

Seriously, I was talking about CPU and memory, and disk I/O to some extent. Since VirtualBox 6.1 doesn't provide GPU passthrough and only offers D3D9, it's obviously not suited for fast graphics.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Basic VM setup for linux - theory vs. reality question.

Post by scottgus1 »

If we want to bring this from theory to reality, especially on the Hyper-V front, we'd need to see a VM log:

Start the VM from full normal shutdown, not save-state. Run until you see the problem happen, then shut down the VM from within the VM's OS if possible. If not possible, close the Virtualbox window for the VM with the Power Off option set.

Right-click the VM in the main Virtualbox window's VM list, choose Show Log. Save the far left tab's log, zip it, and post the zip file, using the forum's Upload Attachment tab.

FWIW the performance of my 3D-modelling cabinetry design program runs in a VM pretty close to the same program on the host. But it's not a video-card-centric program.
arQon
Posts: 226
Joined: 1. Jan 2017, 09:16
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Ubuntu 16.04 x64, W7

Re: Basic VM setup for linux - theory vs. reality question.

Post by arQon »

fth0 wrote:performance usually is between 80% and 100% of the host's performance.
Just because I know you'd want to know :) - we'd say "is usually" there, not "usually is". It's a matter of binding to the subject, which changes the nuance. "A is usually B" means what you're saying here. "A usually is B" would only ever be used with emphasis on the "is", either in objection to someone arguing that "A is usually *not* B", or in support of a claim that "A is usually B".
e.g.
Person A: "My PC runs fine most of the time, but when I run Timespy it BSODs".
Person B: "Your PSU probably sucks. Random BSOD but only under load is usually a power delivery problem".
Person C: "WTF? What does PSU have to do with this? It's obv the GPU".
Person D: "No, B's right - that kind of failure usually is the PSU".

Anyway, returning on-topic: what was the 80%? I've never gotten close to that, aside from synthetics that just hammer syscalls.
Leetmeymayk wrote:but more seriously even 80% is realm of myth
It sounds like you're confusing virtualization with emulation. Virtualization has had hardware support on commodity CPUs since around 2006, with performance of CPU-bound tasks at ~97%; and even early software-based virtualization like Xen often had performance penalties in just single-digit percentages, nowhere near -20%.
fth0
Volunteer
Posts: 5661
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Basic VM setup for linux - theory vs. reality question.

Post by fth0 »

arQon wrote:Just because I know you'd want to know :)
Thanks for the lecture, appreciated! :)

I knew that when emphasis of the verb is intended, the adverb is placed before the verb. But in the case with no emphasis wanted, I wasn't sure about which placement is better. In the German language, you usually (*) place the adverb behind the verb, so in the past it was a long learning curve for me to place adverbs before verbs at all. I'll try and question my adverb placements again.

(*) Hmm. Is this wrong now, or is this a counterexample? ;)

arQon wrote:Anyway, returning on-topic: what was the 80%?
In my own experience, it's usually over 90% regarding my unmeasured impression. When using synthetic benchmarks (e.g. sysbench) and looking at CPU, memory, disk and thread measurements, it's a mixed bag, but all measurements are over 80% most of the time. In consequence, I'm stating 80% to 100%, in the hope that it's valid for CPU-bound payloads, memory-bound payloads, and so on.
Post Reply