Hetzner - DokuWiki

FreeBSD installieren/en


FreeBSD Requirements

FreeBSD 9.0 currently does not support the Realtek 8168F NIC that can be found on the mainboard of the newer EX4 models. It is only supported as of FreeBSD 8.3 and FreeBSD 9.1

The installation of FreeBSD requires the following programs to be installed on your computer:

Starting the Rescue System

To install FreeBSD on your server, you first need to start the FreeBSD Rescue System. Log in to your server via SSH. For reasons of security, it is recommended that you have a backup of your server before proceeding.

Automatic Installation

The installation can be started by using the following command:

# bsdinstallimage

The script is based on the official freebsd "bsdinstall". In the dialogs you can select options like version, architecture and packets. The source file are downloaded from the official freebsd mirror. After the installation is complete, you can restart your server:

# reboot

A few minutes later your server will once again be reachable via SSH.

Manual Installation

To perform the installation, you will need to decide which drives you wish to install FreeBSD onto. A list of all the drives in your server can be found with:

# ls -1 /dev/ad* /dev/da* /dev/twed* /dev/aacd* | grep -E '[a-z]{2}[0-9]+$'

Additional information on the single drives can also be found as follows:

# dmesg | grep da0
da0 at mpt0 bus 0 scbus0 target 0 lun 0
da0: <VMware Virtual disk 1.0> Fixed Direct Access SCSI-2 device
da0: 320.000MB/s transfers (160.000MHz, offset 127, 16bit)
da0: Command Queueing enabled
da0: 20480MB (41943040 512 byte sectors: 255H 63S/T 2610C)

Installation using ZFS

You can now install FreeBSD using the "zfsinstall" script (part of mfsBSD - see also http://mfsbsd.vx.sk/). Please ensure that you select the correct file, (current 8.3-RELEASE i386.iso or 8.3-RELEASE amd64.iso for 64bit CPUs):

# zfsinstall -d da0 -d da1 -t /nfs/mfsbsd/8.3-release-i386.tbz -s 4G
Notice: two drives selected, automatically choosing mirror mode
Creating GUID partitions on da0 ... done
Configuring ZFS bootcode on da0 ... done
=>      34  41942973  da0  GPT  (20G)
        34       128    1  freebsd-boot  (64K)
       162   8388608    2  freebsd-swap  (4.0G)
   8388770  33554237    3  freebsd-zfs  (16G)
Creating GUID partitions on da1 ... done
Configuring ZFS bootcode on da1 ... done
=>      34  41942973  da1  GPT  (20G)
        34       128    1  freebsd-boot  (64K)
       162   8388608    2  freebsd-swap  (4.0G)
   8388770  33554237    3  freebsd-zfs  (16G)

Creating ZFS pool tank on da0p3 da1p3 ... done
Creating tank partitions: root usr var tmp ... done
Setting bootfs for tank to tank/root ... done
tank        218K  15.6G    18K  none
tank/root    18K  15.6G    18K  legacy
tank/tmp     18K  15.6G    18K  legacy
tank/usr     18K  15.6G    18K  legacy
tank/var     18K  15.6G    18K  legacy
Mounting tank on /mnt ... done
Extracting FreeBSD distribution ... done
Writing /boot/loader.conf... done
Writing /etc/fstab... done
Copying /boot/zfs/zpool.cache ... done

Installation complete.
The system will boot from ZFS with clean install on next reboot

You may type "chroot /mnt" and make any adjustments you need.
For example, change the root password or edit/create /etc/rc.conf for
for system services

Note: If a different operating system was installed on your server, you may be asked to delete your partition table:

Error: /dev/da0 already contains a partition table.
=>      34  41942973  da0  GPT  (20G)
        34       128    1  freebsd-boot  (64K)
       162   8388608    2  freebsd-swap  (4.0G)
   8388770  33554237    3  freebsd-zfs  (16G)

You may erase the partition table manually with the destroygeom command

This may be done using the "destroygeom" command:

# destroygeom -d da0
Destroying geom da0:
   Deleting partition 1 ... done
   Deleting partition 2 ... done
   Deleting partition 3 ... done

ZFS v5000 features and disk alignment

FreeBSD 9.2 and higher include the newest v5000 zpool functionality, including improved compression using lz4 engine (faster and less space).

Unfortunately the newer MFSBSD 9.2 image is yet not available within Hetzner directly, but can be written to the drives in a new server as follows, after using the current 8.x base rescue CD:

# erase all partitions and data on mirror SATA drives
destroygeom -d ada0 -d ada1
# retrieve latest MFSBSD version
cd /tmp && ftp http://mfsbsd.vx.sk/files/images/9/amd64/mfsbsd-se-9.2-RELEASE-amd64.img
# confirm the checksum is valid and write over existing boot & root partition
md5  mfsbsd-se-9.2-RELEASE-amd64.img | \
  grep 725ff6ae7e9595d5a7b0cb46d4555804 && echo md5 OK && \
  dd if=mfsbsd-se-9.2-RELEASE-amd64.img of=/dev/ada0 bs=64k && \
  dd if=mfsbsd-se-9.2-RELEASE-amd64.img of=/dev/ada1 bs=64k && \

Note that for SSD-based servers and many newer SATA drives, the default disk partitions should be both 4k-aligned and using 4k block size, not the older 0,5K block size. This will significantly reduce wear & improve both performance and lifespan on SSDs, and performance for both SATA and SSD models.

The MFSBSD zfsinstall script has a fork that supports these zpool v5000 improvements (block size & partition alignment, lz4 compression, zpool v5000 by default) modified zfsinstall with flags included in the zfsinstall -h help notes.

To use this, after the reboot you will need to fetch the newer zfsinstall script and run that instead. SSH into your instance, using root and mfsroot as the password, then fetch the newer version and proceed as normal:

fetch -o /root/bin/zfsinstall https://github.com/jsonified/mfsbsd/blob/master/tools/zfsinstall

These changes have been submitted as patches to the mfsbsd project.

Installation using UFS

Optional: If you wish to install FreeBSD with software RAID1 you can now use GEOM to configure a mirror (in this example the drives /dev/da0 and /dev/da1 are used):

# gmirror label -vb round-robin gm0 da0
# gmirror load
# gmirror insert gm0 da1

If RAID1 is configured /dev/mirror/gm0 should be used in the following steps instead of /dev/daX.

It is not possible to configure partitions or labels using "sysinstall", since the Rescue System is not an init process, so the drives need to be given a disk label:

# fdisk -BI /dev/ad0

The error regarding GEOM can be ignored here.

# bsdlabel -wB /dev/ad0s1
# bsdlabel -e /dev/ad0s1

Example label (4GB swap file, the rest is for /):

# /dev/ad0s1:
8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:         *       16    4.2BSD        0     0
  b:        4G        *      swap        0     0
  c:         *        0    unused        0     0         # "raw" part, don't edit

Now, a file system needs to be installed on the newly configured partitions:

# newfs -U /dev/ad0s1a
/dev/ad0s1a: 148531.3MB (304192160 sectors) block size 16384, fragment size 2048
	using 809 cylinder groups of 183.77MB, 11761 blks, 23552 inodes.
super-block backups (for fsck -b #) at:
 160, 376512, 752864, 1129216, 1505568, 1881920, 2258272, 2634624, 3010976, [...]

In case you have defined multiple partitions and not just the swap space, you will need to format those as well.

You can then mount the partitions with "/mnt":

# mount /dev/ad0s1a /mnt

After this you can start the FreeBSD installation program:

# sysinstall

Select the "Custom" option in the main menu (both of the other options will not work) and configure the options.

For the "Install Root" give the mounted address ("/mnt") and for the release version, one of the numbers in the table below. Confirm your selections with the "q" key.

The menu choices "Partition" and "Label" can be skipped (since you have already done that) and you can go directly to "Distributions". Select the "Minimal" distribution and confirm this by pressing "OK".

Confirm the question on network configuration with "Yes".

Finally, start the installation by pressing "Commit" in the menu. Afterwards, you will be asked if you wish to see the configuration menu. Simply answer "No".

You can now quit "sysinstall".


After the basic installation has been completed, you will still need to configure some of the options before you can start FreeBSD for the first time.

You can use the "bsdconfig" tool for this:

# bsdconfig
Welcome to the Hetzner configuration tool for FreeBSD.

Hostname: freebsd.hetzner.de

Changing local password for root
New Password:
Retype New Password:

Configuring rc.conf... DONE
Enabling SSH login for root... DONE
Configuring resolv.conf... DONE

Congratulations! The configuration has been completed successfully.
You can now use 'reboot' to boot your newly installed FreeBSD system.

Once the configuration has finished, you can reboot your server:

# reboot

A few minutes later you will be able to access your server with SSH again.

Network Configuration

Please note that it is not possible to reach servers on the same subnet directly. Instead, you will have to send the packets to your gateway.


The special routing paramters can be specified in /etc/rc.conf:

ifconfig_re0="inet <insert main ip>/32"
gateway_ip="<insert gateway ip>"
static_routes="gateway default"
route_gateway="-host $gateway_ip -interface $gateway_if"
route_default="default $gateway_ip"

Notice: do not use the "defaultrouter" keyword with this configuration!


The default IPv6 gateway fe80::1 can be defined in /etc/rc.conf:

# set a static local interface-route

Configure additional IP addresses

The configuration of an additional IP addresses or subnets in FreeBSD is achieved by adding the alias entries in /etc/rc.conf. For each additional subnet (or if the additional IP is on a different subnet than the main IP), the correct netmask must be used on the first IP address for that subnet. All subsequent IP addresses should be added as /32's (

ifconfig_<interface>_alias0="inet <ipadresse1> netmask"
ifconfig_<interface>_alias1="inet <ipadresse2> netmask"

© 2020. Hetzner Online GmbH. Alle Rechte vorbehalten.