Skip to content

Instantly share code, notes, and snippets.

@ashaindlin
Last active August 29, 2015 14:04
Show Gist options
  • Save ashaindlin/ebf807cd14b82066058e to your computer and use it in GitHub Desktop.
Save ashaindlin/ebf807cd14b82066058e to your computer and use it in GitHub Desktop.
Start MINIX on QEMU VM in background, SSH to it
#!/bin/bash
# Start the VM with `./vm start` (to boot from disk) or `./vm livecd` (to boot
# from installation media). Once openssh starts on the VM, the QEMU console will
# display something like:
#
# Local packages (start): sshd Starting sshd. done.
#
# Now you can ssh to the VM from your host machine with `./vm ssh`.
#
# To kill the VM, run `./vm kill`. This might do something surprising and
# potentially dangerous if you have other QEMU machines running. If you try to
# kill a VM when you have none running, you'll just end up killing the process
# grepping for the PID of the VM, which is useless but kind of hilarious.
#
# Running QEMU with `-display curses` does a bad thing if your MINIX is set up
# to use an unusual (i.e., non-QWERTY) keymap. Either take it out or change
# your keymap within MINIX.
#
# This works on my computer (host: Ubuntu 14.04.1, guest: MINIX 3.2.1). It's
# not my fault if it doesn't work on yours.
PORT=10022
LIVECD="minix_R3.2.1-972156d.iso"
IMAGE="minix.img" # created with qemu-img
QEMU_ARCH="x86_64"
case "$1" in
start) qemu-system-$QEMU_ARCH -rtc base=utc -net \
user,hostfwd=tcp::$PORT-:22 -net nic -m 256 -hda "$IMAGE" -display curses
;;
livecd) qemu-system-$QEMU_ARCH -net user -net nic -m 256 -cdrom "$LIVECD" \
-hda "$IMAGE" -boot d -display curses
;;
ssh) ssh -p $PORT root@localhost
;;
kill) kill `ps ax | grep "qemu-system-$QEMU_ARCH" | awk 'NR==1{print $1}'`
;;
*) echo "Usage: vm (start|livecd|ssh|kill)"
esac
exit 0
@ashaindlin
Copy link
Author

Do mv vm.sh vm after downloading this. I just needed to give it a file extension on here to get pretty highlighting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment