OPNsense Forum

Archive => 16.7 Legacy Series => Topic started by: s4rs on November 22, 2016, 03:15:53 pm

Title: booting without a serial or vga console
Post by: s4rs on November 22, 2016, 03:15:53 pm
I am new to Opensense and BSD in general. I picked up a mini PC to use as a router with the intention of using Opensense. I installed Opensense fine but I found out that it won't boot on a headless system. The mini PC I have does not have a serial port, and I want to put this in a closet without a display. How do I get this to working headless.
Title: Re: booting without a serial or vga console
Post by: franco on November 22, 2016, 07:11:15 pm
I don't fully understand this. You must have had a VGA or serial attached for installation. Which image did you use? What did you do after installation?

In general you can tweak the console settings under System: Settings: Administration, but in order to fix the issue with a headless system we need to have a bit of "head" to find the actual problem.

Happy to provide patches, but not sure what to debug. :/


Cheers,
Franco
Title: Re: booting without a serial or vga console
Post by: s4rs on November 22, 2016, 07:43:33 pm
The system I have has 2 HDMI, 4 USB3, and 2 USB2 ports. When I installed I used an wireless USB Keyboard and connected to a HDMI attached monitor. The install went smoothly and the system came up fine. I configured things then did a reboot, removing the USB Keyboard and HDMI monitor, since the PC is going into my little network cabinet with no room for a monitor or keyboard. I figured I can just use the web interface at this point.

Much to my surprise the system would not boot without a monitor. I tried to set up a serial console figuring it would boot without it, but still no boot. I needed the something plugged it to get the system to boot post install.

Hope this is clear. If not let me know what I am leaving out.
Title: Re: booting without a serial or vga console
Post by: chemlud on November 22, 2016, 08:55:01 pm
Have here such embedded systems not booting without monitor attached. Problem with BIOS, not opnsense. What you need is a HDMI dummy (just a HDMI plug and a bunch of 100 Ohm resistors). Web search should help quite fast :-)
Title: Re: booting without a serial or vga console
Post by: s4rs on November 22, 2016, 09:09:14 pm
why does Smoothwall boot without a monitor attach if it is a BIOS issue?
Title: Re: booting without a serial or vga console
Post by: s4rs on November 23, 2016, 12:40:44 am
BTW I just installed Fedora 25 on the box and that boots just fine without a keyboard and display attached. So I don't think its the BIOS but Opensense..
Title: Re: booting without a serial or vga console
Post by: franco on November 23, 2016, 08:59:53 am
Hi s4rs,

Smoothwall is Linux, so it could be a problem with FreeBSD. Let's try to make the boot loader less verbose...

Modify /boot.config file by replacing its content with "-q -m" and reboot without monitor.


Cheers,
Franco
Title: Re: booting without a serial or vga console
Post by: s4rs on November 23, 2016, 04:57:27 pm
I was playing and found if I set the boot option in my bios to bios boot Opensense instead of using UEFI boot it works without a display. I will test what you recommended next.
Title: Re: booting without a serial or vga console
Post by: s4rs on November 23, 2016, 05:07:45 pm
Hi s4rs,

Smoothwall is Linux, so it could be a problem with FreeBSD. Let's try to make the boot loader less verbose...

Modify /boot.config file by replacing its content with "-q -m" and reboot without monitor.


Cheers,
Franco

I just checked and there is no /boot.config

Code: [Select]
root@OPNsense:~ # find / -name "boot*"
/boot
/boot/boot2
/boot/boot1.efifat
/boot/boot1.efi
/boot/boot1
/boot/boot0sio
/boot/boot0
/boot/boot
/dev/gpt/bootfs
/etc/rc.d/bootparams
/usr/include/sys/boot.h
/usr/include/rpcsvc/bootparam_prot.x
/usr/include/rpcsvc/bootparam_prot.h
/usr/include/fs/msdosfs/bootsect.h
/usr/libexec/bootpgw
/usr/libexec/bootpd
/usr/local/opnsense/www/themes/opnsense/build/fonts/bootstrap
/usr/local/opnsense/www/themes/opnsense/build/css/bootstrap-select.css
/usr/local/opnsense/www/themes/opnsense/build/css/bootstrap-dialog.css
/usr/local/opnsense/www/themes/opnsense/assets/stylesheets/bootstrap-select
/usr/local/opnsense/www/themes/opnsense/assets/stylesheets/bootstrap-select/less/bootstrap-select.less
/usr/local/opnsense/www/themes/opnsense/assets/stylesheets/bootstrap-dialog.less
/usr/local/opnsense/www/themes/opnsense/assets/stylesheets/bootstrap
/usr/local/opnsense/www/themes/opnsense/assets/fonts/bootstrap
/usr/local/opnsense/www/js/bootstrap-select.min.js
/usr/local/opnsense/www/js/bootstrap-select.js.map
/usr/local/opnsense/www/js/bootstrap-select.js
/usr/local/opnsense/www/js/bootstrap-dialog.min.js
/usr/local/opnsense/www/js/bootstrap-dialog.js
/usr/local/opnsense/www/js/bootstrap-datepicker.min.js
/usr/local/opnsense/www/js/bootstrap3-typeahead.min.js
/usr/local/opnsense/www/js/bootstrap3-typeahead.js
/usr/local/opnsense/www/js/bootstrap.min.js
/usr/local/opnsense/www/js/bootstrap.js
/usr/local/opnsense/www/css/bootstrap-datepicker3.min.css
/usr/local/opnsense/scripts/OPNsense/CaptivePortal/htdocs_default/js/bootstrap.min.js
/usr/local/opnsense/scripts/OPNsense/CaptivePortal/htdocs_default/css/bootstrap-theme.min.css
/usr/local/opnsense/scripts/OPNsense/CaptivePortal/htdocs_default/css/bootstrap-theme.css.map
/usr/local/opnsense/scripts/OPNsense/CaptivePortal/htdocs_default/css/bootstrap.min.css
/usr/local/opnsense/scripts/OPNsense/CaptivePortal/htdocs_default/css/bootstrap.css.map
/usr/local/lib/perl5/site_perl/mach/5.20/sys/boot.ph
/usr/sbin/bootptest
/usr/sbin/bootpef
/usr/sbin/bootparamd
/usr/sbin/boot0cfg
/usr/share/man/man9/boottime.9.gz
/usr/share/man/man9/boot.9.gz
/usr/share/man/man8/boot_i386.8.gz
/usr/share/man/man8/bootptest.8.gz
/usr/share/man/man8/bootpgw.8.gz
/usr/share/man/man8/bootpef.8.gz
/usr/share/man/man8/bootpd.8.gz
/usr/share/man/man8/bootparamd.8.gz
/usr/share/man/man8/boot0cfg.8.gz
/usr/share/man/man8/boot.8.gz
/usr/share/man/man5/bootptab.5.gz
/usr/share/man/man5/bootparams.5.gz
/usr/share/man/man5/boot.config.5.gz
/usr/share/examples/bootforth
/var/db/etcupdate/current/etc/rc.d/bootparams
/var/db/etcupdate/current/boot
/var/dhcpd/dev/gpt/bootfs
Title: Re: booting without a serial or vga console
Post by: franco on November 23, 2016, 05:18:39 pm
Hi s4rs ,

It's ok to create it. It will be rewritten after reboot for consistency, but if it helps your use case we are going to add a GUI option for it. The contents is just the single line "-q -m".


Cheers,
Franco
Title: Re: booting without a serial or vga console
Post by: s4rs on November 23, 2016, 05:25:08 pm
Do I make it executable? any special permissions?
Title: Re: booting without a serial or vga console
Post by: s4rs on November 23, 2016, 05:39:35 pm
Couple of things, first the file is lost after a reboot. If I create the file and boot I see a difference. I see a FreeBSD boot screen then boots to Opensense.

Next if I recreate the file, remove the video cable and reboot the system does not come up. So that doesn't work in UEFI mode.
Title: Re: booting without a serial or vga console
Post by: franco on November 23, 2016, 07:00:41 pm
Yes, the system wants to revert back to a known state. It deletes the file in the standard configuration when it is not needed.

If we can't observe the error we won't be able to find the fix. You could try the 17.1-ALPHA image, it has a newer FreeBSD version, but I'm expecting the same results.

https://pkg.opnsense.org/snapshots/

I don't know how to proceed in order to debug this. A bug search in FreeBSD also came up empty. :(


Cheers,
Franco
Title: Re: booting without a serial or vga console
Post by: s4rs on November 23, 2016, 08:45:14 pm
Thanks.. I will try 17.1 but agree with you that its difficult to shoot since you can't see whats going on. The things we do know are

BIOS boot works
UEFI fails
the boot.config changes fail

Now if you have some insight on how to get a serial USB device configured at boot time I can try to see if there is console output over serial. I built a null modem cable last night and tested it today and it works.. I tried setting the console boot parm to serial but got nothing on the text console I hooked up.
Title: Re: booting without a serial or vga console
Post by: s4rs on November 26, 2016, 01:26:51 am
FYI I was playing with this today and adding console="nullconsole" to /boot/loader.conf should fix this issue. In FreeBSD 10.1 release notes it states that UEFI should support this option. But no matter how I try it the option doesn't work. I tried 11.0 and it works but you have to use "NULLCONSOLE" instead of "nullconsole". I'll try 17.1 and see how that works out. I did pick up a dummy HDMI plug which also fixes the problem.
Title: Re: booting without a serial or vga console
Post by: franco on November 26, 2016, 09:34:30 am
Thanks for finding this. I added "nullconsole" support to the GUI:

https://github.com/opnsense/core/commit/f00d4309
https://github.com/opnsense/core/commit/d596905

You can apply this on top of 16.7.9 for testing using:

# opnsense-patch f00d4309 d596905

My VM did not adhere to setting the console to mute, however. I will have to try with a hardware device when I'm back home.

I double-checked the 11.0 (17.1) and 10.3 (16.7) code: there is no mention of "NULLCONSOLE", "nullconsole" is the intended value, but maybe it hasn't worked for a while and nobody used it. *shrugs*


Cheers,
Franco
Title: Re: booting without a serial or vga console
Post by: s4rs on November 26, 2016, 01:02:23 pm
In Freebsd 10.x it has to be nullconsole. Even though it didn't seem to work the loader complained if it was NULLCONSOLE. However it only worked as NULLCONSOLE in 11.0 which kind of makes sense since all the 11.x variables in loader.conf are upper case. .. In 11.x I never got an error with nullconsole but it also didn't work. Can you make a patch for 17 and I will test it? I'll let you know how I make out with the 16 patch.
Title: Re: booting without a serial or vga console
Post by: s4rs on November 26, 2016, 01:14:56 pm
stupid question, where do I get the patch? I looked at the download site but only see the full installers.
Title: Re: booting without a serial or vga console
Post by: fabian on November 26, 2016, 01:20:41 pm
a patch is a diff in git from the public git repository github.com/opnsense/core and it can be downloaded and applied using the opnsense-patch utility.
Title: Re: booting without a serial or vga console
Post by: s4rs on November 26, 2016, 01:23:45 pm
So from the GUI got to System -> Firmware -> Updates -> Check for Updates and grab it from there? I need to reinstall 16.x to test..
Title: Re: booting without a serial or vga console
Post by: franco on November 26, 2016, 01:27:40 pm
There is not a single uppercase mention of NULLCONSOLE. I double-checked. It may be that text processing is doing something weird in the boot loader code, but that would only further add to ambiguity. :)

What's worse, I think any attempt to print to a detached device will freeze the boot. I did some more cleaning in our bootup code to make sure that it never tries to flip on console output.

As far as patching goes: update the install to 16.7.9, then run this command:

# opnsense-patch f00d4309 d596905

And you're all set for using the setting under System: Settings: Administration (it's called primary console, set to "mute console").


Cheers,
Franco
Title: Re: booting without a serial or vga console
Post by: franco on November 26, 2016, 01:31:07 pm
Oh, I see it works, but only for boot loader menu and kernel bootup. It then prints the RC messages...
Title: Re: booting without a serial or vga console
Post by: franco on November 26, 2016, 01:48:28 pm
And further down the rabbit-hole, the system now supports setting boot.config settings for mute boot, the tty is disabled, but it still prints all the RC messages... whew, this is complicated, but we're getting there.
Title: Re: booting without a serial or vga console
Post by: s4rs on November 26, 2016, 02:44:11 pm
I tested it and can see nullconsole survives a reboot. Still doesn't work but I didn't expect it to in BSD 10.3. Its definitely a 10.x bug. Can I try the same patch on 17? or do you need to write a patch for that? Again in 11.x I think the option should be all upper case.
Title: Re: booting without a serial or vga console
Post by: franco on November 26, 2016, 03:11:36 pm
Yes, but should wait for 17.1-BETA to arrive along with images (2 weeks out tops). Currently it requires upgrading to 17.1-ALPHA and updating the core package using git.

Muting the RC output is giving me several different head-aches ATM, if indeed they cause the system from working properly.
Title: Re: booting without a serial or vga console
Post by: s4rs on November 26, 2016, 03:56:40 pm
NP thanks again.. Now to see if I can figure out how to get a USB serial adapter to work as a boot console on FreeBSD.