14 ms·
M1 dev setup with a virtual Linux box
- sdevonoes 6y agoDoes vagrant + virtualbox work on the M1s?
- deleted 6y ago[deleted]
- tmiller02 6y agoVagrant works great on Macs with M1, the issue is finding a compatible 'provider' (VirtualBox, VMWare etc). For my personal projects I've been able to switch from using VirtualBox to Docker as a Vagrant provider, and it works well enough for what I need it to do. I created a cookiecutter template for Django projects at https://github.com/tmiller02/cookiecutter-django-react-ansible https://github.com/tmiller02/cookiecutter-django-react-ansib... that I use for development on my M1 mac using Vagrant + Docker.
- djs55 6y ago(I work for Docker on the M1 support) I'm glad it's working for you! There's a bug in the recent Docker Desktop on Apple Silicon RC build which affects some users of vagrant at the provisioning stage when the new ssh key is copied into the machine. It turned out that the permissions of `/dev/null` inside `--privileged` containers were `0660` (`rw-rw----`) instead of `0666` (`rw-rw-rw-`) In case you (or someone else) runs across this there's an open issue with a link to a build with the fix: https://github.com/docker/for-mac/issues/5527#issuecomment-817188600 https://github.com/docker/for-mac/issues/5527#issuecomment-8...
- tmiller02 6y agoHey, thanks for all your hard work, it's much appreciated! Thanks for the tip, that's good to know. I'm running RC2 and haven't come across any issues like that, although I don't run my Docker containers in 'privileged' mode when using Vagrant.
- arvindamirtaa 6y agoThank you so much for all the hard work. Very much appreciated!
- stef25 6y agoDocker makes things really slow, VirtualBox much better on my Intel Mac. Any idea if Parallels would work better on the M1?
- lloeki 6y agoThere is some official claim somewhere in the vbox forums that vbox will never support ARM, so you might just as well consider it dead. I'm currently using Docker for Mac but will move to UTM (a.k.a a nice UI atop qemu-hvf) when I have some time at hand. Vagrant I only used for some other OS VMs (e.g smartos) but the base images are x64 so there's no chance it works well (if ever) on ARM either.
- varispeed 6y ago> vbox will never support ARM, Is it because some kind of beef with ARM or they think it is technically impossible?
- my123 6y agoIt’s strictly x86 only, and wasn’t written with other platforms in mind at all. A port to Arm wouldn’t be really a port but a rewrite.
- arvindamirtaa 6y agoHere's the thread mentioned above - https://forums.virtualbox.org/viewtopic.php?f=8&t=98742#p488532 https://forums.virtualbox.org/viewtopic.php?f=8&t=98742#p488...
- okamiueru 6y agoI'm curious what the author means by > I had two requirements for developing that I wanted to achieve: macOS UI, Linux-based dev environment What exactly is meant by a linux-based dev environment? Seems like the idea is to run the whole dev environment is in a virtual disk in a VM. I'm puzzled, but ok. It then goes on to set up Ubuntu Server in this VM, which is then used to host the dev environment. Wouldn't simple running a docker instance both be less cumbersome, far more resource efficient, and quick to iterate, than literally installing an OS on a virtual disk? --- To summarize, unless I missed something, this looks to explain that it is possible to run a VM on a MacOS. Add "M1" and it's the top post on hacker news? What's going on here?
- lawik 6y ago"but the upside is that there is no noticeable IO latency issues like when running Docker for Mac" Docker on Mac can be dog slow. This is appealing to me.
- ccouzens 6y ago> Wouldn't simple running a docker instance both be less cumbersome, far more resource efficient, and quick to iterate, than literally installing an OS on a virtual disk? On Mac, docker works by installing a VM- so the two aren't so different. I (not the author) prefer using a VM as a development environment, because at some point I'll want to run a container and nested containers are tedious.
- icoder 6y agoThat this is 'M1' is relevant for me personally, as my current Mac is dead old, I 'need' a Mac for iOS development, the Intel ones are a dead end and seem to run hot often, and it is unclear if all my dev needs will be met by the M1. Any piece of information that untangles this mess is helpful to me. Of course this may not be the same for others, but it could be 'what's going on here'.
- goonogle 6y agoI weep for you. As an alternative could you use React Native and borrow an Apple product during compile day?
- ccouzens 6y agoI think running your dev environment in a VM is the future on all platforms. As developers we trust so many different libraries. And it is important that they are safe when used in production code. But we shouldn't have to worry about accidentally installing a library which uploads our emails or our browser data. By working from a VM we can prevent that. The worst a malicious library can do from a VM is upload our SSH keys or source code (which is still bad).
- josephg 6y agoI hear what you're saying, but the last time I worked through a linux VM on my mac laptop, everything got much slower. Our nodejs service took 2-3x longer to start up or to build. I think the issue was filesystem overhead for some reason. The future might involve working from a VM when we have CPU cycles to spare. But right now I need every iota of speed my computer has for my rust compiler. I'd much rather we solve the security problems using better local sandboxing for software, like how it works on our phones. That would help end users as well, and it would stop crypto ransomware and all sorts of other attacks. Or alternatively, run my dev tools from a solaris zone or a freebsd jail or something, both of which have no performance impact.
- danieldk 6y agoFedora Toolbox is quite interesting from this perspective. It does not provide a proper security boundary, since it shares the home directory, but it is really nice to make ad-hoc development environments. Since it is built on podman/buildah, it does not require the Docker daemon and can be used by regular users.
- JimDabell 6y ago> the last time I worked through a linux VM on my mac laptop, everything got much slower. Our nodejs service took 2-3x longer to start up or to build. I think the issue was filesystem overhead for some reason. Docker on Mac has a lot of IO overhead. This is mentioned in the article: > The way I made it work is by having a full “dev environment” running virtually. That means that I check out repositories on the virtual disk and run everything from there. This has the slight inconvenience that I can’t easily access those files with Finder, but the upside is that there is no noticeable IO latency issues like when running Docker for Mac. If you just want improved performance with bind mounts instead, you can use :cached or :delegated flags.
- fpoling 6y agoThe article author uses VSCode remote support to work with VM. This is not ideal from a security point of view. VSCode is huge, typically uses a lot extensions and all that has access to all local files and ssh keys. So for this reason I run VSCode inside a VM or a container with VNC server to provide X session. This works OK without GPU even on 4K screen while providing much better isolation.
- deleted 6y ago[deleted]
- fallenhitokiri 6y agoTo give an additional data point for people who are interested how a setup like this performs for daily use: I am currently running Parallels Tech Preview on the MacBook Air M1 and primarily use PyCharm (remote interpreter and deployment to the VM). The whole thing works better than expected considering it’s still a preview release. Battery lasts around 12 hours, sometimes an hour or so more depending on what else I run. I am currently working on a Django app. When saving while the debug server is running I can command tab to my REST client and make an API request and the change was already deployed and the server restarted. Despite dealing with a VM the whole thing is just fast.
- tbrock 6y agoIf you don’t absolutely need a local VM I’ve found it much nicer to have a beefy ec2 instance be the Linux vm that you connect to in order to work in Linux on x86. Recently I’ve been doing this with VSCode which has a remote dev mode that works amazingly well. Before that I was just using ssh and tmux/screen which, as we know, also works and has worked for decades.
- fallenhitokiri 6y agoI am curious what you find „much nicer“ using an EC2 instance than a local VM. When running remote VMs I usually run them on my ESXi box in the basement and VPN back home when traveling. This is especially nice when a project needs more resources than whatever device I’m working on has to offer. But beside this very specific use case I haven’t personally found any advantage of this setup.
- aidos 6y agoIn our basic testing on M1 performance this week we’ve found that an arm vm on the M1 runs about 2x as fast as a c6g.2xlarge graviton2 instance. So you’re probably looking at about $0.50 / hr to compete with the Mac.
- rcarmo 6y agoI’ve been doing this with minor variations for a while now (from my iPad, from my Mac, my netbook, etc.) towards VMs in various places (your favorite flavor of cloud, my favorite closet, etc.). It has become remarkably seamless and trivial to switch any of the local/remote pairs over time, and definitely cleaner than managing various app runtimes on my local machines (I have cloud-config templates to bootstrap fresh Go, Java and Node boxes as required). edit: forgot to mention I'm posting this from another of those combos, a Windows VM I remote to from my iPad whenever I need a desktop browser
- dchuk 6y agoCan you explain more about your setup, in particular the iPad part? What apps are you running on your iPad to facilitate dev work? And when talking remote instances, do you mean something like a droplet/vps? My dream is to code web apps from my iPad from the couch/bed as I sit at a big desk and monitor all day for work and I just want to chill in the evenings on something smaller and more comfortable.
- maxioatic 6y agoNot OP but I use an iPad occasionally to remote in to a linux box and work on projects. I use blink for the terminal app and connect using mosh instead of ssh. I found that mosh handles the connection (reconnection) way better since iPadOS is pretty aggressive in killing the terminal app if I switch to a different app. I use also tmux on the server and just detach it when I'm done in case I want to work on it on my laptop or desktop. Overall works great, my only issue is that the 10.9" iPad screen is a _little_ bit too small for my liking so I don't do work like this that much. If I had the 12.9" iPad it would probably be something I use daily.
- rcarmo 6y agoWell, I have an iPad mini :) https://taoofmac.com/space/blog/2016/11/06/1930 https://taoofmac.com/space/blog/2016/11/06/1930
- 6y ago
- varispeed 6y agoI am looking for a quiet and fast machine for development. I've been trying to find a reasonable AMD laptop but all are out of stock and I think these will still have fans buzzing under heavier load. I personally hate Apple practices and I never clicked with macOS (was forced to work with it for many years), but if I could install Linux on M1 it would be hard to swallow, but I may consider using it. My Intel laptop has fans buzzing now even when it is idle. It drives me crazy.
- gpanders 6y agoYou may already know this, but there is active work happening now to port Linux to the M1: https://asahilinux.org/ https://asahilinux.org/
- rovr138 6y agoInitial support was also just merged a couple? days ago. https://news.ycombinator.com/item?id=26746983 https://news.ycombinator.com/item?id=26746983
- ansible 6y agoUnless you are doing Linux GUI development, you have several options. 1. Low-end Chromebook (good battery life), remote server, VPN. 2. High-end Chromebook (there are a few i3 and i5 models with 8GB RAM), Linux environment. Are you often in locations where you don't have Internet access?
- phonethrowaway 6y agoHigh end Chromebooks have i7 and 16 gb RAM fwiw, and run Linux VMs just fine.
- fanatic2pope 6y agoDo you absolutely have to have a laptop? I realized years ago that I spend 99% of my time in a single place and have since built custom desktop systems for my primary development machine. They are faster than any laptop I ever owned, quieter and much easier to live with. And because I can put together a system to my own specifications I can end up with something that works perfectly with Linux. I haven't bought a Mac in years and even with their new ARM hardware I don't see enough of a benefit to go back.
- hopsoft 6y agoI recently Dockerized a Rails development environment for working on an M1. It’s gone well so far and may provide some guidance for other development workflows (YMMV). https://gist.github.com/hopsoft/c27da1a9fda405169994a004957597b4 https://gist.github.com/hopsoft/c27da1a9fda405169994a0049575...
- sylens 6y agoSo he’s basically recreating WSL but on an Apple Silicon Mac?
- hu3 6y ago> That means that I check out repositories on the virtual disk and run everything from there. This has the slight inconvenience that I can’t easily access those files with Finder, but the upside is that there is no noticeable IO latency issues like when running Docker for Mac. Yes. Except on Windows it is easy to access WSL files.
- seabrookmx 6y agoI used to use a setup similar to this before WSL was a thing (Hyper-V VM). The "accessing your files" issue trips people up but there's a trivial solution.. install Samba in your dev VM and mount it on the host. Unsurprisingly, WSL2 does something similar (it uses the 9p protocol instead of SMB though).
- shoulderfake 6y agoI dont understand this HN infatuation with apples new chip laptops. Ppl are doing everything under the sun to make it work in random ways that arent supported yet etc.
- JoBrad 6y agoIt’s new tech with a lot of promise, in a decent laptop. Experimenting to see what you can do with it is very solidly within HN’s typical audience.
- sim_card_map 6y agoThe chip is insanely fast, runs without a cooler, consumes very little power.
- stef25 6y agoPersonally I can't wait to upgrade my iMac to the one with the new chips as soon as they come out, but the fact that setting up a dev env is still a pain (whether it's Docker or a VM) makes me hesitant. I want to run multiple VMs at the same time and my current quad core iMac struggles. So I was thinking of getting a beefy Lenovo Workstation to use as a dev environment and use the VScode remote ssh thing. But in that case I don't really to upgrade my iMac.
- coldtea 6y ago>I dont understand this HN infatuation with apples new chip laptops. Ppl are doing everything under the sun to make it work in random ways that arent supported yet etc. (a) HN has people who like new technology. (b) This particular new technology is also very good. What's difficult to understand about it? People have been tinkering with WSL and Linux to have all kinds of things working "in random ways that arent supported yet etc", M1 is not that different...
- rograndom 6y agoIt's almost like the same people that try to make things work in random ways are the same ones who frequent sites like these....
- culopatin 6y ago
- Toutouxc 6y agoEveryone is talking about running a separate Linux dev environment, but I'd actually love to run a separate macOS dev environment in a clean way (i.e. without messing with partitions for dualboot, especially on the M1). I get my stuff from Homebrew, just Rails + MySQL, no Docker, no fancy stuff. I'd love to have a fast macOS VM to run software I don't trust like Zoom or Skype and a second one to run my work projects, so they don't spill over my personal stuff, but AFAIK the virtualization story is still pretty incomplete on the M1 (or is there a way to run an arm64 macOS VM without a gigantic performance hit?).
- kitsunesoba 6y agoIf I recall, VMWare Fusion and Parallels can run macOS VMs with little or no speed hit, under Big Sur. Big Sur added GPU virtualization support so VMs aren’t slow, previous macOS versions lacked this.
- 0x426577617265 6y agoFusion doesn’t work on M1s.
- coopreme 6y agoI’ve been looking for this for a while, not sure when or if it will get done. X86 emulation on an M1… I wonder if there will be a massive hit
- ThinkBeat 6y agoThere are plenty of ways to mount a filesystem via SSH. Then the author could access the files via Finder.
- mikewhy 6y agoAh, echoes of the "why use this new Dropbox thing when I can use FTP, SVN, and some FTPFS" attitude. You're right, what you've suggested works. It would still result with VS Code running more on your client than it would when using VS Code Remote. Port tunnelling, while totally possible with an SSH command in a new terminal, is something VS Code just sets up automatically (and makes it easy to add your own).
- tlhunter 6y ago> Working keyboard. And the feature of not having a touch bar is not only included but it’s the cheaper option — I would have paid money for that! I've been using Linux development laptops for the past decade and have had all of these benefits!
- xbar 6y agoWhy the universal misuse of "weary?"
- arvindamirtaa 6y agoI've been doing something like this for about 3 months with very good success. This is also pretty much the only "complete" solution I could come up with that doesn't involve duct taping 3-4 different things and keeping them all in my head. A simpler solution I had - One linux vm, SSH connection plugin in VSCode and a simple 4 line SSH config file (~/.ssh/config) does magic. Here's my config file - Host <hostname> HostName <Hostname IP> User <User> IdentityFile <Identity File Path> LocalForward 127.0.0.1:8000 127.0.0.1:8000 LocalForward 127.0.0.1:7000 127.0.0.1:7000 The LocalForwards are key in setting up any tunnels I need working locally - you can tunnel as many ports as you need. I use the terminal inside VSCode - which means I can manage docker(-compose), microk8s, etc and anything I spin up, I'll just be able to access from my local host during testing.