This is the first post in the FreeBSD Desktop series.
The default FreeBSD boot process is quite verbose with a lot of debugging information along with kernel messages. We may divide that boot process into several ‘screens’ or stages. First thing You see is the ‘BIOS’ screen of the computer manufacturer. Second thing is the FreeBSD BTX Loader. The third one is the FreeBSD Boot Menu with eventual ZFS Boot Environments if You use ZFS for root filesystem and other options to select like Single User Mode for example. The 4th one is the system boot along with kernel messages in non-native resolution. In the middle of that stage screen switches to native resolution and continues to display kernel messages and services leading to the text prompt with login:
at the end. There comes optional fifth screen which may be graphically started (x11) login manager like slim
or gdm
.
This verbose information is usually useful for servers but not that much for laptops and/or desktop/workstation systems. The UNIX philosophy is to not ‘say’ anything to stdout
if everything is OK, so
/stdout
stderr
should only be used when something is wrong … like on AMIGA, if anything is wrong then I want to see big red sign like [GURU MEDITAION] but if everything is ok, shut the … slience is golden 🙂
I really like Sun Solaris 10 approach here, that it boots with minimal information like its version and hostname into the login:
prompt in less then 10 lines. The image below is from the first Sun Solaris 10 boot, so it includes additional OpenSSH server key generation information.
Unfortunately – despite what Oracle says – Oracle Solaris is dying, I gathered most of the information here – Oracle just killed Solaris/SPARC/ZFS teams – https://forums.freebsd.org/threads/62320/ – on FreeBSD Forums. The recent Oracle Solaris 11.4 release process along with public beta will not change that. Oracle Solaris will be kept in maintenance mode for the rest of its life, which is set by Oracle to 2034 currently. Pity because even BSD bits recently found its way into it Solaris, for example the OpenBSD PF firewall, there are some differences – Comparing PF in Oracle Solaris to IP Filter and to OpenBSD Packet Filter – https://docs.oracle.com/cd/E37838_01/html/E60993/pfovw-comparall.html – but there are differences between OpenBSD PF and FreeBSD PF too.
Back to FreeBSD – according to the project website – https://freebsd.org/ – “FreeBSD is an operating system used to power modern servers, desktops, and embedded platforms” so why not tune the boot process to be more appealing on laptops/desktops? Below are the stages of the default FreeBSD boot process up to the login: prompt.
Not very lean to my standards. But with one parameter in /boot/loader.conf
and 5 slightly silenced startup scripts its whole a lot better. Here are the modifications needed.
First add the boot_mute=YES
option to the /boot/loader.conf
file.
As we are here, You may as well add autoboot_delay=2
parameter to the /boot/loader.conf
file to speed up boot process by 8 seconds. Default delay is 10 seconds.
% grep boot_mute /boot/loader.conf boot_mute=YES %
Next we will need to modify these startup scripts.
/etc/rc.d/ldconfig
/etc/rc.d/netif
/etc/rc.d/nfsclient
/etc/rc.d/random
/etc/rc.d/routing
Here is the summary of the changes. In most cases its just adding 1> /dev/null
or 1> /dev/null 2> /dev/null
to not display unneeded information at boot process.
% grep -n -E '(1|2)> /dev/null' /etc/rc.d/* | grep -E 'routing|netif|ldconfig' /etc/rc.d/ldconfig:40: check_startmsgs && echo 'ELF ldconfig path:' ${_LDC} 1> /dev/null /etc/rc.d/ldconfig:60: echo '32-bit compatibility ldconfig path:' ${_LDC} 1> /dev/null /etc/rc.d/netif:260: /sbin/ifconfig ${ifn} 1> /dev/null 2> /dev/null /etc/rc.d/routing:70: eval static_${_a} delete $_if 1> /dev/null 2> /dev/null /etc/rc.d/routing:97: static_$2 add $3 1> /dev/null 2> /dev/null /etc/rc.d/routing:104: static_$2 add $3 add $3 1> /dev/null 2> /dev/null
The only exception is the /etc/rc.d/random which requires little more love.
% grep -n -A 8 'random_start()' /etc/rc.d/random 45:random_start() 46-{ 47- 48- # if [ ${harvest_mask} -gt 0 ]; then 49- # echo -n 'Setting up harvesting: ' 50- # ${SYSCTL} kern.random.harvest.mask=${harvest_mask} > /dev/null 51- # ${SYSCTL_N} kern.random.harvest.mask_symbolic 52- # fi 53-
Here are diff(1)
patches if that way will be easier for you.
% diff -rq ~/CLEAN-FreeBSD-11.1-RELEASE/etc/rc.d /etc/rc.d | column -t Files ~/CLEAN-FreeBSD-11.1-RELEASE/etc/rc.d/ldconfig and /etc/rc.d/ldconfig differ Files ~/CLEAN-FreeBSD-11.1-RELEASE/etc/rc.d/netif and /etc/rc.d/netif differ Files ~/CLEAN-FreeBSD-11.1-RELEASE/etc/rc.d/nfsclient and /etc/rc.d/nfsclient differ Files ~/CLEAN-FreeBSD-11.1-RELEASE/etc/rc.d/random and /etc/rc.d/random differ Files ~/CLEAN-FreeBSD-11.1-RELEASE/etc/rc.d/routing and /etc/rc.d/routing differ
% diff -u ./rc.d/ldconfig /etc/rc.d/ldconfig --- ./rc.d/ldconfig 2017-07-21 04:11:06.000000000 +0200 +++ /etc/rc.d/ldconfig 2017-12-18 09:12:18.190074000 +0100 @@ -37,7 +37,7 @@ _LDC="${_LDC} ${i}" fi done - check_startmsgs && echo 'ELF ldconfig path:' ${_LDC} + check_startmsgs && echo 'ELF ldconfig path:' ${_LDC} 1> /dev/null ${ldconfig} -elf ${_ins} ${_LDC} case `sysctl -n hw.machine_arch` in @@ -57,7 +57,7 @@ fi done check_startmsgs && - echo '32-bit compatibility ldconfig path:' ${_LDC} + echo '32-bit compatibility ldconfig path:' ${_LDC} 1> /dev/null ${ldconfig} -32 -m ${_ins} ${_LDC} ;; esac
% diff -u ./rc.d/netif /etc/rc.d/netif --- ./rc.d/netif 2017-07-21 04:11:06.000000000 +0200 +++ /etc/rc.d/netif 2017-11-30 17:32:11.394251000 +0100 @@ -257,7 +257,7 @@ esac if check_startmsgs; then for ifn in ${_ok}; do - /sbin/ifconfig ${ifn} + /sbin/ifconfig ${ifn} 1> /dev/null 2> /dev/null done fi fi
% diff -u ./rc.d/nfsclient /etc/rc.d/nfsclient --- ./rc.d/nfsclient 2017-07-21 04:11:06.000000000 +0200 +++ /etc/rc.d/nfsclient 2017-12-18 09:15:38.200376000 +0100 @@ -44,7 +44,7 @@ # successfully notified about a previous client shutdown. # If there is no /var/db/mounttab, we do nothing. if [ -f /var/db/mounttab ]; then - rpc.umntall -k + rpc.umntall -k 2> /dev/null fi } load_rc_config $name
% diff -u ./rc.d/random /etc/rc.d/random --- ./rc.d/random 2017-07-21 04:11:06.000000000 +0200 +++ /etc/rc.d/random 2018-01-09 13:32:18.439347000 +0100 @@ -45,13 +45,13 @@ random_start() { - if [ ${harvest_mask} -gt 0 ]; then - echo -n 'Setting up harvesting: ' - ${SYSCTL} kern.random.harvest.mask=${harvest_mask} > /dev/null - ${SYSCTL_N} kern.random.harvest.mask_symbolic - fi + # if [ ${harvest_mask} -gt 0 ]; then + # echo -n 'Setting up harvesting: ' + # ${SYSCTL} kern.random.harvest.mask=${harvest_mask} > /dev/null + # ${SYSCTL_N} kern.random.harvest.mask_symbolic + # fi - echo -n 'Feeding entropy: ' + echo -n 'Feeding entropy:' if [ ! -w /dev/random ] ; then warn "/dev/random is not writeable"
% diff -u ./rc.d/routing /etc/rc.d/routing --- ./rc.d/routing 2017-07-21 04:11:06.000000000 +0200 +++ /etc/rc.d/routing 2017-12-18 09:22:16.604428000 +0100 @@ -67,7 +67,7 @@ ""|[Aa][Ll][Ll]|[Aa][Nn][Yy]) for _a in inet inet6 atm; do afexists $_a || continue - eval static_${_a} delete $_if + eval static_${_a} delete $_if 1> /dev/null 2> /dev/null # When $_if is specified, do not flush routes. if ! [ -n "$_if" ]; then eval routing_stop_${_a} @@ -94,14 +94,14 @@ _ret=0 case $1 in static) - static_$2 add $3 + static_$2 add $3 1> /dev/null 2> /dev/null _ret=$? ;; options) options_$2 ;; doall) - static_$2 add $3 + static_$2 add $3 add $3 1> /dev/null 2> /dev/null _ret=$? options_$2 ;;
Now lets see how FreeBSD boots now after the modifications.
Its definitely not perfect, but a lot better in my taste.
Now lets login to desktop 🙂
I prefer not to use a login manager so I have an alias named x
to xinit
command. This way after I login I type x
press [ENTER] and x11 desktop is started.
% which x x: aliased to xinit ~/.xinitrc -- -dpi 75 -nolisten tcp 1> /dev/null 2> /dev/null
EOF.
. . . . . . . . . . . . . . . . . . . .
It’s a laptop. This means it is a personal platform. It’s not a kiosk. It’s not for a family member who would be intimidated and confused. Why on earth would you waste your time hiding information which may be potentially valuable in the future?
And then, to top it off, you eschew XDM in order to use the very text console you’d been hiding.
Madness.
LikeLike
> It’s a laptop. This means it is a personal platform. It’s not a kiosk. It’s not for a family member who would be intimidated and confused.
Yes, maybe, yep, rather not.
> Why on earth would you waste your time hiding information which may be potentially valuable in the future?
Because its only POTENTIALLY valuable and its useless and annoying for 99.999% of the time.
> And then, to top it off, you eschew XDM in order to use the very text console you’d been hiding.
I do not hide from console, I suppress the unneeded output from it.
> Madness.
Naturally 😉
https://forums.freebsd.org/threads/31662/
LikeLiked by 1 person
Pingback: [How-To] Nextcloud 13 on FreeBSD - FreeBSDNews.com
Pingback: FreeBSD desktop (1) | 0ddn1x: tricks with *nix
Did you consider adding exec > /dev/null into /etc/rc ?
LikeLike
I haven’t tried that.
LikeLike