ZFS on FreeBSD

10Mar 2013

ZFS on FreeBSD

by Craig Mayhew on Sun 10th Mar 2013 under General/Techie
For this test I will be running FreeBSD in a VirtualBox virtual machine. These instructions will work regardless of this.

Download the 64bit iso of FreeBSD. I am using version 9.1.

Install FreeBSD form the livecd. I decided to drop the games from the install.

I initially tried to get a bootable zfs partition going, but after several hours of failed attempts using this guide: https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/9.0-RELEASE, I decided I would leave plenty of drive space spare when partitioning the disk. I set 64GBs up for the operating system and left the rest spare for the ZFS.

Note: I have used da0 for my drive as it is a SAS drive. If you are using SATA then you will need ada0.

# gpart add -t freebsd-zfs -l disk1 da0

So, assuming you have booted freebsd, you now need to create the zfs volume.

# kldload opensolaris
# kldload zfs
# zpool create -m /zfs disk1 da0p1

Enable dedupe using fletcher4, verify hashes when writing to disk and enable compression:
# zfs set dedupe=on disk1
# zfs set dedup=fletcher4,verify disk1
# zfs set compression=gzip disk1

We will want it to mount the volume every time the system boots

# echo 'zfs_enable="YES"' >> /etc/rc.conf

Great, now we need something like network file sharing for windows so I can use it in a windows environment and just dump backups to it. (Prepare for a lot of compiling and a long wait)

# cd /usr/ports/
# portsnap fetch
# portsnap extract
# portsnap update
# cd net/samba36/
# make install

You will be asked for a whole bunch of optional packages, just stick with the defaults as the menus appear.

You will be wanting Samba to available after reboot:
# echo 'samba_enable="YES"' >> /etc/rc.conf

I am sharing my /zfs directory and have setup my smb.conf like so:
# vi /usr/local/etc/smb.conf
smbconf

In here goes your password:
# vi /usr/local/etc/samba/smbpasswd

Warning:
Do not ever use a ZFS partition for SWAP, do not place any swap files within a ZFS filesystem. The reason for this is that ZFS requires a fair amount of RAM (some argue over 1GB for every 1TB of unique data on disk). If the data ZFS keeps in RAM falls into swap then your system will very quickly ground to a halt and slowly consume all it's RAM.

Further reading:
https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/9.0-RELEASE
http://www.datadisk.co.uk/html_docs/sun/sun_zfs_cs.htm
https://wiki.freebsd.org/ZFSQuickStartGuide
http://www.freebsd.org/doc/handbook/filesystems-zfs.html

ZFS  


© 2005-2024 Craig Mayhew