If special PCIe devices like network cards are installed in the system it may be needed to load the corresponding drivers.
If the drivers for this hardware are already available from FreeBSD they can be loaded via an addition in /boot/loader.conf.
A list if the available drivers for a given release of FreeBSD can be found on the official website. Take a look at the 14.0 Release drivers here.
To load for instance the driver for Mellanox ConnectX network cards add the following line to /boot/loader.conf:
It is advisable to create ZFS datasets for directories that you probably want to have fallback versions in the future.
One of these directories could be for instance /usr/local.
See the following documentation on how to create a ZFS dataset.
Create dataset
First take a look at the currently available datasets by using the following command:
zfs list
If the dataset is not already present create a new one using this command:
To create the examplary folder from above use the following command:
zfs create zroot/usr/local
Make first snapshot of your datasets to roll back when needed
If you create a snapshot of the root datasets directly after installation it will be possible to roll back in case something goes wrong during setup of the server.
To create a snapshot follow this example:
Create a Snapshot
To create a ZFS snapshot simply use the snapshot command on the target dataset. If also descendent file systems should be snapshotted use the -r option like this:
zfs snapshot -r <path_to_dataset>@<snapshot_name>
An example could look like this:
zfs snapshot -r pool/home@yesterday
Info
Snapshots can also be renamed using zfs rename. So there is no need to destroy and recreate a snapshot because of a typo.
Periodic tasks include for instance automatic scrubbing. These periodic tasks are configured in the /etc/periodic.conf file. This file has to be created and can initially be copied over from the default file /etc/defaults/periodic.conf.
Also make sure to set the value for daily_output at the top of the file. The given absolute path or space seperated mail addresses are used to store / send the output of the scripts run by the daily tasks configuration.
Also take a look here on how to set up automatic scubs:
Setting up automatic scrub for ZFS pools
Per default in FreeBSD scrubs are scheduled every 35 days but the scrubbing is disabled. This is configured in /etc/defaults/periodic.conf with the following lines:
# 800.scrub-zfs daily_scrub_zfs_enable="NO" daily_scrub_zfs_pools="" # empty string selects all pools daily_scrub_zfs_default_threshold="35" # days between scrubs #daily_scrub_zfs_${poolname}_threshold="35" # pool specific threshold
To enable automatic scrubbing copy the default periodic.conf to /etc:
cp /etc/defaults/periodic.conf /etc/periodic.conf
Then enable daily_scrub_zfs_enable by setting it to "YES".
Info
It is important to check at which time the daily, weekly and monthly periodic tasks are scheduled. If the server is not running at that time the tasks would not be executed. The tasks are scheduled in the /etc/crontab file.
To check when the last scrub was and if it repaired any errros this command can be used - note that if no scrub was performed so far no information will be displayed regarding scrubs:
When in single user mode many system services are not started per default.
Also the file system will be mounted as read-only.
To edit configuration files for the file system first has to be mounted with read rights.
This can be done as follows depending on the filesystem:
UFS
mount -u /mount -a -t ufs
ZFS
mount -u /zfs mount -a
Manage SSH Daemon
To start or restart the SSH daemon use the following command:
In order to identify disks uniquely even after they were swapped to different SATA / ATA ports two main methods can be used. However, depending on which method is used the disks will also be mounted correspondingly.
This means, if a disk is mounted in /etc/fstab using a GPT label as /dev/ada3p1 then it will be mounted under this location and even if it has a GPT label associated it will not be available in /dev/gpt/<label>.
Using Disk IDS
It is possible to use the individual Disk IDs instead of the /dev/sdX nomenclature when identifying disks.
The Disk IDs and GPT IDs have to be enabled in /boot/loader.conf:
These Disk IDs are unique and will help to uniquely identify your disks. However, they are not easy to remember and will not help finding a disk in your system without checking the serial number every time. This, it can be helpful to define custom labels for each disk. This can be done using GPT Labels like explained below.
Another method to uniquely identify disks even when they were removed and added again to the system is to create GPT Labels.
These GRP Labels can be defined manually and therefore be used to define disk labels that for instance show the physical location of the drive in an enclosure.
Assuming for instance there is a disk ada0 and a disk ada1 un the system that should be labelled for use with ZFS, the following commands can be used to create a GPT partition on the whole disks. After that they are labelled with a name showing their location in the system:
If you are using this method of identifying your disks it is advisable to disable other methods so that only the custom labels will be used. To do so add following lines to the /boot/loader.conf:
A NFS share can be set up in FreeBSD quite easily.
First all corresponding services have to be started at startup of the FreeBSD system. This can be configured in the /etc/rc.config file like this:
If this is setup a share can be exported using these steps:
Export NFS share
To export a NFS share the exports configuration file has to be adjusted.
On a FreeBSD server the /etc/exports file could look something like this:
V4: /data/data/testshare -maproot=0:10
This specific configuration will share the testshare directory with NFS V4 of the data share and map UIDs 0 to 10 to the root user. This means all users that share the UID of the owner of the files inside the share and all root UIDs can edit the share files.
This means if you want non-root users to edit files in a share, it is necessary that UIDs of the file owner on the server and client match.
Make sure to setup the nfs_server_flags correctly on FreeBSD machines, otherwise the NFS shares will cause problems if they are used for appdata storage of Docker containers or similar.
Start with the exemplary configuration in Setting up NFS shares.
If special PCIe devices like network cards are installed in the system it may be needed to load the corresponding drivers.
If the drivers for this hardware are already available from FreeBSD they can be loaded via an addition in /boot/loader.conf.
A list if the available drivers for a given release of FreeBSD can be found on the official website. Take a look at the 14.0 Release drivers here.
To load for instance the driver for Mellanox ConnectX network cards add the following line to /boot/loader.conf:
mlx4en_load="YES"
Setting up automatic scrub for ZFS pools
Per default in FreeBSD scrubs are scheduled every 35 days but the scrubbing is disabled. This is configured in /etc/defaults/periodic.conf with the following lines:
# 800.scrub-zfs daily_scrub_zfs_enable="NO" daily_scrub_zfs_pools="" # empty string selects all pools daily_scrub_zfs_default_threshold="35" # days between scrubs #daily_scrub_zfs_${poolname}_threshold="35" # pool specific threshold
To enable automatic scrubbing copy the default periodic.conf to /etc:
cp /etc/defaults/periodic.conf /etc/periodic.conf
Then enable daily_scrub_zfs_enable by setting it to "YES".
Info
It is important to check at which time the daily, weekly and monthly periodic tasks are scheduled. If the server is not running at that time the tasks would not be executed. The tasks are scheduled in the /etc/crontab file.
To check when the last scrub was and if it repaired any errros this command can be used - note that if no scrub was performed so far no information will be displayed regarding scrubs: