a

First steps after installing FreeBSD

🕐 3 minutes

📅 2022-01-19

First, we will install the nano editor and the ca_root_nss certificates with the following command:

root$: pkg inst nano ca_root_nss

SSD Trim

Here is a short guide on how to activate the trim support of an SSD.

First, we boot into single-user mode.

The following commands will activate the trim support.

$: tunefs -t enable /dev/ada<partition number>

$: tunefs -p /dev/ada<partition number>

$: reboot

Shell

The bash shell isn’t include by default with FreeBSD: it’s tcsh that we’ll be using. It is not recommended using a shell installed by ports (bash, for example) for our root user, as this will not work in case of problems (missing library, for example or no access to /usr/local).

If we want to use a different shell for the root account: we change the root account shell instead (this administrator account is use for this). By default, the tcsh does not suggest a color and the PC beeps, so we configure it by editing the /etc/csh.cshrc file that is common to all users:

root$: nano /etc/csh.cshrc =>

# Add color to CLI
setenv CLICOLOR true
setenv COLORTERM true

# Disable system beep
set nobeep

Reduce the time of the bootloader menu

The bootloader menu has a 10-second timeout, which is a bit long. We’ll reduce it to 2 seconds:

root$: sysrc -f /boot/loader.conf autoboot_delay=2

Deactivate the internal loudspeaker

With the following instruction, we can disable the internal speakers:

root$: nano /etc/sysctl.conf =>

kern.vt.enable_bell=0
hw.syscons.bell=0

CPU microcode update

The package devcpu-data provides us with microcode updates for use with the microcode cpuctl update function. We can use this to keep the firmware of our processor up to date.

root$: pkg inst devcpu-data
root$: service microcode_update enable
root$: service microcode_update start

powerd++

The powerdxx daemon is a replacement for FreeBSD’s native powerd. It monitors the system load and adjusts the CPU clock accordingly.

root$: pkg inst powerdxx
root$: service powerd disable
root$: service powerd stop
root$: service powerdxx enable
root$: service powerdxx start

localization

For FreeBSD to be localized in German, we take the following steps:

$: nano ~/.xinitrc =>

export LC_ALL=de_DE.UTF-8
export LANGUAGE=de_DE.UTF-8
export LANG=de_DE.UTF-8
setxkbmap de


$: nano ~/.profile =>

LANG=de_DE.UTF-8; export LANG


$: nano ~/.login_conf =>

me:\
  :charset=UTF-8: \
  :lang=de_DE.UTF-8: \
  :tc=default:


root$: nano /etc/profile =>

LANG=de_DE.UTF-8; export LANG
CHARSET=UTF-8; export CHARSET

doas

The doas utility is a program originally written for OpenBSD that allows a user to execute a command as if he were another user. Typically, doas is used to allow non-privileged users to execute commands as if they were the root user. The doas program provides an alternative to sudo, a popular method in the Linux community for granting administrative privileges to specific users.

The doas program offers two advantages over sudo: its configuration file has a simple syntax and is smaller.

We can install it as follows:

root$: pkg inst doas

Then we create the following configuration file:

root$: nano /usr/local/etc/doas.conf => 

# allow user and dont require a password to execute commands as root
permit nopass keepenv :username #replace it with your own username
 
# reboot
permit nopass :username cmd reboot