113 points · by pvinis · 4y ago · 174 comments
But what else do people use it for? I want to hear interesting or unusual things you use a VM for.
For example, I have thought of running a VM only to use git in there, maybe so try and see if magit will run faster in a VM rather than on the host macos. I also have thought of using a VM to only run a browser in there, to keep the memory under control. Not sure any of these are good, but they are interesting.
What are your ideas or actual ways you use VMs?
For other Linux users out there — a VM is not needed for this, use a cgroup with memory limits. It's very easy to do with systemd, but can be done without it:
$ systemd-run --user --pty --property MemoryHigh=2G firefox
The kernel will prevent Firefox from using more than 2 GiBs of RAM by forcing it into swap (including all child processes). To quote systemd.resource-control(5):> Specify the throttling limit on memory usage of the executed processes in this unit. Memory usage may go above the limit if unavoidable, but the processes are heavily slowed down and memory is taken away aggressively in such cases. This is the main mechanism to control memory usage of a unit.
If you'd rather have it OOMed, use MemoryMax=2G.
It's actually very useful for torrent clients. If you seed terabytes of data (like I do), the client quickly forces out more useful data out of the page cache. Even if you have dozens of gigabytes of RAM, the machine can get pretty slow. This prevents the client from doing that.
There are lots of other interesting controllers that can put limits on disk and network I/O, CPU usage, etc.
For most folks, they're right.
I prefer lxd for gui programs personally, while probably a tad more effort initially setting up the x11 profile to get gpu acceleration, once that is done you can pop everything into its own linux container using that profile. From there you can control resource limits permanently.
Especially like it for intrusive apps such as discord, zoom, etc which are hard to escape from.
Some of its more interesting features (in addition to the obvious path/privilege restrictions):
- putting the application into a separate network namespace with its own firewall rules/network interfaces (for example, you can force Firefox to work through a VPN connection only, or block incoming connections with your main firewall rules and allow them for a single application)
- using a separate X server for each application (works pretty much transparently)
- setting resource limits (network bandwidth, memory, CPU, I/O; although not as flexible as systemd limits, they can be combined)
- running `sudo firecfg` once will create a bunch of symlinks for all applications installed on your system and supported by firejail. After that, those applications will run under a sandbox automatically. Or you can create them manually (I did it for the PDF reader and such).
What if there's no swap (as I believe is the current fashion in desktop envs, unlike servers)?
All this works with a great, unified interface on Qubes OS (https://qubes-os.org). See also: https://forum.qubes-os.org/t/how-to-pitch-qubes-os/4499/15.
It's nearly worth it for avoiding Google's terrible account switching UX alone :)
I've been using QubesOS as my daily dev machine for a couple of years now. No regrets. I really like that I've set up each of my clients' work in their own VMs, so there's no way one can pollute the other.
Switching back to macOS is a relief for some tasks, but it feels dirty smudging all my different types of task into the one OS again.
That's right.
> but the idea that it easy to get inside vm keeps me from doing it
No! Of course the host is the ultimate dictator. Just don't do untrusted operations in the host context. Have low-trust, low-connectivity, low resource level VM for untrusted work.
Most VM escapes happen through buggy virtual-devices written in C/C++/.. code. Virtual-device bugs that are exploitable by attackers with root access in the VM are found frequently.
This makes me wonder how many security holes CPUs have which have been buried into secrecy by the manufacturers.
An attacker would need to do some quite invasive hardware tampering to get a third party hypervisor to work on a system secured like that.
Furthermore, preventing hypervisor detection requires constant updates if the OS itself is configured to check for the presence of a hypervisor. There's a constant arms race going on between security researchers and cybercriminals who don't want their malware to trigger on analysts' machines, many of which use virtualization to easily reset the system back to a known, secure state. Every time malware comes up with a new method of detection your evil hypervisor needs to be patched to fake that stuff too or you risk detection next time the OS updates its detection algorithms.
To do this I have been given software that is single threaded and will only run a single instance, so I have taught myself Hyper-V, and run several VMs with alternative searches simultaneously. These searches can take 12+ hours to run.
The software also runs 25% faster when allocated 2 threads maximum than when 3+ are available…
Second of all,
>These searches can take 12+ hours to run
WTF. What are these searches doing?
The searches are trying to allocate groups of teachers to time slots, subject to the inputted constraints e.g. their students aren’t elsewhere, changing rooms are available if needed, a teacher hasn’t been allocated a different class already etc.
But I can’t tell the software which constraints are hard, which are soft, and which have alternatives we are indifferent about. Hence the need for parallel searches!
> WTF. What are these searches doing?
This is why you're a techie ;)
Kudos.
Edit: read the other answers. In FEL you can specify hard and soft constraints. Search can be long nonetheless...
(2 minutes for starting the project outside vs 25 seconds inside)
Because 2 years ago I moved back to Windows from MacOS for my daily driver because of WSL2.
I get the same "modern GUI on top, Unix-like shell underneath" experience that I had with MacOS but now I have a 24-core machine with 32GB of RAM for a third (or less) the price of what a similar Mac would have cost me.
I'm curious as to what pain points make you avoid it. Do you prefer the windows GUI interface? do you not want to deal with with updates breaking your system or having to manage things yourself? or are there programs that you use on windows that aren't available on linux? (or something else).
I want to stress that this is a good faith question. (since it seems flame-war territory adjacent, which I'm not interested in getting into).
I think the other question is, why would one want to use desktop Linux? With Windows 11 and WSL2, I get both. I can run all my normal apps on Windows 11, and if I really want to run GUI apps on WSL2, I can do that too.
Honestly, Windows plus WSL is the most "just works" platform out there right now. macOS is far too brittle and a compromise between high-level OS and a Unix-like environment. Linux does Linux, obviously, but it struggles as a low-friction, high-level OS.
GNOME 4 is superior to Windows and MacOS as low-friction, high-level OS in my experience. Control panel is clear, if spartan, three finger gestures stolen from MacOS "just work", and the desktop just stays out of the way so I can focus on the applications that I really care about.
I have not had a "struggle with drivers" for over a decade with Ubuntu, Fedora, and Manjaro (YMMV in other distros of course, but it's much more uniform these days), and Windows has become even worse with doing unnecessary BS work in the background slowing down the GUI such that heavyweight desktops like GNOME and KDE feel as svelte as LXDE in comparison.
I honestly can't stand any time I have to use a Windows machine due to how inconsistent the settings are, how many ~200-300ms pauses happen randomly, especially when I'm trying to type, and applications that don't "just work" but only because of the high marketshare I can google a solution. (MacOS is less viscerally disgusting to me, but more disappointing due to all of the "small" bugs that have creeped in despite having 100% control of the hardware in question. Wake-from-sleep shouldn't screw up the Wifi, unplugging and plugging back in an external monitor shouldn't shuffle the window locations, etc.)
Is the Linux experience perfect? Certainly not, there can be hiccups - try guiding someone on the other side of a phone line through connecting one of those Dell USB3 docks which needs that Synaptic-provided DisplayPort driver - but compared to Windows it is a breath of fresh air. Since Linux in general only serves one master - you - where Windows has to serve at least two - Microsoft first, you may come in second but it is quite possible for some other vendors to push themselves in front of that queue - this is hardly surprising.
I have nothing against Linux (or MacOS), and it was a fair question.. =)
I think for lots of people it would be a very suitable choice, and if I had a "work only" machine, I would absolutely consider Linux, probably even over MacOS at this point..
But for my specific uses, Windows (with WSL2) lets me do all the things I want to with one machine, so it's the winner.
The only thing I've had to add to it is an addon called Owl for accessing MS Exchange with Thunderbird at my previous employer. But stock Thunderbird is good enough for accessing Office 365 where I work now.
Plasma feels more predictable to me than Windows does, and I really like what it builds into the desktop environment itself. The essentials— window management, the volume mixer, global keyboard shortcut configuration, the panels, the desktop, compose key support, the default terminal emulator, the network management applet, display configuration, the default GUI text editor, the file manager, etc.— all feel just right to me, with very little tweaking required. What configuration is required is straightforward in the GUI and super easy to automate or save in my dotfiles.
Some of this is my own habituation to Plasma's quirks over the years, and some of it is my usage patterns not intersecting with open issues that Windows users would likely find strange. But I do think it's genuinely a wildly underrated desktop that a lot of developers would quickly come to love if they gave it a chance.
Audio is handled with Scream[2] mostly so I can get >65536Hz sample rate. (Really terrible things seem to happen if you try to boot a qemu guest w/ the emulated audio attached to pipewire-pulse when the DSP graph has a 96/192KHz sample rate. I've also had latency issues in the past w/ bonafide pulseaudio and the emulated audio card.) I do all my gaming and most of my browsing inside the Windows VM, which is bridged to my usual data VLAN. The linux host is where I do development work which lives on a separate experimental VLAN.
Other than that I run a few LXC containers for various services needed for running the LAN. (DNS, mail, VPNs, etc.) - I just want that stuff logically separated so that they can either (a) be moved to my new workstation in 2024, or (b) if one breaks it can just be rebuilt from scratch without affecting the others. It's also nice because I can use whatever distro works best for that particular package.
[1]: https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF
I use a VM on my work machine to get around Docker Desktop licensing on macOS. I also use VMs on my work and personal machines to test out new-to-me OSes that I want to play with but don't necessarily want to run full time. And once upon a time, I used VMs heavily to write and test Chef cookbooks, but those days are mostly over for me.
Perhaps my understanding is outdated, but I remember a time when the GPU was somewhat limited when virtualized since it potentially needed to be shared as well be exposed through a common layer.
Maybe this doesn't matter for all use cases, but for Plex especially when it's doing transcoding, I'd imagine it's very important.
The challenge is getting your friends and family to change the default prefer-transcoding behavior every time they fire up a new client.
I know you can use tricks like tautulli events to terminate transcode streams but they're difficult to deploy and a bad UX for the users even at their best. Better to have Plex tell users something like "This content can't be played at your preferred bitrate X, would you like to use more data to play at full bitrate Y? Yes/No/Always"
On the other hand, I was able to very easily get GPU pass through working on Emby inside and LXC container.
In the end, I went and specifically hunted down Docker for use on servers to get an installation without all the Desktop cruft - even on that page [0] there's a big thing advertising Docker Desktop for Linux.
Even more true for the BSDs and other, even more obscure operating systems.
Not really viable on portable machines, though. Too much power use. Desktop, however, is great.
Another highly likely possibility is a proprietary filter from the printer manufacturer that wasn't complied as a universal binary or compiled with i386 dependencies and thus won't run on x64-only versions of the OS.
I had a GPU (even two in SLi with hacked drivers at one point) passed through to the VM and used it for Windows / games (with a Linux host).
I've abandoned it since gaming on Linux itself has been proving alright
I use Linux as my main operating system now, the only drawback is that there's no audio when I stream through discord.
I've been toying with the idea of setting this up again -- I still have the highly-tuned XML definition for libvirt. I just ran out of PCI-e slots and I'm down to one beefy GPU -- having a lower power one for the host head is nice.
I actually had some success bypassing some anti-VM anticheats -- particularly, ESEA.
Valorant was the only one I 'gave up' on, the usual approaches didn't work and having not played it, wasn't really worth the investment.
As a concrete example let's say I have an interface on the host sitting on a trunk port receiving tagged traffic. It exposes two such VLANs as pseudo-devices "nic.10" and "nic.20" which are enslaved to "bridge10" and "bridge20" respectively. If I have a VM with a virtual NIC sitting on bridge10, the guest kernel shouldn't be able to see traffic on bridge20, right? (Assuming nothing above the guest is doing L2/L3 forwarding between the two VLANs.)
I use a similar configuration on my three ESXi hosts, with a pair of Ethernet ports on each host LACP bonded to a trunk port channel on the physical switch, a separate port group per VLAN on the virtual switches, and all L3 features disabled on the physical switch, so traffic only passes between VLANs through a dedicated router VM with strict firewall rules in place. Works great.
https://app.vagrantup.com/boxes/search?page=1
https://www.osboxes.org/virtualbox-images/
I use Parallels to run windows on a Mac, a pretty common use. I've heard of people running game servers in VM's e.g. Minecraft
It lets me test against all of them pretty easily. Tear down, spin up, repeat.
I learned that various versions of RHEL6 kernels have stuff like epoll() but others don’t and it’s not everything after kernel version X.Y. Joy.
Better than before when I had to support HP-UX, Solaris, AIX, etc. At least I have a consistent shell and least common denominator tools. That was like old school browser detection.
But yeah, a lot of focus on doing work without stressing the machine at all to not impact business workloads. Not my “day job”, but get pulled into emergencies because folks trust that I’ll do it. Log4j2 detection/validation was not fun. That was a “real cli” with a degraded pure shell fallback. And due to the lack of predictably, that was a try, fail, degrade. Nested jars/wars/ears suck when you can’t just play in memory.
I run macOS with virtualbox locally, but can get all the Linuxes I need and quickly ruby/shell a test harness.
Only annoying thing is remembering to remove them all when I’m done to get that disk back.
At work, we use VMs with NIC virtual function interfaces (https://www.kernel.org/doc/html/latest/driver-api/vfio.html) from the hypervisor for first line of validation for our product (full disclosure: part of the quality and automation team at StorPool Storage), so that we can have an environment both close to the production systems with network hardware acceleration enabled in the VM (i.e. kernel bypass) and easy to reproduce and re-create. There are some limitations and setup quirks with different orchestrations, but they are not live-migrated anyway, so not really an issue.
At home the main usage is for isolated environments (not unusual), and recently to be able to access a ZFS in an older Freenas/Freebsd zpool drive (the Ubuntu ZFSoL could not detect it for some reason, haven't looked into it more). I was a bit surprised that passing through the whole storage controller with the sole SATA disk behind it (the host root OS is on an NVMe) is actually slower than attaching to the VM as virtio raw disk (i.e. /dev/sdN).
https://archivebox.io/ - self-hosted internet archiving solution to collect, save, and view sites you want to preserve offline (this is how I bookmark now)
https://photoprism.app/ - self hosted photo, video application (used to store my family photos); I also use https://www.photosync-app.com to sync directly from my iPhone to PhotoPrism
https://gitea.io/ - lightweight code hosting solution (similar to GitHub and I mirror GH repos with this)
https://www.proxmox.com/ - my hypervisor of choice
Installing tunnels and certs needed for contract work.
Experimenting with new software environments.
And of course for learning. For example you can learn a lot about operating systems if you can just run any older version at your will.
Also, you are obviously speaking of virtualization of a given hardware platform but a lot of stuff is modeled as a "virtual machine" in the generalized sense - e.g. the pickle Python format.
Testing and playing with older systems (Windows 9x, Linux distros from the 90s) for fun and kicks (or to compile some sutpidly old tarball of something that sounds interesting or fun but hasn't been updated in 15 years)
Building network meshes to play around with running BGP, OSPF etc. on FRRouting
For a while I was using Parallels and/or UTM, but honestly (perhaps due to my /r/unixporn addiction), not having the option of a GUI on the Linux VM is great (well, it's technically possible with Multipass, but it's a bit involved). For work, I prefer to treat Linux as command line-only, nothing more -- "OS as IDE," that whole thing.
Since it's a VM, I'm happy to just blow it away and start over if I screw something up (though, the lack of a DE greatly simplifies and reduces the number of things that can go wrong). I have a single repo with all my dotfiles, and if I pull that down and symlink a few things, I have my old environment up and running in minutes. I've been meaning to look into nix, but haven't yet since it's known to have such a steep learning curve. For now, though, this is working great; my needs are so simple and my tools so few that I honestly don't know if the juice will be worth the squeeze.
I also tend to keep my Mac pretty clean and "unpolluted," as I generally create bespoke build environments in VMs. So even the Mac is fungible.
I've honestly never been happier with a dev machine/environment. No more weird macOS/Linux inconsistencies, hardly any maintenance overhead, aside from customizing my dotfiles (which I really enjoy -- it's like gardening, in a way). It all just works.
(DVD-A is a variant of the DVD format where audio is lossless, compressed using MLP. (Very similar to FLAC.) In general, DVD-A is 100% obsolete because Bluray supports lossless audio over HDMI without a special player. Unfortunately, some artists still release on DVD-A for reasons I don't fully understand.)
My VMs are managed using libvirt/virt-manager (over SSH).
IT also can't get their grubby fingers on the software inside and break anything. I also don't even have admin rights to change my network settings on my host OS, which is 100% required for the job as I need to connect to machine networks running a static IP. With VMs, I can get a USB Ethernet dongle and give it to the VM and get network control that way.
These days I do almost nothing on my host OS.
Made my side projects much easier to work and collaborate with.
qm start 600 to start ELSA, the VAG document server. Connect through VNC, find whatever was needed followed by qm shutdown 600
pct start 209 to start the Debian-stable build server, connect through SSH, build whatever is needed, package and copy the result out of the container followed by pct shutdown 209
pct start 208 starts the bookkeeping server, pct start 501 for the backup router, etc.
VMWare can provide DirectX 11 support for guest OS, and there are many kinds of gaming-friendly remote desktop applications to play remotely from my Linux laptop.
Originally inspired by this LTT video: <https://www.youtube.com/watch?v=-Mgnwn4twZE>, except that I wanted "work" system to have 100% of all resources when "gaming" one is not used (since it's started up only once in a few months). Hence, nothing as fancy as in video: "host" OS is the work system, and "guest" OS is booted up once in a few months for occasional gaming.
Working on industrial equipment even with current technology is like going back 20 years. The controls software ecosystem seems to just barely be accepting version control now. Instead of just directory after directory of duplicates named "XXX - v1.000 - I really deployed this one to plant XXX"
I thought they just had guys that bought you coffee and the odd cake until you had handed over the cash, and then you never see or hear from them again.
Otherwise, I am using VMs for edge compute, caching and cache configuration etc. I think the caches of tomorrow are those that can be fully programmed, safely in a sandbox.
I used to work on unikernels, but I have become less interested simply due to the fact that while people find them interesting, in the end they all want Linux underneath.
1. pfsense - It's the router & firewall for my house. runs a openvpn client 2. monitoring - A linux box I can ssh to. Port 22 is forwarded here 3. win11VM - Windows box I can RDP to. It runs 2FA 4. winDC - A windows domain controller for my house 5. transmission - networking forced to go over openvpn for better linux ISO sharing
It's Linux only, and it's either Ubuntu in a VM, or WSL to get it to compile.
I've tried more than once to get it to compile for windows, where I understand things better, but no go.
That is, it helps to have the same exact dependency versions as Debian, because that's what the core devs test with. This is a flaw in the distro model IMO ...
The other distros basically have to copy what Debian does, and do it imperfectly as far as I know.
I'm also running android-x86[1], for a single mobile game with an x86 port
Also I made a script to install a DE and novnc, I can browse in it, and not feel guilty about local firewall.
The VM has four cpu cores with a passed through graphics card, sound card and its own SSD. Just to be able to watch 4K HDR content in Kodi.
also, i use them to do large builds of code on OS versions other than the one i'm running on my laptop. and i use them to test packer-built custom versions of FreeBSD, RHEL, Alma, Rocky, etc., because i can control the interfaces and storage more easily when debugging my packer builds.
I've had great use of VMs when testing more boutique and unsupported software, where I need to test compatibility on various versions of OS
Outside of work, I use VMs for distro-hopping, i.e. regularly trying out new Linux distributions.
I could put multiple services on a single vm but split is easier mental model wise
So if I need a new VM I copy an existing inventory section for a VM (which has mem, cpu, NFS mounts etc variables defined), tweak that and run the deploy script with that.
Followed by another ansible script specific to the software piece I'm deploying.
Bit unorthodox (traditionally deploy part is terraform not ansible) but works for me. This is home server though...for cloud VMs I'd use terraform.