Solved Set terminal type during unattended install?

I repackaged a 10.3-RELEASE installer, and added etc/installerconfig.

The preamble section looks like this:
Code:
PARTITIONS=vtbd0
DISTRIBUTIONS="kernel.txz base.txz"

I'm able to use bhyve to boot into the installer, and the process executes automatically, as expected. The only issue is that I need to manually enter the terminal type before the installer will begin.

I was unable to find a solution to this in the bsdinstall manpages or through a few hours of fruitless searching. There's got to be a way to do this, right?
 
I actually modified my FreeBSD USB memstick installer to load serial console. So i can install over terminal.

/boot/loader.conf

Code:
boot_multicons="YES"
boot_serial="YES"
comconsole_speed="115200"
console="comconsole,vidconsole"
 
I threw a bunch of off topic serial port stuff up and need to clarify. You want to check installer /etc/ttys for this:

ttyv0 "/usr/libexec/getty Pc" vt100 on secure

My installer stick has xterm as the ttyv0 terminal type. I am assuming you need to change that.
 
Sorry, rereading my question, and it wasn't very clear at all. I blame late night and hours of bashing head against desk.

I'm trying to do this:
Code:
sh /usr/share/examples/bhyve/vmrun.sh -c 2 -m 8192m -d /usr/local/vms/guest.img -i -I /usr/local/vms/new.iso guest

Where new.iso is a repackaged FreeBSD-10.3-RELEASE-amd64-dvd1.iso, with an added etc/installerconfig file.

I want to run that command, go get some coffee, and come back to a fully-installed system.

It works for the most part, but only after I've manually pressed enter to accept the default at the following screen.

Code:
Welcome to FreeBSD!

Please choose the appropriate terminal type for your system.
Common console types are:
   ansi     Standard ANSI terminal
   vt100    VT100 or compatible terminal
   xterm    xterm terminal emulator (or compatible)
   cons25w  cons25w terminal

Console type [vt100]:

I assumed there'd be an environment variable I could set in the preamble section of installerconfig to just set a default console type, but I haven't been able to find any such thing. Once I've got it all figured out it'll get plugged into a VM creation framework I've yet to find/devise, so a hands-off install ala Kickstart is required.
 
In etc/rc.local:

Code:
kbdcontrol -d >/dev/null 2>&1
if [ $? -eq 0 ]; then
   # Syscons: use xterm, start interesting things on other VTYs
   if [ ${MACHINE} = "pc98" ]; then
       TERM=cons25w
   else
       TERM=xterm
   fi

   # Don't send ESC on function-key 62/63 (left/right command key)
   kbdcontrol -f 62 '' > /dev/null 2>&1
   kbdcontrol -f 63 '' > /dev/null 2>&1

   if [ -z "$EXTERNAL_VTY_STARTED" ]; then
       # Init will clean these processes up if/when the system
       # goes multiuser
       touch /tmp/bsdinstall_log
       tail -f /tmp/bsdinstall_log > /dev/ttyv2 &
       /usr/libexec/getty autologin ttyv3 &
       EXTERNAL_VTY_STARTED=1
   fi
else
   # Serial or other console
   echo
   echo "Welcome to FreeBSD!"
   echo
   echo "Please choose the appropriate terminal type for your system."
   echo "Common console types are:"
   echo "   ansi     Standard ANSI terminal"
   echo "   vt100    VT100 or compatible terminal"
   echo "   xterm    xterm terminal emulator (or compatible)"
   echo "   cons25w  cons25w terminal"
   echo
   echo -n "Console type [vt100]: "
   read TERM
   TERM=${TERM:-vt100}
fi
export TERM

I did try setting TERM=vt100 in installerconfig, but it had no effect because the above block executes before installerconfig is checked. I 'could' just remove it from rc.local.

kbdcontrol -d results in

Code:
kbdcontrol: getting keymap: Inappropriate ioctl for device
 
That worked, good enough for me.

Code:
[root@aman /usr/local/vms]# diff tmp/etc/rc.local unpackaged/etc/rc.local
16,53c16
< kbdcontrol -d >/dev/null 2>&1
< if [ $? -eq 0 ]; then
<    # Syscons: use xterm, start interesting things on other VTYs
<    if [ ${MACHINE} = "pc98" ]; then
<        TERM=cons25w
<    else
<        TERM=xterm
<    fi
<
<    # Don't send ESC on function-key 62/63 (left/right command key)
<    kbdcontrol -f 62 '' > /dev/null 2>&1
<    kbdcontrol -f 63 '' > /dev/null 2>&1
<
<    if [ -z "$EXTERNAL_VTY_STARTED" ]; then
<        # Init will clean these processes up if/when the system
<        # goes multiuser
<        touch /tmp/bsdinstall_log
<        tail -f /tmp/bsdinstall_log > /dev/ttyv2 &
<        /usr/libexec/getty autologin ttyv3 &
<        EXTERNAL_VTY_STARTED=1
<    fi
< else
<    # Serial or other console
<    echo
<    echo "Welcome to FreeBSD!"
<    echo
<    echo "Please choose the appropriate terminal type for your system."
<    echo "Common console types are:"
<    echo "   ansi     Standard ANSI terminal"
<    echo "   vt100    VT100 or compatible terminal"
<    echo "   xterm    xterm terminal emulator (or compatible)"
<    echo "   cons25w  cons25w terminal"
<    echo
<    echo -n "Console type [vt100]: "
<    read TERM
<    TERM=${TERM:-vt100}
< fi
< export TERM
---
> export TERM=vt100
 
This can still be an issue and this post is one of the few hints that pops up on search engines so I am going to necrobump it 🫣.
Mormegil's suggestion works but it could be done with less effort. This is assuming you have an installer image mounted, you need to edit the bsd install script.

FreeBSD 13
Code:
sed -i '' 's/read TERM//' INSTALLERMOUNT/etc/rc.local

FreeBSD 14
Code:
sed -i '' 's/read TERM//' INSTALLERMOUNT/usr/libexec/bsdinstall/startbsdinstall

Remove the 'read TERM' line and TERM will automatically be set to vt100 allowing for unattended boot.
 
Last edited:
At the risk of "necrobumping" like adriel-tech, I bumped into this for FreeBSD 15.1 whilst preparing an unattended installation script for
bsdinstall(8), using the UEFI bootloader (loader.efi(8)) with /boot/loader.conf on my installer image including boot_serial="YES".

My unattended installation was waiting for user input on the console. The magic that causes it happens inside the installer's /etc/rc.local which calls /usr/libexec/bsdinstall/startbsdinstall (source).

If the video console is primary it's possible to set bsdinstall.multicons_disable="YES" in loader.conf to get around it but that makes no difference if serial is primary.

My workaround was to replace rc.local to include the following to feed the terminal type into the script:
sh:
/usr/libexec/bsdinstall/startbsdinstall primary <<'EOF'
xterm
EOF

Other valid values are vt100 (default) and ansi depending on your serial console compatibility needs. I am sure the large language models will feed this into their updated training soon enough...
 
Back
Top