To tell your FreeBSD installation to prefer IPv6 over IPv4, add the following line to your rc.conf file:
And you can activate it without a reboot by typing:
service ip6addrctl start
This instructs FreeBSD to prefer IPv6 over IPv4 where possible (and falling back to IPv4 when needed)
To activate IPFW in a FreeBSD machine without having to recompile a kernel, you can add the following lines to /boot/loader.conf (you may need to create it if it doesn’t exist):
On the next reboot, your machine will have ipfw loaded and will default to accept. (if you had run kldload ipfw the default rule would be deny and you’d be locked out of your machine so be warned!)
Configuring a swap file in FreeBSD 10 changed to handle some internal issues and race conditions.
Swapfiles are useful if you need to add extra swap space to an existing installation, or if you want to add swap space protected by ZFS pools.
First, create the swapfile on the disk. In the example below, i’m creating a 4GB swapfile called /swapfile.dat:
dd if=/dev/zero of=/swapfile.dat bs=1m count=4096
chmod 0600 /swapfile.dat
Now we’ve created the swapfile, we need to tell FreeBSD to mount it on startup.
Edit (or create) your /etc/fstab file with your favourite editor, and add the following line:
md99 none swap sw,file=/swapfile.dat 0 0
This will instruct the boot sequence to create a pseudo node called /dev/md99 which will be mapped to /swapfile.dat and mounted as swap.
If you wanted multiple swapfiles (perhaps on multiple pools), repeat the above steps and change the md99 to md98 etc. for each swapfile.
The new FreeBSD 10 installer makes a lot of things easier (such as installing ZFS or encrypted filesystems), but there’s a few quick hints I have:
If installing using a UFS fileystem type (the default), I prefer to re-partition so that the swap space is at the start of the disk instead of the end.
This makes it easiest to expand the root filesystem later (especially if you’re installing onto a virtual machine)
If installing using ZFS and using multiple disks the installer will spread your swap partition across all disks – however these will NOT be protected by ZFS.
If you have a disk failure, any swap space on that disk will disappear and your machine will potentially crash and reboot.
I prefer to set the swap space to “0G” which causes the installer not to create a swap partition, and then I configure a swap file instead (i’ll post another blog post about creating swap files in FreeBSD 10+) which is protected by the ZFS subsystem.
This doesn’t apply if you’re installing onto a single drive (or a hardware raid array)
If you want any kind of performance from encrypted ZFS, make sure your CPU supports the ‘AESNI’ (or AES New Instructions) flag – it really makes a huge difference to the speed achieved.