FreeBSD Survival Guide

This document refers to FreeBSD 15.0.

Installation

  1. VirtualBox:

    • Use Intel Pro/1000 MT Desktop (8254OEM) network card. The inferface is available under FreeBSD as em0.

    • Change System → Motherboard → Enable EFI, and System → Motherboard → Chipset: ICH9.

    • Change Display → Graphics controller: VBoxSVGA

    • Resize the disk image before running the VM:

      # VBoxManage modifymedium disk --resize 10240 FreeBSD150.vdi
      
    • Install package virtualbox-ose-additions-72, and add to /etc/rc.conf:

      vboxguest_enable="YES"
      vboxservice_enable="YES"
      
    • Add the user to the wheel group:

      # pw groupmod wheel -m voytek
      
  2. Resize virtual drive image and then resize the partition:

    $ gpart show
    $ gpart recover ada0
    $ gpart show
    $ gpart resize -i 4 ada0
    $ gpart show
    

    and finally resize the filesystem:

    $ growfs /dev/gpt/rootfs
    
  3. Allow remote login for root by editing /etc/ssh/sshd_config:

    PermitRootLogin yes
    

    Add to /etc/rc.conf:

    sshd_enable="yes"
    

    and start SSH server:

    $ service sshd start
    

    Use bsdconfig to configure it: Configure –> Networking –> sshd.

  4. Configure boot loader: edit /boot/loader.conf.d/local.conf:

    efi_max_resolution="720p"
    screen.font="10x20"
    hw.efi.poweroff=0
    

Administration

Packages

  1. Install pkg command by running:

    $ pkg
    The package management tool is not yet installed on your system.
    Do you want to fetch and install it now? [y/N]: y
    
  2. Info about installed packages:

    $ pkg info
    $ pkg info vim
    $ pkg info -l vim
    
  3. Search for packages:

    $ pkg search vim
    
  4. Update remote repository cache:

    $ pkg update
    
  5. Install a package:

    $ pkg install vim
    
  6. Upgrade packages:

    $ pkg upgrade
    
  7. Remove unneeded packages:

    $ pkg delete vim
    $ pkg autoremove
    
  8. Usefull packages:

    bash
    htop
    ncdu
    rsync
    vim
    
  9. Clear cache:

    # pkg clear -a
    

System settings

  1. The main settings are stored in /etc/rc.conf file which consists of parameters listed in /etc/defaults/rc.conf. See rc.conf(5) for more details. The settings may be modified using sysrc, e.g.:

    # sysrc mouse_enable="YES"
    
  2. The main administration tool is bsdconfig.

  3. Install bash and set it as a default shell (/usr/local/bin/bash) for root using chsh.

  4. Networking: add to /etc/rc.conf:

    ifconfig_DEFAULT="DHCP accept_rtadv"
    

    to activate DHCP for em0 interface.

Console

  1. History is available after pressing ScrollLock.

  2. Polish keybord/fonts: add to /etc/rc.conf:

    keymap="pl"
    
  3. Mouse in text mode: add to /etc/rc.conf:

    moused_enable="YES"
    
  4. Download Terminus fonts and unpack it into /usr/share/vt/fonts. Next, add to /etc/rc.conf:

    allscreens_flags="-f ter-u20"
    

Kernel modules

  1. List of modules:

    $ kldstat
    
  2. Automatic loading of modules: edit /boot/loader.conf:

    linux_load="YES"
    

Networking

  1. Restart:

    $ service netif restart
    $ service routing restart
    
  2. Start/stop a single interface:

    $ ifconfig eth0 down
    $ ifconfig eth0 up
    
  3. Alias:

    $ ifconfig em0 192.168.1.2/24 alias
    $ ifconfig em0 192.168.1.2/24 -alias
    
  4. Show routing:

    $ netstat -r -4
    $ route add -net 192.168.2.0/24 192.168.0.1
    
  5. Show network services listening on ports:

    $ sockstat -4 -l
    

Graphical user interface

  1. Install packages:

    chromium
    droid-fonts-ttf
    lightdm
    xfce
    xorg (or xorg-minimal)
    
  2. Check the display:

    # pciconf -lv | grep -B3 display
    
  3. LightDM (display manager): edit /usr/local/etc/lightdm/lightdm.conf:

    [Seat:*]
    ...
    autologin-user=voytek
    

    and run:

    # sysrc dbus_enable="YES"
    # sysrc lightdm_enable="YES"
    

Resources

  1. FreeBSD Handbook. Available at https://www.freebsd.org/doc/handbook/.

  2. Wikipedia entry for FreeBSD: http://en.wikipedia.org/wiki/FreeBSD.