FreeBSD Server

Posted on Tue 06 May 2014 in english

This post will show how I set up my FreeBSD server which aims to act as a fileserver (primarily).

Failover

# ifconfig igb0 up
# ifconfig igb1 up
# ifconfig lagg0 create 
# ifconfig lagg0 up laggproto lacp laggport igb0 laggport igb1 10.0.1.1/8

This is how the result looks:

lagg0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=403bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,VLAN_HWTSO>
    ether 0c:c4:7a:00:c6:be
    inet 10.0.1.1 netmask 0xff000000 broadcast 10.255.255.255 
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
    media: Ethernet autoselect
    status: active
    laggproto failover lagghash l2,l3,l4
    laggport: igb1 flags=0<>
    laggport: igb0 flags=5<MASTER,ACTIVE>

To make this changes persistent add the following entries to your /etc/rc.conf:

ifconfig_igb0="up"
ifconfig_igb1="up"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto lacp laggport igb0 laggport igb1 10.0.1.1/8"

Automatic FreeBSD panic reporting

To enable automatic panic reporting to give devs something to do :) install sysutils/panicmail and:

# echo 'dumpdev="AUTO"' >> /etc/rc.conf
# echo 'panicmail_enable="YES"' >> /etc/rc.conf
# echo 'panicmail_autosubmit="YES"' >> /etc/rc.conf         (if you don't want to go through your dump reports)

I have an APC UPS connected to my server. Install sysutils/apcupsd for this device and add

apcupsd_enable="YES"

to your /etc/rc.conf to start the daemon on boot. My UPS is connected via USB so I had to change the UPSTYPE in the config file

# cd /usr/local/etc/apcupsd
# cp apcupsd.conf.sample apcupsd.conf
# vim apcupsd.conf # Change UBSTYPE to usb and comment the DEVICE line
# /usr/local/etc/rc.d/apcupsd start

Now you can test your daemon:

# apcaccess status
APC      : 001,036,0912
DATE     : 2014-04-28 22:54:06 +0200  
HOSTNAME : scumm-server
VERSION  : 3.14.10 (13 September 2011) freebsd
UPSNAME  : scumm-server
CABLE    : USB Cable
DRIVER   : USB UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2014-04-28 17:51:48 +0200  
MODEL    : Back-UPS RS 900G 
STATUS   : ONLINE 
LINEV    : 230.0 Volts
LOADPCT  :   7.0 Percent Load Capacity
BCHARGE  : 100.0 Percent
TIMELEFT : 153.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
SENSE    : Medium
LOTRANS  : 176.0 Volts
HITRANS  : 294.0 Volts
ALARMDEL : 30 seconds
BATTV    : 27.4 Volts
LASTXFER : No transfers since turnon
NUMXFERS : 0
TONBATT  : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x07000008 Status Flag
SERIALNO : 3B1402X00418  
BATTDATE : 2014-01-06
NOMINV   : 230 Volts
NOMBATTV :  24.0 Volts
NOMPOWER : 540 Watts
FIRMWARE : 879.L4 .I USB FW:L4
END APC  : 2014-04-28 22:55:06 +0200

EZJail setup on ZFS

Jails work great on the world's best filesystem and thanks to erdgeist's work it's SO easy to set up! Install ezjail from packages or ports and add the following line to your /etc/rc.conf:

ezjail_enable="YES"

EZJails is configured for UFS (the classic unix filesystem) by default, but it has some knobs for ZFS build-in:

# Setting this to YES will start to manage the basejail and newjail in ZFS
ezjail_use_zfs="YES"

# Setting this to YES will manage ALL new jails in their own zfs
ezjail_use_zfs_for_jails="YES"
ezjail_jailzfs="zpool/usr/jails"

Change the parameter for ezjail_jailzfs to whatever your zfs pool is named and append the path for jails (/usr/jails by default).

Create the zfs pool to use it with ezjails:

$ zfs create system/usr/jails

The rest of ezjail setup is described at erdgeist's homepage or the excellent ezjail man-pages.