SOLVED Quick guide to install Debian 10 in bhyve with the serial console

blanchet

Guru
Joined
Apr 17, 2018
Messages
516
Abstract
To have a lighter Linux virtual machine, you can enable the serial console and then remove the VNC device after the operating system installation with VNC.
But do you know that you can directly run the Debian 10 installer on the serial console without VNC ?
It is faster because you will not have to enable the serial console after the operating system installation.



Install Debian 10 with the serial console in bhyve
Open the VM creation wizard
Code:
1/ Operating System
  Guest Operating System: Linux
  Name: my_debian_server
  Description: debian server in serial mode
  System clock: Local
  Boot Method: UEFI
  [x] Start on Boot
  [_] Enable VNC

2/ CPU and Memory
  Virtual CPUs: 1
  Memory: 2 GiB

3/ Disks
  (o) Create new disk
  Select Disk Type: Virtio
  zvol location: tank1
  Size: 10 GiB

4/ Network Interface
  Adapter type:  VirtIo
  Mac Address: <autogenerated>
  Attach NIC: <select you NIC>

5/ Installation Media
  /mnt/tank1/iso/debian-10.4.0-amd64-netinst.iso

6/ Confirm Options
SUBMIT


Return to the VM list
  • Open COLUMNS menu to display the Com Port of your new virtual machine and note it.
  • For example /dev/nmdm20B
From your Linux PC
  • run xterm , because it interprets neither keys (F1, F2, etc) nor shortcuts unlike gnome-terminal
  • connect with SSH to FreeNAS
    • from a Windows computer, you can use PuTTY instead of xterm + ssh
  • in the FreeNAS shell, connect to the virtual serial port of the virtual machine
    • The FreeNAS webUI supports also the serial console, but it is not as reliable as xterm or PuTTY
Code:
freenas# cu -l /dev/nmdm20B


Keep open the xterm window while powering on the VM
  • Select the entry Install (instead of Graphical Install)
  • Press e to edit the command line
  • Modify the vmlinuz line to add vga=off and console=ttyS0,115200n8
  • Example
Code:
/install.amd/vmlinuz vga=off initrd=/install.amd/initrd.gz --- quiet console=ttyS0,115200n8

  • Hit CTRL+X to boot
The installer will run in text mode.

At the end of the installation
  • Power off the VM
  • Remove the CDROM device from the VM
  • Power on the VM
  • The EFI boot will fail (it is normal for Debian 10)
  • Wait 1 minute, that the EFI shell appears
  • Hit the key Esc
  • Exit the EFI shell
Code:
Shell > exit


Navigate in the menu of the EFI boot manager
  • Boot Maintenance Manager
  • Boot from file
    • <NO VOLUME LABEL ... GPT ...>
    • <EFI>
    • <debian>
    • <grubx64.efi>

Now GRUB appears and the system boots
  • Login as root and type the following commands to fix the EFI boot issue
Code:
mkdir -p /boot/efi/EFI/BOOT/
cp /boot/efi/EFI/debian/grubx64.efi /boot/efi/EFI/BOOT/bootx64.efi


  • The installation is finished
  • Enjoy your new Debian 10 Linux server with a serial console.
 
Last edited:

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
You can avoid the post-install EFI fix by running the debian installer in expert mode ( advanced options > expert install). Editing the boot command for the serial console as you showed is the same. At the "install GRUB" stage you should see this message:
di_install.png


First EFI boot should now succeed. These dirs/files are created:

Code:
root@de10serial:~# cd /boot/efi/EFI
root@de10serial:/boot/efi/EFI# ls -lR
.:
total 8
drwx------ 2 root root 4096 Jun 10 09:15 BOOT
drwx------ 2 root root 4096 Jun 10 09:15 debian

./BOOT:
total 3968
-rwx------ 1 root root 1322936 Jun 10 09:18 BOOTX64.EFI
-rwx------ 1 root root 1206824 Jun 10 09:18 fbx64.efi
-rwx------ 1 root root 1529200 Jun 10 09:18 grubx64.efi

./debian:
total 5208
-rwx------ 1 root root     108 Jun 10 09:18 BOOTX64.CSV
-rwx------ 1 root root 1206824 Jun 10 09:18 fbx64.efi
-rwx------ 1 root root     117 Jun 10 09:18 grub.cfg
-rwx------ 1 root root 1529200 Jun 10 09:18 grubx64.efi
-rwx------ 1 root root 1261192 Jun 10 09:18 mmx64.efi
-rwx------ 1 root root 1322936 Jun 10 09:18 shimx64.efi
root@de10serial:/boot/efi/EFI#
 

FreeNasJoe

Dabbler
Joined
Nov 21, 2016
Messages
13
I'm very much a novice with linux and VMs. I am installing debian via this method and it is taking an extremely long time (~1.5 hrs and still going). Currently the installer is 43% through the "Select and install software" dialogue box. When I selected the software to install, I deselected all desktop environments and chose web server, sshd, print server, and general utilities. Is it normal for an install to take this long?

The VM I created is 10GB hdd, and 4GB RAM.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
@FreeNasJoe Short answer is that sounds abnormal to me, particularly with the hardware you are using. Did you select "virtio" for both the disk and nic devies attached to your VM? Did you really want both a web and print server running in your VM? You can always install the package of your choice post install if need be. It's not essential to use this install method, most people would probably attach a VNC device to thier linux VM, at least during install.
 

FreeNasJoe

Dabbler
Joined
Nov 21, 2016
Messages
13
@KrisBee The install is still going as I type this. Currently at 67% on "Select and install software." Yes I wanted both the web server. Print server was selected by default and I didn't bother to deselect it. And yes, I did "virtio" for both disk and nic.

I previously tried other install methods via VNC device but that was extremely slow as well. I thought this method might be faster. Something seems really amiss and I'm at a loss as to how to set about troubleshooting it.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
Well. I don't know what your pool layout is and whether its free of errors, nor if you're writing to HDD or NVMe. What install iso are you using and has it allways been the same one? Do you configure the VM network at install time as DHCP, or use a static IP?
 

FreeNasJoe

Dabbler
Joined
Nov 21, 2016
Messages
13
@KrisBee On FreeNAS I have a pool (boot pool) that is comprised of 2 265GB SSDs; and pool (tank) that is comprised of 8 8TB HDD. At the top of the "Pools" page in the FreeNAS web interface the pool tank is reported as "HEALTHY:(29%) Used / 28.14 TiB Free." When creating the network during VM creation I did not specifiy an IP address, so I presume it will be configured as DHCP. (I do grab the MAC address of the VM during its creation and use it in my DHCP server settings in my router so the DHCP will always assign the same IP to this VM.) I am trying to install the iso debian-10.5.0-amd64-netinst.iso. I have not tried a different install iso. (As I type this reply the install is at 82% through the "Select and install software" dialogue.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
So is it crawling when "fetching files" during the "Select and install software" stage - so could be a network problem - or is crawling when actually writing data to the zvol used by the VM? So what pool layout are you using, eg mirros, raidz1, raidz2. Your last post implies the VM wizard has created a zvol on your HDD pool, is that correct? Did you create a dataset first to hodl this, and possibly other, VM zvols?
 
Last edited:

blanchet

Guru
Joined
Apr 17, 2018
Messages
516
Fetching files means that the installer is downloading the files from Internet.
If you want a faster installation, you need to use a full iso instead of the tiny network install iso.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
@blanchet A netinstall should take a matter of minutes when creating a VM on a HDD pool, and no need to upgrade packages after install. Something else is going on in this case.
 

FreeNasJoe

Dabbler
Joined
Nov 21, 2016
Messages
13
Just quickly following up on the sloooow VM installations I was experiencing. After having some time to mess around with things again... I discovered that the installation of VMs goes much, much faster after turning off sync on my VM dataset.

This setting is found as follows:
storage >> pools >> [select the VM dataset and then select "edit options" form vertical dot dot dot menu on right] >> change the "sync" field to disabled)

Once that is changed to disabled, VM installation moves along much, much faster.
 
Top