HOW TO: Boot Ubuntu Desktop VM in UEFI mode

short-stack

Explorer
Joined
Feb 28, 2017
Messages
80
Note: In this tutorial, I install Ubuntu Mate as my guest OS, and then use an Ubuntu Desktop ISO in Live mode to repair the boot device. You can try the steps using the Mate ISO or whatever distro you're using, but I've had mixed results with other ISOs than the Ubuntu Desktop 16.04 ISO.


  1. Click Create a new VM.
    • Give it a name
    • Leave the template blank!
    • Pick your datastore location
    • Select UEFI as your bootloader
    • Set the Guest Type as Linux (64-Bit)
    • Give it a description
    • Set CPU/Memory to 2 core/2 GB of RAM
    • Click on devices

      [*]Add a CDROM and choose your ISO install file
      [*]Add a NIC
      [*]Add a Display
      [*]Do not add a disk from the GUI, it's hit or miss if it actually works. Add it from the CLI instead.​

    • Open the CLI and type the following(replace Ubuntu with what you called the VM):
      unix::>vm
      unix::/vm>Ubuntu/
      unix::/vm/Ubuntu>Device
      unix::/vm/Ubuntu/Device>create name=OS type=DISK disk_mode=AHCI disk_size=10G
    • When you go back to the FreeNAS webpage the VM should now show the disk OS as a device attached to your VM
    • Save your VM!


  2. Install your Guest OS
    • Click start on the VM
    • Click on VGA Console (If you don't see VGA console as an option, click the < next to your VM name and then click back in to the VM)
    • Follow through the prompts to install Ubuntu
    • Choose LVM to make resizing easier in the future, and if you get a message like the below screenshot just click 'Continue in UEFI mode'
      3-LVM-install-ignore-uefi-boot.png
    • Finish setting up your preferences for your install, and reboot
    • The VM will sit a screen that says 'Please remove the installation medium, then press ENTER:' Pressing enter does nothing, you need to shut down from the FreeNAS GUI
    • Click 'Shutdown' and then 'Power off' to force it to shut down

  3. Boot into Live Ubuntu
    • Click on the CDROM device and change the ISO file to the ubuntu-16.05.2-amd64.iso file
    • Save the VM changes
    • Click Start
    • Click on the VGA Console button again
    • Choose 'Try Ubuntu without installing' as this will boot it into a Live environment
    • Click the upper left hand icon to search and type Terminal to open the terminal
      8-open-terminal.png
    • In the terminal Window type the following: sudo add-apt-repository ppa:yannubuntu/boot-repair
    • It will prompt you to press Enter to continue adding the repo, so press enter
    • Run the following to update your package list (Ignore errors about moving old databases out of the way): sudo apt-get update
    • Run the following to install and run Boot-Repair: sudo apt-get install -y boot-repair && boot-repair
    • Boot Repair will ask if there is RAID on the computer, click No
    • Boot Repair should then pop up a window that says "/boot detected. Please check the options." Click ok
    • Click the words 'Advanced options' to get into the advanced menu
      15-click-advanced.png
    • Click on the GRUB options tab, and uncheck 'SecureBoot'
      16-uncheck-secureboot.png
    • Then click 'Apply'
    • Boot Repair will pop-up a window that says 'Please open a terminal then type (or copy-paste) the following commands:' Right click on the highlights commands and hit copy
      18-copy.png
    • Click on the terminal window in the background, press enter once to make sure you're at a prompt, right click and press paste
      19-paste.png
    • The last command might not run until you press enter, so when everything looks to be finished press enter until you get back to the terminal prompt
    • Switch back to the Boot Repair window and click on forward
    • Boot Repair will now run it's commands, and eventually ask you if you want to upload the results to pastebin, I check no, but if you have issues you can click yes to be able to share the results for help
    • Boot Repair will pop up a window and say 'Boot successfully repaired' and open a text viewer with the full results of what it did
      21-success.png
    • Shutdown the VM, in the GUI click 'Shutdown' and then 'Power Off'

  4. Prepare VM for first boot
    • Click on the CDROM device and delete it to remove the ISO from booting
    • Save the VM
    • Click 'Start' and click 'VGA Console'
    • Choose 'Ubuntu' to boot into your new VM, or wait and it will auto boot in 20 seconds
      24-boot-select-ubuntu.png
    • Enjoy your new Ubuntu Desktop VM!

Please let me know if you have any problems, or if my steps are clear.
 
Last edited:

chris crude

Patron
Joined
Oct 13, 2016
Messages
210
+1 this worked well for me also with FN11. The steps were slightly different i think because i am using ubuntu 16.04.2 with gnome, but it was just an extra round of copying commands and pasting them into terminal. Thanks.
 

Amsoil_Jim

Contributor
Joined
Feb 22, 2016
Messages
175
Worked great! thank you
 

Grinas

Contributor
Joined
May 4, 2017
Messages
174
Hey

thanks this worked great for FREENAS 11. I was fit to give up after 12 attempts at installing it and the same result all the time.

After running the commands given by the Boot Repair will pop-up. I got an error saying grub still exists.
i click next or forward and had to copy and run another few commands given by the Boot Repair will pop-up.

After that all was good and i can now boot to Ubuntu Desktop 16.04.
 
Joined
Mar 30, 2015
Messages
32
I can't get it to run on Ubuntu 16.04.2 or 17.04...
For some reason SecureBoot option does not exist on boot-repair for me, I tried to repair boot without it like 10 times now but no luck...
Anyone know what's going on?

P.S: When you see "Please remove the installation medium, then press ENTER" you can just do Ctrl+C to and it will reboot or shutdown.
 
Joined
Mar 30, 2015
Messages
32
Hey

thanks this worked great for FREENAS 11. I was fit to give up after 12 attempts at installing it and the same result all the time.

After running the commands given by the Boot Repair will pop-up. I got an error saying grub still exists.
i click next or forward and had to copy and run another few commands given by the Boot Repair will pop-up.

After that all was good and i can now boot to Ubuntu Desktop 16.04.
Hello I'm also working with freenas 11, but I'm stuck and I can't get it to work any tips?
 
Joined
Aug 8, 2017
Messages
1
Thanks for this write up it was an invaluble help to me.

I will just throw in my 2p worth it may help someone. Not one to normally do this so apologies if it is of no use or already covered elswhere.

I wanted to instal Linux Mint in a VM but found after taking time to set it up it failed after a power cycle. I did this twice before I started reading to find a solution.

Install your VM as described here and and I have only tested this with mint. When you get to the part after the installation and reboot it appears to hang there doing nothing, have patience it will eventually reboot. I was doing this on a laptop and the resoloution was a bit low, but you can if you wear your thickest specs see that the dots are cycling green indicating that something is happening.

Eventually you will get the login screen. Login now.

Unless you alter things this will work fine until you power cycle.


So to cure this problem read this excellent article...
https://www.lifewire.com/change-the-efi-boot-order-efibootmgr-4028027
By the talented Gary Newell
I fowllowed his guide and set up to boot with the efibootmgr a 60s timeout which did not appear to make any difference, and the boot order of 0000,0001 and since then I have power cycled many times and made various attempts to get it to fail and it has survived them all.

Thanks to all the people who spend time giving all this invaluable help and to Gary Newell who cracked it for me. Hope this is of some use to someone.

Best of luck what ever you are doing.
 

chris crude

Patron
Joined
Oct 13, 2016
Messages
210
Thanks for this write up it was an invaluble help to me.

I will just throw in my 2p worth it may help someone. Not one to normally do this so apologies if it is of no use or already covered elswhere.

I wanted to instal Linux Mint in a VM but found after taking time to set it up it failed after a power cycle. I did this twice before I started reading to find a solution.

Install your VM as described here and and I have only tested this with mint. When you get to the part after the installation and reboot it appears to hang there doing nothing, have patience it will eventually reboot. I was doing this on a laptop and the resoloution was a bit low, but you can if you wear your thickest specs see that the dots are cycling green indicating that something is happening.

Eventually you will get the login screen. Login now.

Unless you alter things this will work fine until you power cycle.


So to cure this problem read this excellent article...
https://www.lifewire.com/change-the-efi-boot-order-efibootmgr-4028027
By the talented Gary Newell
I fowllowed his guide and set up to boot with the efibootmgr a 60s timeout which did not appear to make any difference, and the boot order of 0000,0001 and since then I have power cycled many times and made various attempts to get it to fail and it has survived them all.

Thanks to all the people who spend time giving all this invaluable help and to Gary Newell who cracked it for me. Hope this is of some use to someone.

Best of luck what ever you are doing.
Many different flavours of Linux, some have no problems with the boot issues, some do. Glad you reported what you found.
 

Charlie G

Cadet
Joined
Jul 18, 2017
Messages
4
For what it's worth, I thought I'd offer what I think is an easier solution (depending on your reflexes)

If you can hit delete in the VNC session while the VM is booting, you can get to the VM's UEFI menu. From there:
  • Boot Maintenance Menu ->
  • Boot Options ->
  • Add Boot Option->
  • <Select Volume Label, first option for me>
  • <EFI>
  • <ubuntu>
  • grubx64.efi
Enter a description for this boot option (i.e. Ubuntu FFS)
  • Save
  • Exit

Now, from still within the Boot Maintenance Manager, select
  • Boot Options
  • Change Boot Order
  • Move your newly created option up to the tippy-top
  • save
  • exit, exit, exit, reboot, profit
 

dreamerns

Dabbler
Joined
May 1, 2015
Messages
48
For what it's worth, I thought I'd offer what I think is an easier solution (depending on your reflexes)

If you can hit delete in the VNC session while the VM is booting, you can get to the VM's UEFI menu. From there:
  • Boot Maintenance Menu ->
  • Boot Options ->
  • Add Boot Option->
  • <Select Volume Label, first option for me>
  • <EFI>
  • <ubuntu>
  • grubx64.efi
Enter a description for this boot option (i.e. Ubuntu FFS)
  • Save
  • Exit

Now, from still within the Boot Maintenance Manager, select
  • Boot Options
  • Change Boot Order
  • Move your newly created option up to the tippy-top
  • save
  • exit, exit, exit, reboot, profit
I've seen many conflicting explanations here on forum, this is the right one. Thanks.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
I've seen many conflicting explanations here on forum, this is the right one. Thanks.

CG 's post offers a set of instructions, without explaining anything, nor can it really be described as the right one.

It's a waste of time to "add a boot option" and then "change the boot order" via the EFI shell as you might do successfully on a real machine. Yes, you will get your Ubuntu install to boot, but (a) there is a quicker way via the Boot Maintenance Manager, and (b) the new entry created will be lost on VM re-boot as the UEFI-EDK2 firmware for bhyve does not emulated NVRAM in anyway.

According to https://wiki.freebsd.org/bhyve, UEFI NVRAM Support is still under development. So AFAIK there is no change to the situation as typified by this post at raised almost a year ago:
https://lists.freebsd.org/pipermail/freebsd-virtualization/2017-February/005221.html.
 

dreamerns

Dabbler
Joined
May 1, 2015
Messages
48
It's a waste of time to "add a boot option" and then "change the boot order" via the EFI shell as you might do successfully on a real machine. Yes, you will get your Ubuntu install to boot, but (a) there is a quicker way via the Boot Maintenance Manager, and (b) the new entry created will be lost on VM re-boot as the UEFI-EDK2 firmware for bhyve does not emulated NVRAM in anyway.

I just realized that saving changes to NVRAM is not permanent :-( Now, I'm beginning to wonder, how they solved this problem in FreeNAS Corral? I never had issues with boot priority or finding grub.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
AFAIK they only used non-efi grub booting for linux. So the problem never arose.
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,176
I'm moving this elsewhere, since it's barely related to Corral and useful for 11.x.
 

technoholic

Dabbler
Joined
Oct 4, 2012
Messages
46
Worked for me with FreeNAS 11.1 and Ubuntu 16.04 desktop. Excellent write up!
 

afsy_d

Cadet
Joined
Feb 2, 2018
Messages
3
For what it's worth, I thought I'd offer what I think is an easier solution (depending on your reflexes)

If you can hit delete in the VNC session while the VM is booting, you can get to the VM's UEFI menu. From there:
  • Boot Maintenance Menu ->
  • Boot Options ->
  • Add Boot Option->
  • <Select Volume Label, first option for me>
  • <EFI>
  • <ubuntu>
  • grubx64.efi
Enter a description for this boot option (i.e. Ubuntu FFS)
  • Save
  • Exit

Now, from still within the Boot Maintenance Manager, select
  • Boot Options
  • Change Boot Order
  • Move your newly created option up to the tippy-top
  • save
  • exit, exit, exit, reboot, profit
This worked great, thank you for the explanation!
 

gremblin

Dabbler
Joined
Aug 2, 2016
Messages
13
Note: In this tutorial, I install Ubuntu Mate as my guest OS, and then use an Ubuntu Desktop ISO in Live mode to repair the boot device. You can try the steps using the Mate ISO or whatever distro you're using, but I've had mixed results with other ISOs than the Ubuntu Desktop 16.04 ISO.


  1. Click Create a new VM.
    • Give it a name
    • Leave the template blank!
    • Pick your datastore location
    • Select UEFI as your bootloader
    • Set the Guest Type as Linux (64-Bit)
    • Give it a description
    • Set CPU/Memory to 2 core/2 GB of RAM
    • Click on devices

      [*]Add a CDROM and choose your ISO install file
      [*]Add a NIC
      [*]Add a Display
      [*]Do not add a disk from the GUI, it's hit or miss if it actually works. Add it from the CLI instead.​

    • Open the CLI and type the following(replace Ubuntu with what you called the VM):
      unix::>vm
      unix::/vm>Ubuntu/
      unix::/vm/Ubuntu>Device
      unix::/vm/Ubuntu/Device>create name=OS type=DISK disk_mode=AHCI disk_size=10G
    • When you go back to the FreeNAS webpage the VM should now show the disk OS as a device attached to your VM
    • Save your VM!


  2. Install your Guest OS
    • Click start on the VM
    • Click on VGA Console (If you don't see VGA console as an option, click the < next to your VM name and then click back in to the VM)
    • Follow through the prompts to install Ubuntu
    • Choose LVM to make resizing easier in the future, and if you get a message like the below screenshot just click 'Continue in UEFI mode'
      View attachment 17988
    • Finish setting up your preferences for your install, and reboot
    • The VM will sit a screen that says 'Please remove the installation medium, then press ENTER:' Pressing enter does nothing, you need to shut down from the FreeNAS GUI
    • Click 'Shutdown' and then 'Power off' to force it to shut down

  3. Boot into Live Ubuntu
    • Click on the CDROM device and change the ISO file to the ubuntu-16.05.2-amd64.iso file
    • Save the VM changes
    • Click Start
    • Click on the VGA Console button again
    • Choose 'Try Ubuntu without installing' as this will boot it into a Live environment
    • Click the upper left hand icon to search and type Terminal to open the terminal
      View attachment 17989
    • In the terminal Window type the following: sudo add-apt-repository ppa:yannubuntu/boot-repair
    • It will prompt you to press Enter to continue adding the repo, so press enter
    • Run the following to update your package list (Ignore errors about moving old databases out of the way): sudo apt-get update
    • Run the following to install and run Boot-Repair: sudo apt-get install -y boot-repair && boot-repair
    • Boot Repair will ask if there is RAID on the computer, click No
    • Boot Repair should then pop up a window that says "/boot detected. Please check the options." Click ok
    • Click the words 'Advanced options' to get into the advanced menu
      View attachment 17990
    • Click on the GRUB options tab, and uncheck 'SecureBoot'
      View attachment 17991
    • Then click 'Apply'
    • Boot Repair will pop-up a window that says 'Please open a terminal then type (or copy-paste) the following commands:' Right click on the highlights commands and hit copy
      View attachment 17992
    • Click on the terminal window in the background, press enter once to make sure you're at a prompt, right click and press paste
      View attachment 17993
    • The last command might not run until you press enter, so when everything looks to be finished press enter until you get back to the terminal prompt
    • Switch back to the Boot Repair window and click on forward
    • Boot Repair will now run it's commands, and eventually ask you if you want to upload the results to pastebin, I check no, but if you have issues you can click yes to be able to share the results for help
    • Boot Repair will pop up a window and say 'Boot successfully repaired' and open a text viewer with the full results of what it did
      View attachment 17995
    • Shutdown the VM, in the GUI click 'Shutdown' and then 'Power Off'

  4. Prepare VM for first boot
    • Click on the CDROM device and delete it to remove the ISO from booting
    • Save the VM
    • Click 'Start' and click 'VGA Console'
    • Choose 'Ubuntu' to boot into your new VM, or wait and it will auto boot in 20 seconds
      View attachment 17994
    • Enjoy your new Ubuntu Desktop VM!

Please let me know if you have any problems, or if my steps are clear.


Please Help!

I'm trying to get this to work on FreeNAS 11.1-U5 (lastest at time of writing) and am following this tutorial that you have so kindly shared. Thank you.

When I run the vm command, I get this error:


root@freenas:~ # vm
/usr/local/sbin/vm: WARNING: $vm_enable is not set properly - see rc.conf(5).
/usr/local/sbin/vm: ERROR: $vm_enable is not enabled in /etc/rc.conf!


I checked my rc.conf and these are the vm related lines:

# open-vm-tools
vmware_guest_vmblock_enable="YES"
vmware_guest_vmhgfs_enable="YES"
vmware_guest_vmmemctl_enable="YES"


Am I missing something here??
 
Top