• Home
  • Assertions
  • Poetry
  • Programming

Record and Reverie

General things I find interesting

Feed on
Posts
Comments
« What Objective-C can learn from Java, Part 4 (Namespace)
The Case for Ripping Media »

FreeBSD with ZFS root

Oct 15th, 2011 by Graham Booker

It’s been a while since I posted here. I’ve been busy with a new job, new house, and a bunch of other things. One of these things was setting up my new file server. This is something that’s been in the works for a long time, as can be seen from the various posts on ZFS. I spent a long time researching this, and finally came up with my solution:

I did consider FreeNAS for a really long time. It is essentially a FreeBSD install with most of the administrative work done for you through a web-based GUI. It hit most of my checkboxes in that it supported ZFS, AFP, Bonjour, and a few others. While this is nice, I found it also to be limiting when one wants to stray off the beaten path. I didn’t want to lose ZFS, but I wanted something where I could tinker. I decided to go with FreeBSD.

One of the first things I tried with FreeBSD, as the topic indicates, is to put the root filesystem on ZFS. I followed an excellent tutorial to start, but decided to make a few modifications:

  • I wanted to put the root filesystem some place other than the root of the pool. Since my large media collection is going to be stored on the same pool, I wanted the ability to selectively snapshot the boot filesystem, and possibly revert it, without affecting the media partition. So, I put the root filesystem on on a sub filesystem of the pool.
  • The trend in disk storage is looking like it will go to 4K sector sizes in the future. ZFS cannot migrate a pool from 512 byte sector sizes to 4K sector sizes without a reformat/restore. I wanted a 4K sector size pool from the start.
  • I wanted to use ZFS swap instead of swap partitions.
  • I was going to spent several iterations getting things right and didn’t want to type on that blasted 12 year old keyboard the same commands over and over.

So, I accomplished this whole task through a series of scripts, that I would modify. If the script did something wrong, I’d destroy the pool and start over. The end result is a simple setup that I decided to share with the world:

  1. Download and burn/image one of the FreeBSD iso images or USB images. I used 8.2, the most recent at the time of this writing, and did the USB image since I had flash drives to spare but no DVD ROM drives.
  2. Boot the machine and enter the recovery mode (Fixit).
  3. Start the networking:
    mkdir /var/db
    dhclient em0
    ln -s /dist/usr/bin /usr/bin
    
  4. Transfer over the script directory:
    scp -r username@10.0.0.10:Desktop/FreeBSD/\* .

    In this case, 10.0.0.10 is my laptop with sshd running.

  5. Start sshd:
    ./FreeBSDSSHSetup.sh
  6. ssh into the machine from my laptop and execute:
    ./FreeBSDInstall.sh
  7. Reboot the server and enjoy.

The FreeBSD directory is available for those who would like to copy my efforts, though they will likely need some modification to suit your needs. The gptzfsboot, pmbr, and zfsloader files came from this site which are modified versions that work with 4K drives. The versions available in 8.2 do not work with 4K sector sizes, but future versions will. My install script

  • Partitions ad8, 10, 12, 14, 16, 18 to contain the boot loader and zpool information (6 SATA drives),
  • Loads kernel modules and sets up a gnop drive with 4K sectors,
  • Creates a raidz2 pool using the gnop drive as one of the drives forcing 4K sectors, exports the pool,
  • Destroys the gnop drive, re-import the pool, which had been forced to 4K sectors,
  • Sets up root filesystem on zroot/root (zroot is the root of the pool, root is the root filesystem, as discussed above), and
  • Performs a standard zroot install, except no swap partition.

I actually added the swap later, which is simply:

zfs create -V 2G zroot/swap
zfs set org.freebsd:swap=on zroot/swap
zfs set checksum=off zroot/swap

And that’s it. I have my 8TB raid running, with 2 drive redundancy, booting off the raid. Setting up AFP and the like requires more tinkering than with FreeNAS, but the instructions are easy to find and would be redundant to list here.

Tags: Servers, ZFS

Posted in General

One Response to “FreeBSD with ZFS root”

  1. on 18 Oct 2011 at 5:09 am1William Reading

    I’m tempted to set this up (as root, that is), but I think I’ll wait until FreeBSD 9.0 so that I can pick up Triple parity RAID-Z and data deduplication.

  • Recent Posts

    • Goodbye Roku, Hello GoogleTV
    • The Case for Ripping Media
    • FreeBSD with ZFS root
    • What Objective-C can learn from Java, Part 4 (Namespace)
  • Archives

    2021
    2020
    March 2020 (1)
    2019
    November 2019 (1)
    2018
    June 2018 (1)July 2018 (1)December 2018 (1)
    2017
    January 2017 (2)June 2017 (1)August 2017 (1)
    2016
    June 2016 (1)August 2016 (1)
    2015
    January 2015 (1)February 2015 (1)December 2015 (1)
    2014
    June 2014 (1)July 2014 (1)August 2014 (2)
    2013
    February 2013 (2)March 2013 (1)April 2013 (1)June 2013 (1)November 2013 (1)
    2012
    April 2012 (2)May 2012 (1)June 2012 (1)November 2012 (1)
    2011
    January 2011 (1)October 2011 (1)November 2011 (1)December 2011 (1)
    2010
    February 2010 (2)April 2010 (1)June 2010 (1)July 2010 (1)August 2010 (1)September 2010 (1)October 2010 (2)December 2010 (3)
    2009
    January 2009 (1)February 2009 (1)March 2009 (2)May 2009 (1)July 2009 (3)September 2009 (1)
    2008
    January 2008 (1)February 2008 (4)March 2008 (1)April 2008 (6)May 2008 (1)June 2008 (3)August 2008 (1)September 2008 (2)October 2008 (2)December 2008 (1)
    2007
    January 2007 (1)February 2007 (4)March 2007 (5)April 2007 (4)May 2007 (1)June 2007 (6)August 2007 (3)September 2007 (3)November 2007 (3)December 2007 (4)
    2006
    January 2006 (4)February 2006 (10)March 2006 (4)April 2006 (6)May 2006 (2)June 2006 (4)July 2006 (1)August 2006 (1)September 2006 (4)October 2006 (6)November 2006 (3)December 2006 (3)
    2005
    October 2005 (6)November 2005 (13)December 2005 (1)
    2004
    February 2004 (2)March 2004 (1)April 2004 (1)May 2004 (6)June 2004 (6)July 2004 (3)August 2004 (2)September 2004 (1)November 2004 (5)
    2003
    September 2003 (1)October 2003 (3)November 2003 (1)December 2003 (1)
  • Categories

    • Breakaway (5)
    • Family (4)
    • Friends (2)
    • General (148)
    • Nature Pictures (8)
    • Politics (2)
    • Programming (41)
    • School (11)
    • SysAdmin (8)
    • Teaching (2)
  • Tags

    AC3 Ads Code Frontrow Java Objective-C Open Source Perian Perl permissions plex plugin RSS Sapphire School Servers ZFS

  • Pages

    • Assertions
      • Female Friends Who Won’t Date You
      • Not Dating Friends
    • Poetry
      • Curtis Staying Over
      • Girl Questions
      • Scaring Girls Off
      • Summer’s End
    • Programming
      • Fire Development
      • Kyocera Ringtone Converter for the Mac
      • Perian
      • Text Compression

Record and Reverie © 2021 All Rights Reserved.

WordPress Themes | Web Hosting Bluebook