Skip to content

Instantly share code, notes, and snippets.

@rkusa
Created January 11, 2016 09:10
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save rkusa/9e847e52adb3b34a458f to your computer and use it in GitHub Desktop.
Save rkusa/9e847e52adb3b34a458f to your computer and use it in GitHub Desktop.
Install alpine linux on xhyve VM
# curl -LO http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.3/releases/x86_64/alpine-3.3.1-x86_64.iso
curl -LO http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.3/releases/x86/alpine-3.3.1-x86.iso
# create hdd image (8GB)
dd if=/dev/zero of=hdd.img bs=1g count=8
# extract kernel and initramfs
brew install cdrtools
isoinfo -i alpine-3.3.1-x86.iso -J -x /boot/initramfs-grsec > initramfs-grsec
isoinfo -i alpine-3.3.1-x86.iso -J -x /boot/vmlinuz-grsec > vmlinuz-grsec
sudo ./install.sh
# login: root (no password)
setup-alpine # follow instructions
mkdir /mnt/vda1
mount -t ext4 /dev/vda1 /mnt/vda1
cat /mnt/vda1/extlinux.conf | grep APPEND
# e.g. result:
# APPEND root=UUID=19023208-f0f5-4c34-b27c-9f011ba78c5e modules=sd-mod,usb-storage,ext4 quiet
halt
# replace {UUID} in run.sh with UUID from above
sudo ./run.sh
#!/bin/sh
# Linux
KERNEL="vmlinuz-grsec"
INITRD="initramfs-grsec"
CMDLINE="modules=sd-mod,ext4,console quiet console=ttyS0"
MEM="-m 1G"
#SMP="-c 2"
NET="-s 2:0,virtio-net"
IMG_CD="-s 3,ahci-cd,alpine-3.3.1-x86.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"
# UUID="-U deadbeef-dead-dead-dead-deaddeafbeef"
# Linux
xhyve $ACPI $MEM $SMP $PCI_DEV $LPC_DEV $NET $IMG_CD $IMG_HDD $UUID -f kexec,$KERNEL,$INITRD,"$CMDLINE"
#!/bin/sh
# Linux
KERNEL="vmlinuz-grsec"
INITRD="initramfs-grsec"
CMDLINE="root=UUID={UUID} modules=sd-mod,ext4,console quiet console=ttyS0 acpi=on"
MEM="-m 1G"
#SMP="-c 2"
NET="-s 2:0,virtio-net"
# IMG_CD="-s 3,ahci-cd,alpine-3.3.1-x86.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"
# UUID="-U deadbeef-dead-dead-dead-deaddeafbeef"
# Linux
xhyve $ACPI $MEM $SMP $PCI_DEV $LPC_DEV $NET $IMG_CD $IMG_HDD $UUID -f kexec,$KERNEL,$INITRD,"$CMDLINE"
@k4ml
Copy link

k4ml commented Apr 8, 2016

I have problem with dhcp networking. It gave me this error message when starting the network:-

udhcpc: socket(AF_PACKET,2,8): Address family not supported by protocol

Using 3.3.3 release seem do not have this issue:-

isoinfo -i alpine-3.3.3-x86.iso -J -x /boot/initramfs-grsec > initramfs-grsec
isoinfo -i alpine-3.3.3-x86.iso -J -x /boot/vmlinuz-grsec > vmlinuz-grsec

@vbogretsov
Copy link

Hello,
Is it possible to avoid unpacking the files vmlinuz-grsec and initramfs-grsec into host FS?
These files are located in iso in case of install.sh and should be located in /boot which is inside hdd.img after alpine installation in case of run.sh.

@joshgoebel
Copy link

They are needed to bootstrap the system. xhyve doesn't really have much of an idea of BIOS, instead it comes with firmware for booting either linux or bad, and one could presume you could have other firmware to do different things... but right now there is no generic BIOS forward to find devices, boot from CD-ROM, etc...

So instead of just fire up the Linux kernel and RAM disk and then it will do it's thing and find the CD-ROM, mount it, etc...

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