Skip to content

Instantly share code, notes, and snippets.

@zg
Forked from lloeki/arch-xhyve.sh
Created May 13, 2016 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zg/2e603c9d288cae4ab4f3411fc47daaac to your computer and use it in GitHub Desktop.
Save zg/2e603c9d288cae4ab4f3411fc47daaac to your computer and use it in GitHub Desktop.
Run Arch Linux in xhyve
#!/bin/bash
tmp=$(mktemp -d)
pushd "$tmp"
iso=/Users/lloeki/Downloads/archlinux-2015.08.01-dual.iso
echo "fixing disk"
dd if=/dev/zero bs=2k count=1 of=tmp.iso
dd if=$iso bs=2k skip=1 >> tmp.iso
echo "mounting disk"
diskinfo=$(hdiutil attach tmp.iso)
disk=$(echo "$diskinfo" | cut -d' ' -f1)
mnt=$(echo "$diskinfo" | perl -ne '/(\/Volumes.*)/ and print $1')
echo "mounted as $disk at $mnt"
echo "extracting kernel"
ls -l "$mnt/arch/boot/x86_64"
cp "$mnt/arch/boot/x86_64/vmlinuz" .
cp "$mnt/arch/boot/x86_64/archiso.img" .
diskutil eject "$disk"
echo "creating hdd"
dd if=/dev/zero of=hdd.img bs=100m count=1
KERNEL="vmlinuz"
INITRD="archiso.img"
CMDLINE="earlyprintk=serial console=ttyS0 archisobasedir=arch archisolabel=ARCH_201508"
MEM="-m 1G"
#SMP="-c 2"
NET="-s 2:0,virtio-net"
IMG_CD="-s 3,ahci-cd,$iso"
IMG_HDD="-s 4,virtio-blk,hdd.img"
PCI_DEV="-s 0:0,hostbridge -s 31,lpc"
LPC_DEV="-l com1,stdio"
ACPI="-A"
# shellcheck disable=SC2086
sudo xhyve $ACPI $MEM $SMP $PCI_DEV $LPC_DEV $NET $IMG_CD $IMG_HDD -f kexec,$KERNEL,$INITRD,"$CMDLINE"
popd
rm -rf "$tmp"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment