13 ms·
Running GUI Linux in a virtual machine on a Mac
- riffic 4y agoare darwin-native containers on Apple's road map at all? previously: https://news.ycombinator.com/item?id=28430196 https://news.ycombinator.com/item?id=28430196
- dwaite 4y agoApple unfortunately does not talk about future product plans. We won't know until hypothetically there is something real. Given that they focus on units of apps rather than of system containers, I would _suspect_ it would be low priority to support a libcontainer API. Are you actually wanting a Darwin BSD container layer, or just a more efficient way to run Linux containers?
- webmobdev 4y agoThe fact that Apple is working on virtualisation shows that there is a user demand for running alternative OSes on a Mac desktop. And yet, instead of opening up their hardware just a bit (by making available some hardware literature on their ARM SoC) to system developers, they'd rather offer a more convoluted way of running other OSes only on their terms and control. It's all about having control over your personal data folks - with Apple ARM chips, Apple can now ensure and push that the "best" way to run alternative OSes on Apple Silicon Mac hardware is only on top of macOS with virtualisation. This way, even if you use another OS (through virtualisation), macOS can still continue to datamine your personal data.
- derefnull 4y agoThere is already much user demand & vendor support for running virtual machines (including for Windows) on Apple hardware, through Parallels, VMWare and Qemu. Like there are options for containers, it is great to have another option for virtual machines.
- webmobdev 4y agoOptions are good. But the way Apple operates to exert control and cripples softwares that don't align with their goals, don't be surprised if Apple suddenly forces developers to only use their virtualisation API on macOS, just like they did for application firewalls (that are no longer allowed to have their own custom kernel extensions for "security" and "stability"). They are slowly squeezing macOS to make it more and more like ios.
- kitsunesoba 4y agoThey had the opportunity to do this when introducing the M-series Macs, because under the hood those work very similarly to iPhones and iPads. They could've done a direct copy-paste from the iDevice boot process and called it a day, but they didn't… they went out of their way to develop support for booting third-party operating systems, complete with a path for painless long term support with the flexibility of allowing the OS to choose which version of firmware to run on the hardware (so Apple can deploy compatibility breaking firmware updates for use with macOS without stepping on the toes of e.g. Asahi Linux). In macOS itself the main goal is to get third parties out of the kernel to the greatest extent possible, which makes perfect sense. Third parties, ideally, should be operating solely in userland, because otherwise you get pointlessly insecure nonsense like cloud file storage apps installing kernel extensions (like Dropbox used to on macOS).
- webmobdev 4y ago> They had the opportunity to do this when introducing the M-series Macs No, they didn't because a Mac computer that is fully locked like the iDevices wouldn't have been popular and would have meant a lot of bad publicity for the M1 mac desktops. Apple Silicon M1 / M2 macs can only run crippled versions of other OSes and macOS is being slowly converted to be more and more like ios. It's the Boiling Frog strategy - https://en.wikipedia.org/wiki/Boiling_frog https://en.wikipedia.org/wiki/Boiling_frog - to ensure that they don't scare away their users. With soldered harware, no viable alternate OSes, and taking away developer options from macOS, all Apple Silicon M1/M2 macs are now just a few more steps away from becoming like the iDevices.
- kitsunesoba 4y agoI believe the bulk of the demand is coming primarily from a need to run Linux containers (e.g. docker images) than out of a desire to boot Linux directly. While there is demand for the latter (as demonstrated by the herculean efforts going into Asahi Linux), most people buying Macs are probably there at least partially for macOS and the ecosystem it fits into, as well as for the ability to run commercial software packages without a compatibility layer like WINE. All things considered it's probably generally easier to make headless Linux containers run acceptably on non-Linux hosts than it is to get complex UI software running acceptably under WINE or a Windows VM.
- jokethrowaway 4y agoI would say people don't care too much and take the path of least resistance. If it was an out of the box option they would definitely love a system with good hardware and a configurable os. When I spent some time and installed Linux on my MacBook Pro 2015 some people came asking for instructions (and were mostly deterred by the compiling needed to build a driver for the webcam). Macbooks are unrivaled for their hardware (pretty much any other laptop sucks), the software is meh and keeps getting worse.
- Maursault 4y ago> And yet, instead of opening up their hardware just a bit (by making available some hardware literature on their ARM SoC) to system developers, they'd rather offer a more convoluted way of running other OSes only on their terms and control. It's all about having control over your personal data folks I think the better argument is that it is what Apple says it's about, security. For the same reasons, we don't see Windows source code, nor are internally discovered Linux kernel security bugs advertised until they're fixed. I personally consider security bugs to be just "normal bugs". I don't cover them up, but I also don't have any reason what-so-ever to think it's a good idea to track them and announce them as something special...one reason I refuse to bother with the whole security circus is that I think it glorifies—and thus encourages—the wrong behavior. It makes "heroes" out of security people, as if the people who don't just fix normal bugs aren't as important. In fact, all the boring normal bugs are way more important, just because there's[sic] a lot more of them. I don't think some spectacular security hole should be glorified or cared about as being any more "special" than a random spectacular crash due to bad locking. -Linus Torvalds, 2008 Instead of rolling over and vulnerably showing soft underbelly, armadillos fold in half, tuck in their legs and head, curling their tail beside the head and pull in tight, so that only their leathery armor shell is exposed. If they did what you wanted them to do, their species wouldn't exist for very long.
- alwillis 4y agoApple isn’t “starting to work on virtualization”; it’s been around for several years. You can also run FreeBSD: https://dan.langille.org/2018/10/02/running-freebsd-on-osx-using-xhyve-a-port-of-bhyve/ https://dan.langille.org/2018/10/02/running-freebsd-on-osx-u...
- derefnull 4y agoAlso, the main page https://developer.apple.com/documentation/virtualization https://developer.apple.com/documentation/virtualization shows support for running virtualized macOS. This is pretty exciting, and appears to be a macOS answer to libvirt
- nynx 4y agoI so, so want to be able to spin up linux VMs on iOS devices.
- capableweb 4y agoThe opposite would be much more interesting and finally make cross-platform CI bearable without relying on closed source third-parties.
- nynx 4y agoI guess that’s be cool. I just want to take advantage of this phone that I carry around in my pocket that’s more powerful than my laptop.
- amelius 4y agoI'm still waiting for a Wine-equivalent where iOS takes the place of Windows.
- yndoendo 4y agoNot IOS yet but macOs middle-ware like WINE. https://www.darlinghq.org/ https://www.darlinghq.org/
- jayd16 4y agoYou'd still need a Mac with xcode for the build, no?
- capableweb 4y agoNot really, I'm already doing Rust builds with macOS SDK on Linux for M1/M2 which works... Fine I guess, but it's hacky as hell. It's testing that's the problem really, where you really need the hardware.
- newaccount74 4y agoThere is iSH -- it's just a single VM, but it's pretty sweet nonetheless.
- aliqot 4y agoUTM works great. Emulate X86, AMD64, or run on Apple Silicon. It's essentially a GUI on top of QEMU. https://mac.getutm.app/ https://mac.getutm.app/
- Maursault 4y agoI really like UTM's business model: identical free software if you want it, or 10 bucks if you want automatic updates and to fund UTM development.
- protomyth 4y agoThe only problem seems to be that it won't allow you to run an earlier OS X that can still run 32-bit programs.
- sdevonoes 4y agoAnother problem is that it's not programmatic (e.g., like Vagrant), so it's tiresome to spin up/down a bunch of VMs.
- wmf 4y agoThere are several tools to create VMs from the CLI or scripts like QEMU, docker machine, and podman machine.
- oneplane 4y agoThose earlier macOS versions don't have the frameworks to run virtualisation with. There are some hacks (mackintosh-ish) that allow you to run very old Intel releases on non-ARM releases, those virtualise the CPU but emulate nearly everything else.
- miles 4y agoThe comment you replied to was about UTM, which does allow running earlier versions of macOS/OS X on Apple silicon hosts: Virtualizing OpenCore and x86 macOS on Apple Silicon (and even iOS!) https://khronokernel.github.io/apple/silicon/2021/01/17/QEMU-AS.html https://khronokernel.github.io/apple/silicon/2021/01/17/QEMU... Run Tiger, Leopard, or any Mac OS X PowerPC version on M1 https://tinyapps.org/docs/tiger-on-m1.html https://tinyapps.org/docs/tiger-on-m1.html
- 0x0 4y agoWith UTM, I can already run GUI Linux arm64 on an M1 mac - on macOS 12.x. Works fine at least for 2d desktop stuff. I think UTM's arm64-macos guest support on arm64-macos12 hosts already use the macOS virtualization framework? Or is it hypervisor framework? Either way performance is very good.
- saagarjha 4y agoUTM uses Virtualization for this.
- pjmlp 4y agoThe year of desktop Linux has arrived, where all major desktop platforms run Linux distributions inside virtual machines.
- fbn79 4y agoI'm running Windows and MacOS virtualized in my Arch Desktop Linux from years
- amelius 4y agoThe only problem: becoming root doesn't mean you now control the device (you paid for).
- pjmlp 4y agoBasically just like container based distributions and cloud infrastructure. :)
- spijdar 4y agoWe've sort of been at this point for a long time, though, the abstraction bar is just being shifted up. Previously, the bar was at the firmware level, where you will never fully control the black boxes governing the security chips, DRM implementations and real time OSes running on the microcontrollers inside the CPU. Now the OS (especially on Apple devices) is almost becoming like the firmware layer itself, so deeply integrated and locked to the machine, but with the freedom to run other OSes/environments on top. At least you can (usually) still unlock the OS level...
- amelius 4y agoI was sort of OK with the firmware being inaccessible when it couldn't talk to the internet. But times changed.
- ribit 4y agoI feel like I pretty much have full control over my Mac laptop. Why would you expect to fully control a machine from inside a VM anyway? Sounds like a massive security risk too.
- lxe 4y agoSo we can finally have docker for Mac that doesn't run egregiously slow?
- hhh 4y agoYou can do this now. I use Multipass to get rapid linux VMs with access to my files. For Kubernetes, I use Rancher Desktop (which can also do some docker magic)
- jokethrowaway 4y agoLima is not too bad (but I'd use Linux if he support was there)
- indymike 4y agoOur solution was to run Linux native on all dev machines. Docker really is a Linux tool and it works much better under Linux. We were running JetBrains IDEs and doing mostly Go, Python and JS development, so the switch was pretty easy and painless. The switch also dramatically reduced developer time spent solving Mac/Linux incompatibilities in tooling, and let us focus more on our product. Overall we accelerated development by about one day, per developer, per week. I was kind of surprised it was that much time, but looking back, there really are quite a few differences between the GNU userspace and MacOS.
- switchbak 4y agoI'm seeing many more folks with Docker centric workflows take the same approach. It's been mostly painless for me, minus the usual audio/Bluetooth snafu. Even those don't happen enough for me to be too concerned.
- avidphantasm 4y agoWhat hardware and distro+kernel version are you using? I am trying to do this on a 12th gen. Intel Dell XPS, and to be honest the hardware support isn’t great. I had to install an upstream 5.19 kernel (rather than 5.15 that ships on Ubuntu 22.04). Sill, at least 2-3 times per week the machine fails to wake from sleep and has to be hard rebooted. Meanwhile my M1 Pro Mac 14” MBP routinely goes 3-4 weeks uptime, with reboots only for OS update. What am I missing?
- mistrial9 4y agocompiling curl today on linux, I see Apple has an internal SSL/TLS curl-7.81.0$ ./configure --help | grep -i apple --with-secure-transport enable Apple OS native SSL/TLS MSFT is adding new signing keys to build and boot Ubuntu. Perhaps Apple wants to play, too and add their own signing keys to build and boot linux, openssl and libssh. Let no crucial technology fall into the hands of the un-corporate?
- comex 4y agoSecureTransport is a system library on Apple operating systems that implements TLS. It doesn’t exist on Linux. The configure help output is showing it on Linux because it doesn’t filter the list of options based on the OS you’re running on. (Nor should it, since you might hypothetically want to cross-compile a binary for a different operating system than the one you’re running on.)
- oneplane 4y agoThe Microsoft equivalent of this is SecureChanel and none of this has to do with signing keys or booting.
- qwerty456127 4y agoDoes this have to be this complex? Can't I just fire up a VirualBox as I do on Linux and Windows and go ahead?
- naikrovek 4y agogithub.com/cirruslabs/tart is what I use, because it is a command-line tool. also, death to oracle.
- CharlesW 4y agoYou sure can. This is developer sample code, rather than something a typical user would use.
- mmis1000 4y agoI think this code is for who make VirualBox or similiar management software instead of end user. It basically demonstrate how to use macos's api to launch a virtual machine.
- philipkglass 4y agoYou can, but running Linux with a graphical desktop on VirtualBox under MacOS has become extremely sluggish in my experience. I don't know whether newer releases of MacOS or VirtualBox itself are to blame. It was much snappier 8 years ago even though I had a significantly slower laptop then.
- coldtea 4y ago>You can, but running Linux with a graphical desktop on VirtualBox under MacOS has become extremely sluggish in my experience. Huh? It's actually faster than ever, and near native experience. And the post is not about "how to run" a virtual machine as an end user or dev (for that the way the parent describes is still the suggested way). It's about how to program running it under the hood if you're a developer who wants to develop something like a program that manages virtual machines or that hosts and runs one.
- 4y ago
- als0 4y agoFails to build for me on macOS Monterey. It seems like you have to wait until macOS Ventura.
- abinaya_rl 4y agoNice, There is official Apple documentation on running Linux GUI in VMs on Mac. So that means it's going to be Aashi linux competitor?
- benrow 4y agoAs I understand it, Asahi can run on bare metal of an Mx machine, including custom hardware/firmware due to their reverse engineering efforts. Running aarch64 Linux within a VM only needs to work with the simplified virtual hardware exposed by the VM.
- als0 4y agoI'm interested to see if this includes an example of harnessing Rosetta-based x86 translation from within the Linux VM. Here's the full documentation https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta?language=objc https://developer.apple.com/documentation/virtualization/run...
- modeless 4y agoWow, you can use Rosetta to run x86 Linux binaries inside the VM on ARM? That seems pretty awesome. https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta https://developer.apple.com/documentation/virtualization/run...
- sascha_sl 4y agoOnly on Ventura, which isn't out yet (and quite frankly, the pre-release version is still a huge mess)
- zakjan 4y agoMaybe I'm missing something, what are the actual commands for running a Linux x64 binary on macOS ARM?
- sascha_sl 4y agoYou just run them after you/your distro registers a handler for them. It uses binfmt behind the scenes. https://en.wikipedia.org/wiki/Binfmt_misc https://en.wikipedia.org/wiki/Binfmt_misc (To be clear, this is for running Linux x86 inside Linux arm64 VMs on an Apple Silicon host)
- aliqot 4y agoYou can do this in UTM, it's a GUI that wraps QEMU.
- mattl 4y agoHas anyone seen a guide to installing OpenBSD on M1 Mac using UTM?
- aliqot 4y agoNo, but given that UTM is a graphical wrapper around QEMU would this be a worthy substitute? https://codeofconnor.com/running-an-arm64-openbsd-virtual-machine-on-apple-silicon-with-qemu/ https://codeofconnor.com/running-an-arm64-openbsd-virtual-ma...
- punnerud 4y agoWould not be surprised if they use the open source GPU driver for running Linux: https://news.ycombinator.com/item?id=33019316 https://news.ycombinator.com/item?id=33019316 Or if this was a push to release the Linux support.
- dwaite 4y agoNot really - https://developer.apple.com/documentation/paravirtualizedgraphics https://developer.apple.com/documentation/paravirtualizedgra... . They expose a display object which works with Metal primitives. Supporting the native GPU would mean they would have to get the guests to update for each new GPU. I'm sure Apple loves the idea they could completely rearchitect their GPU for future Apple Silicon, and it would break no preexisting macOS/iOS software
- elnatro 4y agoI would prefer to run Linux GUI applications inside docker containers but, that’s something.
- paulgb 4y agoIt takes some work, but you can pass in an XQuartz display to a Docker container and have it render to that.
- leoh 4y agoLink?
- paulgb 4y agoThe closest thing I’ve seen to a comprehensive write-up is this: https://medium.com/@mreichelt/how-to-show-x11-windows-within-docker-on-mac-50759f4b65cb https://medium.com/@mreichelt/how-to-show-x11-windows-within... (medium, unfortunately) We’ve been using it experimentally to run an ephemeral instance of Firefox that we can programmatically inject DNS and CA certs into, for localhost HTTPS development. It’s not documented yet, but the config is here: https://github.com/drifting-in-space/plane/pull/201 https://github.com/drifting-in-space/plane/pull/201
- e12e 4y agoDoesn't Monterey still run X - so you could forward x11 over ssh from host into docker?
- amelius 4y agoDoes it expose the GPU?
- jamesfmilne 4y agoWhen you virtualise macOS it does expose the GPU, but only Metal is supported. However perhaps Mesa will be able to support OpenGL via paravirtualised Metal, for Linux and perhaps macOS and Windows.
- pram 4y agoYes, through virtio-gpu.
- _yb2s 4y agoAnyone think this might work with openbsd?
- saagarjha 4y agoThere is no Virtualization template for BSD, but you can run it under the Hypervisor framework.
- lobota 4y agoWhat's so different compared to VMware on Mac?
- olliej 4y agoThis is the mechanism something like VMware would use to support a Linux guest, not something comparable with the full application experience of VMware.
- oneplane 4y agoIt seems there is some confusion of what this page is about or why it might be relevant. This is not about an end-user product to run desktop virtualisation, but it is a page for developers in the Apple ecosystem to programmatically make use of OS-native virtualisation to create virtual machines with graphics output. The value in this is not as much that "it is possible" because there are plenty of implementations of this possibility, but it's more about the vendor-native support, vendor-native documentation and examples and the signal it gives about the current state of support. In the wild, an end-user (that includes developers, it's not a derogatory term, it simply mens the person the product is intended to be used by) might see applications like UTM, Veertu, Q and others use this under the hood. VirtualBox doesn't work on ARM by the way, they only release for x86(_64). So it can only virtualise, and only on x86 hosts for x86 guests.
- Maursault 4y ago> VirtualBox doesn't work on ARM by the way, they only release for x86(_64). Because VirtualBox is not a CPU emulator, unlike QEMU, MAME/MESS, and other emulators. Virtualization software such as Fusion and Parallels run VMs of operating systems that match the architecture of the host OS. Intel VMs like those in VirtualBox will not run on Apple Silicon, and Apple Silicon VMs won't run on Intel. The CPU instruction sets are not compatible, nor can Rosetta 2 solve this. But an OS is arguably a tool used to run architecture compatible software, and much software will compile on different architecture platforms, so while it may not be possible to run VirtualBox on Apple Silicon, it may be possible to recompile whatever software is running on the virtual OS to native Apple Silicon. This is true for 10s of thousands of ports managed by MacPorts and much of the code available on GitHub, but it probably isn't true for proprietary software where the source code is unavailable.
- Teknoman117 4y agoJust want to point out that QEMU can use your CPU's hardware virtualization extensions for VMs of the same architecture as your host, it's not exclusively an emulator.
- oneplane 4y ago
- MuffinFlavored 4y agoI can’t help but feel UTM pushed Apple to deliver this polished of a solution? Pulling this 100% out of thin air though.
- pram 4y agoUTM implements VF and QEMU implements HVF as an accelerator. I don't know why theres so much circling the wagons about them itt, these are complementary technologies. VF and HVF are not competition or a replacement.
- webmobdev 4y agoWith Apple, it is all about exerting control and crippling softwares that don't align with their goals. Don't be surprised if Apple suddenly forces developers to only use their virtualisation API on macOS, just like they did for application firewalls (that are no longer allowed to have their own custom kernel extensions for "security" and "stability"). They are slowly squeezing macOS to make it more and more like ios.
- coldtea 4y ago>are no longer allowed to have their own custom kernel extensions for "security" and "stability" Why the "scare quotes"? Sounds totally justifiable. Third party kernel extensions have always have had issues with both security and stability.
- webmobdev 4y agoIt's not "scare quotes" - it's to convey sarcasm and justified scepticism. Sure, poorly coded third party kernel extensions can have security and / or stability issue. That doesn't mean that Apple is the only one who knows how to write such bug-free or secure system software. In fact, in the past most of the popular application firewalls (and VM softwares) on macOS came with their own kernel extensions and have worked fine without issues, and millions of users have used such applications without any issues. Now that Apple is forcing macOS developers to use their APIs, these software developers are at the mercy of Apple which is exactly what Apple wants - they will now be forced to negotiate with Apple for any changes or new features they want. Apple can now cripple a system developers ability to provide the kind of system software they want to offer to user. End result is that Mac users and developers both lose.
- 999900000999 4y agoThis looks absolutely fantastic, does this run at native speed though.
- tambourine_man 4y agoThis link is also interesting: Running Intel Binaries in Linux VMs with Rosetta https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta https://developer.apple.com/documentation/virtualization/run...
- Aissen 4y agoIt's 2022 and we are still running installers in VMs ? Give me a pre-installed VM with cloud-init, it'll be fine, thank you.
- Sirened 4y agoAre there any good, free desktop hypervisor apps for ARM macOS at this point? I always used VirtualBox on Intel but they don't support ARM guests on ARM hosts so I've been stuck using qemu, which is not so great performance-wise. I know I can use the APIs linked here but I would rather not build my own hypervisor client if at all possible haha
- renaudg 4y agoUTM. It's a GUI for both QEMU and the native macOS hypervisor framework
- forgotmypw17 4y agoThis is how I do most of my work. Mac and Windows frequently perform non-consensual changes to my workstation. On the other hand, GNU/Linux is challenging for me to get working 100% on bare metal. This setup is reasonably fast for my work, which is mostly text editing.
- TGRush 4y agoI wonder why they would publish this when Asahi is already quite usable, and Intel macs can run Linux natively too Is it THAT much more convenient to do everything in a VM?
- bobbylarrybobby 4y agoIf you want to use Messages and Linux simultaneously, a VM is your only option, right?
- dwaite 4y agoGoing forward, Apple won't officially support dual boot or alternative operating systems. Unofficially, they'll try their best to leave the options open for third parties like Asahi, but it will never be something they endorse as an option to macOS on their devices. For example, there will not be an ARM version of Boot Camp published by Apple. If you want to run Windows on an Apple Silicon Mac, it'll likely be running virtualized under macOS or in an emulator under macOS. If someone wants to write a bunch of drivers and hack a boot loader to get windows running natively - Apple won't stop them, but thats a heck of a lot of work.
- lamontcg 4y agoWhat is the current state of vagrant on Mac Virtualization? Vagrant is the thing that I really miss on ARM.
- TheCapeGreek 4y agoGet a Parallels license and use it as the vagrant provider. That still seems to be the only real option. https://www.parallels.com/ https://www.parallels.com/
- rcarmo 4y agoNow all we need is something like this for the iPad.
- wtcactus 4y agoDoes this differ from previously posted solutions that needed to pre-allocate a chunk of RAM to the Linux VM? This is indeed cool, but RAM on Apple Silicon is relatively low (with only 8Gb in some models) if I allocate more than 2Gb to a VM, the base desktop will struggle.
- thomastjeffery 4y agoI haven't touched OS X in years, but I do remember xquartz being pretty neat. I'm sure if you really wanted, you could forward the virtual machine's xserver. If only you could use a real window manager in OS X....