SOLVED Quick guide to install Ubuntu 20.04 in bhyve with the serial console

blanchet

Guru
Joined
Apr 17, 2018
Messages
512
Abstract
To have a lighter Linux virtual machine, you can install it without VNC, with only the serial console.
This guide explains how to do it for Ubuntu Server 20.04 on TrueNAS-12.0u2.1


Install Ubuntu 20.04 with the serial console in bhyve
Open the VM creation wizard
Code:
1/ Operating System
  Guest Operating System: Linux
  Name: ubuntu_server
  Description: ubuntu 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/ubuntu-20.04.2-live-server-amd64.iso

6/ Confirm Options
SUBMIT

Before starting the installation you have to change some settings

In the virtual machines devices, change the devices orders like this
  • NIC: 1000
  • DISK: 1002
  • CDROM: 2000
It is very important that NIC is always the first device number and CDROM is always the last device number otherwise the NIC name will change when you remove/add CDROM devices.

In the DISK properties, force disk sector size to 4096

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 TrueNAS
    • from a Windows computer, you can use PuTTY instead of xterm + ssh
  • in the TrueNAS shell, connect to the virtual serial port of the virtual machine
    • The TrueNAS webUI supports also the serial console, but it is not as reliable as xterm or PuTTY
Code:
truenas# cu -l /dev/nmdm20B


Keep the xterm window open while powering on the VM
  • Select the entry Install Ubuntu Server
  • Press e to edit the command line
  • Modify the linux line to disable vga and to enable serial console. Be careful the key END and DELETE do not work as expected. BACKSPACE behaves like DELETE. In case of issue, press ESC to return to the main menu
Code:
linux /casper/vmlinuz vga=off  console=ttyS0,115200n8

  • Hit CTRL+X to boot
The installer will run in text mode.
Ubuntu detects that you are installing in text mode and propose to use Rich mode to have colors, if it does not work, use the basic mode instead.

At the installation end
  • Power off the VM
  • Remove the CDROM device from the VM
  • Power on the VM

The installation is finished, enjoy your new Ubuntu Server 20.04 with a serial console.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,737
It is very important that NIC is always the first device number and CDROM is always the last device number otherwise the NIC name will change when you remove/add CDROM devices.
That's a great idea, thanks! I used to change the netplan config after the first post-install boot, but your solution is way more elegant.
 

NinthWave

Contributor
Joined
Jan 9, 2021
Messages
129
Abstract
To have a lighter Linux virtual machine, you can install it without VNC, with only the serial console.
This guide explains how to do it for Ubuntu Server 20.04 on TrueNAS-12.0u2.1
I get this error message as soon as the install starts and it ends with a blank screen

Code:
root@truenas[~]# cu -l /dev/nmdm2B
Connected
Failed to set MokListRT: Invalid Parameter
Could not create MokListRT: Invalid Parameter
Importing MOK states has failed: import_mok_state() fa                                                                iled
: Invalid Parameter
Continuing boot since secure mode is disablederror: no                                                                 suitable video mode found.
error: can't find command `grub_platform'.


[EDIT]
One must hit e fast to enter the edit mode, then you have a working display in serial
 
Last edited:

blanchet

Guru
Joined
Apr 17, 2018
Messages
512
  • Check that you have exactly follow all the steps of the guide, and in particular that your VM is booting in UEFI mode
  • If it changes nothing, try with another Linux distribution like Debian 10 to see if you get the same error.
 

NinthWave

Contributor
Joined
Jan 9, 2021
Messages
129
  • Check that you have exactly follow all the steps of the guide, and in particular that your VM is booting in UEFI mode
  • If it changes nothing, try with another Linux distribution like Debian 10 to see if you get the same error.
Thanks for the follow up. My [EDIT] was meant to express it worked once I was fast (less than 5 seconds) to hit e. Then the installation went trough.
 

NinthWave

Contributor
Joined
Jan 9, 2021
Messages
129
Abstract
To have a lighter Linux virtual machine, you can install it without VNC, with only the serial console.
This guide explains how to do it for Ubuntu Server 20.04 on TrueNAS-12.0u2.1
Any idea why each time I type the last character "e" of my mount, the cursor goes back to column 1 and I can't do anything but CTRL-C ?

1642716793719.png


It's like there is no carriage return at the 80th character
 
Last edited:

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,737
How do you open your shell session to TrueNAS? Are you using an SSH client on your desktop or the "console" built into the web UI? The latter is broken. Don't use it if you can avoid it.

If you want to do anything with a Unix/Linux based system, learn how to use SSH.
 

NinthWave

Contributor
Joined
Jan 9, 2021
Messages
129
I am in Solarwind Putty. First time I encounter such a behavior in Putty..

I SSHed to the host and used
truenas# cu -l /dev/nmdm20B
After the cariage return occured, I:

Then, I installled openSSH (whic was apparently not done at install) and started the service. The putty session went to a black screen. I was never asked for login credentials.
 

ajkelsey

Dabbler
Joined
Jan 29, 2022
Messages
14
A few months ago, I successfully installed ubuntu using this guide. I'm trying to install a second VM with Ubuntu and I run into an error during install.

---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---

I double checked I have the command line edits correct. I also double checked the device order. Any help would be appreciated.

I have attached a screen dump from the install.
 

Attachments

  • ubuntu install.txt
    32.1 KB · Views: 339

ajkelsey

Dabbler
Joined
Jan 29, 2022
Messages
14
A few months ago, I successfully installed ubuntu using this guide. I'm trying to install a second VM with Ubuntu and I run into an error during install.



I double checked I have the command line edits correct. I also double checked the device order. Any help would be appreciated.

I have attached a screen dump from the install.
Managed to install with a previous version and by increasing the memory size.
 
Top