bhyve ubuntu

Dec 28, 2014 #1 I am using FreeBSD 11 amd64 r275582 and have tried on FreeBSD 10.1 amd64 Release and it appears to work equally well.

Preliminary setup:

Install port grub2-bhyve cd /usr/ports/sysutils/grub2-bhyve make install clean

Allow needed kernel modules at boot time: Edit: /boot/loader.conf Add the following lines: Code: vmm_load="YES" nmdm_load="YES" if_bridge_load="YES" if_tap_load="YES" Edit: /etc/rc.conf

Add the following lines: Code: cloned_interfaces="bridge0 tap0" ifconfig_bridge0="addm em0 addm tap0" **Note -- change em0 to whatever your real network interface is

Make a sysctl change. Enter this line to add to /etc/sysctl.conf Code: echo "net.link.tap.up_on_open=1" >> /etc/sysctl.conf Reboot FreeBSD to allow changes to apply.

Create directories for virtual machines: mkdir /u1 mkdir /u1/dist mkdir /u1/ubuntu

Download the Ubuntu install ISO file: ubuntu-14.10-server-amd64.iso. It can be found here: http://releases.ubuntu.com/14.04/.

Save ISO file to /u1/dist.

Create the map and OS image file: cd /u1/ubuntu truncate -s 40G ubuntu.img

Create the device map file: cd /u1/ubuntu vi ubuntu.map

Add these two lines to ubuntu.map Code: (hd0) ./ubuntu.img (cd0) /u1/dist/ubuntu-14.10-server-amd64.iso Start the Grub installer: cd /u1/ubuntu grub-bhyve -m ubuntu.map -r cd0 -M 2048M ubuntu

The Ubuntu Grub installer menu will appear.

Code: Press Enter to select "Install Ubuntu Server" The FreeBSD command prompt will appear.

Now start the installer: Code: bhyve -c 2 -m 2048M -H -P -A -l com1,stdio
-s 0:0,hostbridge -s 1:0,lpc
-s 2:0,virtio-net,tap0
-s 3,ahci-cd,/u1/dist/ubuntu-14.10-server-amd64.iso
-s 4,virtio-blk,ubuntu.img ubuntu The Ubuntu text installer will start.

The installer asks some basic questions. Watch out -- select "Guided - use entire disk".

Note: Select Guided - use entire disk The default -- Guided -use entire disk and set up LVM Caused Ubuntu to crash later on during boot. YMMV.

I did install the OpenSSH server so I could ssh to Ubuntu.

Make sure to select Code: YES -- Install the GRUB boot loader on a hard disk When Ubuntu completes the install you will see: Code: The system is going down NOW! Sent SIGTERM to all processes Sent SIGKILL to all processes Requesting system reboot [ 703.362711] reboot: Restarting system Then the FreeBSD shell prompt returns.

Need to stop the VM with this command: bhyvectl --destroy --vm=ubuntu

To make the Ubuntu start up a single command create a small script. Code: cd /u1/ubuntu vi start_ubuntu.sh Add the following lines to the file:

Code: grub-bhyve -m ubuntu.map -r hd0,msdos1 -M 2048M ubuntu bhyve -w -AI -H -P -s 0:0,hostbridge
-s 1:0,lpc -s 2:0,virtio-net,tap0
-s 3:0,virtio-blk,./ubuntu.img
-l com1,stdio -c 2
-m 2048M ubuntu Save the file, and make it executable: chmod +x start_ubuntu.sh

You should now be able to start the fresh Ubuntu install with this command: ./start_ubuntu.sh

Finally the Ubuntu text console prompt will appear: Code: Ubuntu 14.10 ubuntu ttyS0

ubuntu login: You now be able to ssh or work from the text console on Ubuntu.

How to shut down the VM:

Log in to Ubuntu from console or ssh. sudo init 0

When the FreeBSD shell prompt appears: Code: bhyvectl --destroy --vm=ubuntu

转载于:https://my.oschina.net/innovation/blog/3101065

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值