Guide on how to use Qemu to create a similar effect to Windows Subsystem for Linux on macOS. Unfinished; contributions are welcome!
Linux terminal/development environment running under macOS, as a proof of concept only.
I recently made a tweet about this, and it went viral in an unprecedented way (I gained 100 followers in 12 hours, thanks for that!). Since then, I have received all sorts of questions about it, so here we go.
A: I was trying to make a Linux and macOS development environment for myself for some future projects (check out my GitHub profile), and was experimenting with QEMU virtual machines for this process. I discovered a feature that allowed for running QEMU headless with the output displayed in a Terminal window instead of having full VGA support. I immediately got sidetracked and... this is the result.
A: Scroll down further. Although I will warn you, this is very unpolished.
A: It's a proof of concept name only. If I were to distribute this as a finished piece of software, which I probably won't (see why below) I would choose a different name.
A: Yes, it is. And yes, it's simple. Why did I choose to put this on my Twitter, you ask? Because I couldn't find something exactly like what I did, and because before I posted it, I had 50 Twitter followers, total. I did not expect to get the over 700 likes that it did when I posted it; as a matter of fact, I would have been perfectly satisfied if it had gotten 7 likes.
A: From what I can tell (and admittedly, I haven't tested this piece of software), it already exists. Lima seems to have a lot more features (such as file sharing, something that I have not implemented) and seems to be geared towards a different application (containers).
A: Very true, but that's not a question.
Note: this will work on Apple Silicon with slight modifications to the qemu
commands, although I haven't tested this since I don't own one.
brew install qemu
mkdir msl && cd msl
(This could be any directory you want, of course.)qemu-img create -f qcow2 msl.qcow2 40G
qemu-system-x86_64 -accel hvf \
-m 4096 \
-hda msl.qcow2 \
-cdrom <path to debian iso> \
-boot d \
-smp 2 \
-net nic \
-net user,hostfwd=tcp::4022-:22 \
Note: to adjust the RAM and CPU core amount, adjust the -m
and -smp
values.
-boot d
changed to -boot c
and the -cdrom
line removed. For example:qemu-system-x86_64 -accel hvf \
-m 4096 \
-hda msl.qcow2 \
-boot c \
-smp 2 \
-net nic \
-net user,hostfwd=tcp::4022-:22 \
sudo nano /etc/default/grub
to edit the GRUB configuration file.GRUB_TIMEOUT
to 0
.GRUB_CMDLINE_LINUX_DEFAULT
to "quiet console=ttyS0"
. This is an S, the letter, not a 5.
GRUB_SERIAL_COMMAND="serial"
GRUB_TERMINAL=console
and change it to GRUB_TERMINAL="serial console"
(the quotes are important here).sudo update-grub
. If you see any errors, make sure that all text is in quotes.sudo shutdown -h now
.-nographic
to the command line arguments. For example:qemu-system-x86_64 -accel hvf \
-m 4096 \
-hda msl.qcow2 \
-boot c \
-smp 2 \
-net nic \
-net user,hostfwd=tcp::4022-:22 \
-nographic
Note: This is the command you will use to launch the VM, so it's a good idea to put this in a script if you're launching it often.
Welcome to GRUB
, or at Loading initial ramdisk...
that probably means that you didn't run sudo update-grub
or didn't add all the required lines to /etc/default/grub
.sudo shutdown -h now
.ssh -X -p 3022 localhost
. Type yes
, and enter your Debian password.vlc
.