More ZFS on FreeBSD

After yesterday’s success with the ZFS configuration I’m hoping to perform some snapshots and get the compression to be a bit better. I was a bit disappointed with the compression ratio yesterday which was a pitiful 1.15x. I’ll be cheating and downloading a mail log file from one of our sendmail servers! So firstly I’ll set the copies to one and use the default compression method of lzjb. Remember that we can’t set the co ies to 1 and expect the system to delete one, so I’ll hose the data and start again when its reset.

# zfs copies=1 DATA
# zfs compression=on DATA
# cd /DATA
# rm *
# ls -lah
total 4
drwxr-xr-x   2 root  wheel     2B Oct 17 19:35 .
drwxr-xr-x  20 root  wheel   512B Oct 16 22:27 ..

Now lets copy in the file and see how much space it takes…

# cp /home/dan/maillog ./
# ls -lah
total 53055
drwxr-xr-x   2 root  wheel     3B Oct 17 19:36 .
drwxr-xr-x  20 root  wheel   512B Oct 16 22:27 ..
-rw-r-----   1 root  wheel   263M Oct 17 19:36 maillog


# zfs get available,used,compressratio,compression DATA
NAME  PROPERTY       VALUE     SOURCE
DATA  available      3.56T     -
DATA  used           102M      -
DATA  compressratio  2.59x     -
DATA  compression    on        local

Still not great, so lets select the gzip compression after first deleting the file…

# zfs compression=gzip DATA
# cp /home/dan/maillog ./
# zfs get available,used,compressratio,compression DATA
NAME  PROPERTY       VALUE     SOURCE
DATA  available      3.56T     -
DATA  used           30.8M     -
DATA  compressratio  8.74x     -
DATA  compression    gzip      local

Much better!

Snapshots

This must be the coolest feature of ZFS, lets hope it works in a manner i hope for. I’m going to add a new directory for my collection of stuff then snapshot it. After that i’ll hose the data a try to recover it.

# zfs create DATA/dans_stuff
# cp /home/dan/Downloads/FreeBSD-8.2-RELEASE-amd64-memstick.img /DATA/dans_stuff/
# mv maillog ./dans_stuff/
# cd dans_stuff/
# ls
FreeBSD-8.2-RELEASE-amd64-memstick.img maillog

Now for the snapshot…

# zfs snapshot DATA/dans_stuff@20111017

So looking for the .zfs directory and couldn’t find anything ?? Whats gone wrong??? Well upon careful reading through the man zfs I realised that the .zfs folder is invisible by default, but we can unhide it with the following:

# zfs snapdir=visible DATA/dans_stuff
# cd .zfs
# ls
shares   snapshot
# cd snapshot/
# ls
20111017
# ls -lah
total 2
dr-xr-xr-x  3 root  wheel     3B Oct 17 19:47 .
dr-xr-xr-x  4 root  wheel     4B Oct 17 19:47 ..
drwxr-xr-x  2 root  wheel     4B Oct 17 19:50 20111017
# cd 20111017/
# ls
FreeBSD-8.2-RELEASE-amd64-memstick.img maillog

Now I’ve deleted the maillog file and I want it back as it was, I’ll do a rollback.

zfs rollback DATA/dans_stuff@20111017
# ls -lah
total 811440
drwxr-xr-x  3 root  wheel     4B Oct 17 19:50 .
drwxr-xr-x  3 root  wheel     3B Oct 17 19:50 ..
dr-xr-xr-x  4 root  wheel     4B Oct 17 19:47 .zfs
-rw-r--r--  1 root  wheel   1.0G Oct 17 19:50 FreeBSD-8.2-RELEASE-amd64-memstick.img
-rw-r-----  1 root  wheel   263M Oct 17 19:43 maillog

Finally we can destroy the the snapshot.

zfs destroy DATA/dans_stuff@20111017

Well it all seems to work as advertised so far. I’ll get a more ‘industrial’ test online as and when, then we’ll see what it can do!

This entry was posted in FreeBSD Administration and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *