LoginSignup
23
22

More than 5 years have passed since last update.

xhyve

Last updated at Posted at 2015-06-16

参考

注意点!!

VirtualBox を起動中に xhyve を実行すると、カーネルパニックが発生するので気を付ける必要がある。

Build

git clone https://github.com/mist64/xhyve
cd xhyve
make
sudo cp build/xhyve /usr/local/bin

boot2dockerを動かす

準備
git clone https://github.com/ailispaw/boot2docker-xhyve
cd boot2docker-xhyve
make
起動
$ sudo ./xhyverun.sh
  • docker / tcuser でログインが出来る。

メモリ容量を変更

xhyverun.sh
- MEM="-m 1G"
+ MEM="-m 2G"

CPU数を変更

xhyverun.sh
- #SMP="-c 2"
+ SMP="-c 2"

Ubuntu Serverを動かす

概要

  1. 起動にはカーネルとinitrd.imgが必要。Qemuのように指定して起動させる。
  2. インストールが終わったら /boot/ をMac側にコピー
  3. 起動

準備

mkdir ~/xhyve/ubuntu/
cd ~/xhyve/ubuntu/
  • ubuntu-14.04.2-server-amd64.iso をカレントディレクトリに保存しておく。
UbuntuのISOからインストールに必要なファイルを取得
dd if=/dev/zero bs=2k count=1 of=/tmp/tmp.iso
dd if=ubuntu-14.04.2-server-amd64.iso bs=2k skip=1 >> /tmp/tmp.iso

hdiutil attach /tmp/tmp.iso

cp /Volumes/Ubuntu-Server\ 14/install/vmlinuz .
cp /Volumes/Ubuntu-Server\ 14/install/initrd.gz .
8GBのHDDイメージを作成
dd if=/dev/zero of=hdd.img bs=1g count=8

起動スクリプト

~/xhyve/xhyverun_ubuntu_install.sh
#!/bin/sh

KERNEL="ubuntu/vmlinuz"
INITRD="ubuntu/initrd.gz"
CMDLINE="earlyprintk=serial console=ttyS0 acpi=off"

MEM="-m 2G"
#SMP="-c 2"
NET="-s 2:0,virtio-net"
IMG_CD="-s 3,ahci-cd,ubuntu/ubuntu-14.04.2-server-amd64.iso"
IMG_HDD="-s 4,virtio-blk,ubuntu/hdd.img"
PCI_DEV="-s 0:0,hostbridge -s 31,lpc"
LPC_DEV="-l com1,stdio"

xhyve $MEM $SMP $PCI_DEV $LPC_DEV $NET $IMG_CD $IMG_HDD \
  -f kexec,$KERNEL,$INITRD,"$CMDLINE"

インストール最後に一手間

  1. Installation complete
  2. Go back
  3. Execute a shell
cd /target
sbin/ifconfig
tar c boot | nc -l -p 1234
ホストから先ほどのIPアドレスを指定
nc 192.168.64.XX 1234 | tar x
  • ゲストの/boot/ を持ってくる

インストール完了

~/xhyve/xhyverun_ubuntu.sh
#!/bin/sh

KERNEL="ubuntu/boot/vmlinuz-3.16.0-30-generic"
INITRD="ubuntu/boot/initrd.img-3.16.0-30-generic"
CMDLINE="earlyprintk=serial console=ttyS0 acpi=off root=/dev/vda1 ro"

MEM="-m 2G"
#SMP="-c 2"
NET="-s 2:0,virtio-net"
IMG_HDD="-s 4,virtio-blk,ubuntu/hdd.img"
PCI_DEV="-s 0:0,hostbridge -s 31,lpc"
LPC_DEV="-l com1,stdio"

xhyve $MEM $SMP $PCI_DEV $LPC_DEV $NET $IMG_CD $IMG_HDD \
  -f kexec,$KERNEL,$INITRD,"$CMDLINE"

Ubuntu起動

~/xhyve/xhyverun_ubuntu.sh
23
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
22