Last active
September 25, 2016 19:47
-
-
Save casualjim/ddbefc85c1ce3e5a33ddf501702bc6d3 to your computer and use it in GitHub Desktop.
photon os in xhyve
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
tmp=$(mktemp -d) | |
pushd "$tmp" | |
iso=$HOME/Downloads/photon-1.0-13c08b6.iso | |
if [ ! -f $iso ]; then | |
echo "downloading photon os iso" | |
curl -o $iso -L'#' https://bintray.com/artifact/download/vmware/photon/photon-1.0-13c08b6.iso | |
fi | |
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/isolinux" | |
cp "$mnt/isolinux/vmlinuz" . | |
cp "$mnt/isolinux/initrd.img" . | |
diskutil eject "$disk" | |
echo "creating 4GB hdd" | |
dd if=/dev/zero of=hdd.img bs=1g count=4 | |
KERNEL="vmlinuz" | |
INITRD="initrd.img" | |
CMDLINE="earlyprintk=serial console=ttyS0 loglevel=3" | |
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