# How to install a Ubuntu guest in Bhyve



## HaHaHa (Jul 19, 2018)

There is no GUI in bhyve or in vm-bhyve. I use Ubuntu 14.04 ISO. But the installation need a GUI to choose the installation configuration. How to get the GUI mode if possible, or how to install Ubuntu without GUI? If I could install without GUI, then could I connect the Ubuntu GUI via remote desktop from this FreeBSD host?


----------



## HaHaHa (Jul 19, 2018)

FYI, it is ubuntu-14.04.5-desktop-amd64.iso


----------



## SirDice (Jul 19, 2018)

https://github.com/churchers/vm-bhyve/wiki/Supported-Guest-Examples


----------



## drhowarddrfine (Jul 19, 2018)

https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/virtualization-host-bhyve.html


----------



## HaHaHa (Jul 20, 2018)

@


drhowarddrfine said:


> https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/virtualization-host-bhyve.html


I need GUI because when I follow this wiki, I will enter the Ubuntu installation first page, it shows choices in terminal: whether want to try Ubuntu or want to install one, select then press Enter, this would end and waiting for new command in terminal.  .


----------



## usdmatt (Jul 20, 2018)

In order to get GUI access you need to boot using UEFI and provide a vnc frame buffer to bhyve. You can then connect with a VNC client (I'm using TightVNC on my Windows desktop). 

The following vm-bhyve worked for me to boot 17.04.
Note that you need the uefi-edk2-bhyve package installed if you don't already have it.


```
uefi="yes"
graphics="yes"
xhci_mouse="yes"
cpu=2
memory=2G
network0_type="virtio-net"
network0_switch="public"
disk0_type="virtio-blk"
disk0_name="disk0.img"
```


----------



## SirDice (Jul 20, 2018)

https://github.com/churchers/vm-bhyve/wiki/UEFI-Graphics-(VNC)


----------



## HaHaHa (Jul 20, 2018)

SirDice said:


> https://github.com/churchers/vm-bhyve/wiki/Supported-Guest-Examples


I follow this link https://github.com/churchers/vm-bhyve/wiki/Quickstart
Skipped step 8 because failed:  "8. vm switch add public em0", I used bge0. but I do not think this is the reason it stoped . 
I already modified the config file by "vm configure myguest". And also ".templates/default.conf":


> loader="grub"
> cpu=1
> memory=512M
> network0_type="virtio-net"
> ...


Where should I create and put this file linux.img?
It stoped here, (I choose 'Install Ubuntu' ):


> # vm -f install myguest ubuntu-14.04.5-desktop-amd64.iso
> 
> 
> GNU GRUB  version 2.00
> ...


----------



## HaHaHa (Jul 20, 2018)

usdmatt said:


> In order to get GUI access you need to boot using UEFI and provide a vnc frame buffer to bhyve. You can then connect with a VNC client (I'm using TightVNC on my Windows desktop).
> 
> The following vm-bhyve worked for me to boot 17.04.
> Note that you need the uefi-edk2-bhyve package installed if you don't already have it.
> ...


Can I use the VNC client from the host, which is freeBSD?


----------



## SirDice (Jul 20, 2018)

HaHaHa said:


> I follow this link https://github.com/churchers/vm-bhyve/wiki/Quickstart
> Skipped step 8 because failed:  "8. vm switch add public em0", I used bge0. but I do not think this is the reason it stoped .
> I already modified the config file by "vm configure myguest". And also ".templates/default.conf":
> 
> ...


Instead of just blindly typing in commands, learn what they actually do. Then apply that knowledge to _your_ situation.


----------



## usdmatt (Jul 20, 2018)

https://github.com/churchers/vm-bhyve/wiki/Quickstart


> *Lines 7-8*
> Create a virtual switch called 'public' and attach your network interface to it. Replace em0 with whatever interface connects your machine to the network.





> I already modified the config file by "vm configure myguest". And also ".templates/default.conf":



There is no need to mess with the templates.

I would just create a guest using the default template, then modify to my needs. If you want to run Ubuntu with uefi, then I would run `vm configure guest`, increase the cpu & memory, remove the loader line and add the uefi, graphics & xhci_mouse settings as in the example above.



> Can I use the VNC client from the host, which is freeBSD?



Yes you can vnc from the bhyve host if you have a GUI and and vnc client.



> Where should I create and put this file linux.img?



When you create a guest, by default it should have one disk called disk0.img. There will be an empty file with this name in the guest directory. You shouldn't need to create this or change the name.


----------



## HaHaHa (Jul 23, 2018)

Now I installed the System. Thanks~ But I can not enter into it by : vm start myguest
Here is the output:
`Boot Failed. EFI DVD/CDROM
Boot Failed. EFI Misc Device`


----------



## usdmatt (Jul 23, 2018)

Looks like that's probably because Ubuntu decided to not put their EFI boot file in the standard location. The UEFI code looks for /EFI/BOOT/bootx64.efi by default, but Ubuntu's code is in /EFI/ubuntu/grubx64.efi. I think the installer tries to set an EFI variable during install pointing to the correct place, but the UEFI support in FreeBSD/bhyve doesn't yet have a way of saving these variables. (In all fairness to Ubuntu, using an ubuntu folder, then directing the boot to use that probably makes it easier to multi-boot)

The easiest fix is described on this page -
https://forums.freenas.org/index.php?threads/howto-how-to-boot-linux-vms-using-uefi.54039/

Basically you need to get out to the main UEFI menu, then manually point it at the grubx64.efi file which will get the system running. Once it's running, go into a terminal and run the following -


```
# cd /boot/efi/EFI
# sudo mkdir BOOT
# sudo cp ubuntu/grubx64.efi BOOT/bootx64.efi
```

Hopefully it should boot automatically after that. Not the perfect solution because if grubx64.efi ever gets changed by an upgrade, ideally you'd need to copy it again. At some point we might get support for EFI variables in the bhyve firmware.


----------



## HaHaHa (Jul 26, 2018)

I connected it to the local area network. The host ping another computer successfully but guest fails, error with 'connect: Network is unreachable'. Here is the host network:

```
$ ifconfig
bge0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=c0099<RXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,VLAN_HWTSO,LINKSTATE>
        ether 18:03:73:e5:xx.xx
        hwaddr 18:03:73:e5:xx.xx
        inet 10.239.xx.xx netmask 0xffffff80 broadcast 10.239.115.127
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
        inet 127.0.0.1 netmask 0xff000000
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
        groups: lo
bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        description: vm-public
        ether 02:5a:18:03:a6:00
        nd6 options=1<PERFORMNUD>
        groups: bridge
        id 00:00:00:00:00:00 priority 0 hellotime 2 fwddelay 15
        maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
        root id 00:00:00:00:00:00 priority 0 ifcost 0 port 0
        member: tap0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 4 priority 128 path cost 2000000
        member: bge0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 1 priority 128 path cost 55
tap0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
        description: vmnet-myguest-0-public
        options=80000<LINKSTATE>
        ether 00:bd:03:d4:xx.xx
        hwaddr 00:bd:03:d4:xx.xx
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect
        status: active
        groups: tap
        Opened by PID 17xx
```


----------



## usdmatt (Jul 26, 2018)

Host networking looks fine, although could do with being in a cod block so it's easier to read.

What does the networking in the guest look like?
Is there a firewall on the host? If so, disable it and see if the guest still has no network access.


----------



## HaHaHa (Jul 26, 2018)

Guest should not have problem, because host and guest both use dhcp, and I also tried with guest enter 'Try Ubuntu'. 
I did not find any firewall on host freebsd. I assume firewall is not installed by default. 
Guest network text cannot copy to host. There is eth0 and lo, without any IP in it.


----------



## usdmatt (Jul 26, 2018)

Hmm, Well I can't see a lot wrong unless there's some strict network policies further up stream that are restricting access.

The host has an IP assigned, so that seems to be working. That interface (bge0) is bridged with the guest's interface (tap0), and both the guest interface and bridge are running.

At this point I'd probably try assigning an IP from the same range manually to the guest and see if I can ping the host.


----------



## nihr43 (Jul 26, 2018)

I've definitely had two physical FreeBSD bhyve servers happen to create the same MAC address for bridges, causing a lot of confusing regarding my virtual machines.  The dev version of vm-bhyve has a bridge ether random feature to work around this.

Also, like usdmatt said, enterprise network switches commonly have "border mode" which prevents more than one MAC being learned per port.  Which would cause something like you're describing.


----------



## HaHaHa (Jul 27, 2018)

nihr43 said:


> I've definitely had two physical FreeBSD bhyve servers happen to create the same MAC address for bridges, causing a lot of confusing regarding my virtual machines.  The dev version of vm-bhyve has a bridge ether random feature to work around this.
> 
> Also, like usdmatt said, enterprise network switches commonly have "border mode" which prevents more than one MAC being learned per port.  Which would cause something like you're describing.


Guest and host MAC address are totally different. 
I also have Windows and Hyper-V VM on it, with the same network policy(DHCP), both of them can connect to this local network successfully, so it should not be this "border mode" problem.


----------



## HaHaHa (Jul 27, 2018)

My network is good now, but I did nothing different from yesterday. Thanks all!~


----------

