ZFS Cheatsheet

Create a RAID 1 style file system across two devices:

zpool create tank mirror /dev/sdb /dev/sdc

Create a RAIDZ2 file system with all the features:

zpool create -f tank -o ashift=12 raidz2 /dev/sda /dev/sdb /dev/sdc /dev/sdd
zfs set compression=lz4 tank
zfs set xattr=sa tank
zfs set acltype=posixacl tank
zpool set autoexpand=on tank

Add another pair of mirrored drives to create an array similar to RAID 10:

zpool add tank mirror /dev/sdd /dev/sde

Display information about the file system:

zpool status
zpool list
zpool list -v
zfs list
zfs list -t all
zfs get all

Disable a drive:

zpool offline tank /dev/sdj

Replace an active drive:

zpool replace -f tank /dev/sds /dev/sdt

Scrub an array:

zpool scrub tank

Enable autoexpand for a zpool (allows growing arrays by replacing drives with larger models):

zpool set autoexpand=on tank

Enable file system compression:

zfs set compression=lz4 tank

Create a new file system:

zfs create tank/partition1

Remove a drive, even if resilvering

zpool detach tank sdc

Clear ZFS info from a drive

zpool labelclear /dev/sdt

Remove a drive from a mirror of sdc+sdd, then attach a new drive sde

zpool detach tank sdc
zpool attach -f tank sdd sde

Remove a drive (sdx) from a RAID-Z2, then attach a new drive (sdy)

zpool offline tank sdx
zpool replace tank sdx sdy

Flashing an LSI 9211-8i IR card with IT Firmware

I purchased a brand new, sealed LSI 9211-8i card from a vendor on eBay at a much better price than at my normal (ie Newegg, Amazon) places. Unfortunately, when I went to flash it from IR to IT firmware I kept receiving a “Failed to Validate Mfg Page 2” error.

Lots of Googling later, I finally found a method that worked to revive the card. Since my process was slightly different from the dozens of methods I found, I’m going to add another revision to the internet (and for my future reference).

The card was probably an OEM design, misleadingly sold as a retail LSI card, but I decided to keep it because I was able to get it working reliably.

Here’s my firmware update process:

  1. create a bootable USB flash drive using Rufus
  2. copy the following items to the bootable flash drive
    1. Megarec DOS utility and Dell SBR file from http://lime-technology.com/forum/index.php?topic=12767.615 (Toolset_PercH310 to LSIMegaraid.zip)
    2. DELL 6gbtsas firmware and DOS flash utility from https://forums.servethehome.com/index.php?threads/fujitsu-d2607-sas2008-it-mode.2513/ (Firmware Package Version:
    3. LSI 9211-8i P7 firmware and DOS flash utilty from LSI website (navigate to downloads for 9211-8i, choose archived)
    4. LSI 9211-8i P19 firmware and DOS flash utility from LSI website (navigate to downloads for 9211-8i, choose current)
  3. Follow the instructions at https://forums.servethehome.com/index.php?threads/fujitsu-d2607-sas2008-it-mode.2513/ with the following changes:
    1. get the SAS address
      1. megaoem -AdpAllInfo -aAll -page 20
    2. flash a dell sbr file with megarec
      1. megarec -writesbr 0 sbrempty.bin
    3. clear the flash with megarec
      1. megerec -cleanflash 0
    4. hard reboot
    5. flash the Dell firmware using the Dell utility
    6. hard reboot
    7. flash using the P7 dos utility and firmware
    8. flash using the p19 DOS utility, firmware, and bios
    9. hard reboot
    10. set the SAS address
    11. verify with sas2flsh -list

To perform this process I _had_ to use a DOS bootable USB flash drive because of the P7 DOS utility. It appears that the P7 UEFI utility is either missing or never existed on the internet. Also the DOS megarec utility was a requirement, the process didn’t work without the erase and sbr commands. Another requirement was a motherboard which was compatible with both the sas2flsh.exe DOS utility and the 9211-8i card. After PAL errors on four motherboards (3 intel, one AMD), I found an AMD motherboard which worked, the ASUS M2N-MX.

The entire process was time consuming and a frustrating experience. Here’s hoping LSI releases a simple, raidless, affordable 8+ port SATA card in the future.

Update (2016-04-17)

I successfully flashed a Dell H310 using the instructions and files at https://techmattr.wordpress.com/2016/04/11/updated-sas-hba-crossflashing-or-flashing-to-it-mode-dell-perc-h200-and-h310/ using a UEFI firmware desktop.



Change the Clock Color in XBMC

The white font color used by XBMC’s Confluence theme was causing image retention on my plasma tv (even with a 1 minute black screen screensaver). To fight this I changed the color to a dark grey.

I’m using OpenELEC, adjust the paths as necessary.

  1. Make a copy of the theme, so system updates don’t clobber the changes
    • cp -a /usr/share/xbmc/addons/skin.confluence addons/skin.confluence.gotham.edit/
  2. Edit 720p/includes.xml, under <include name=”Clock”>, change <textcolor> from white to grey3
  3. Change the skin name from Confluence to something else in addon.xml

Wipe a Hard Drive

zero a drive with progress (change 1T to whatever drive size your zeroing):
# dd if=/dev/zero bs=1M | pv -s 1T | dd bs=1M of=/dev/sde

Erase the drive then read back the blocks to check for errors:
# badblocks -svw -t 0x00 /dev/sde

BTRFS Cheatsheet

Create a RAID 1 style file system across two devices:

mkfs.btrfs -d raid1 -m raid1 /dev/sdl /dev/sdn

Display information about the filesystem

btrfs fi show /mnt/btrfs
btrfs fi df /mnt/btrfs

Check the data while online:

btrfs scrub start /mnt/btrfs
btrfs scrub status /mnt/btrfs

Add a drive

btrfs device add /dev/sda /mnt/btrfs
btrfs balance start -d -m /mnt/btrfs

Remove a drive

btrfs device delete /dev/sdl /mnt/btrfs

Replace a drive

btrfs replace start /dev/sda /dev/sdl /mnt/btrfs

Convert to RAID 1 (both data and metadata)

btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt/btrfs
btrfs balance status /mnt/btrfs

Raspberry Pi as a Car AirPlay Receiver

This can also be done with an Airport Express and a DC inverter. Using a RaspberryPi is slightly less expensive and more fun to setup.


Parts List:

  • $25/$35 – RaspberryPi (model A or B)
  • $8 – case
  • $9 – car usb power adapter
  • $3 – usb cable
  • $12 – usb wifi adapter (148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter)
  • $6 – 8 GB SD memory card
  • $1 – 3.5″ audio cable

Total: $64/$74 (depending on rPI model)


There are a lot of high quality howto guides around the net, but I haven’t found one that combines all the necessary steps. These steps are:

  1. Install Raspbian
  2. Setup Shairport
  3. Setup Wi-Fi in AP mode
  4. Configure Raspbian to boot into read-only mode
  5. Configure iPhone/iPad

1. Install Raspbian to the SD Card

2. Install shairport and configure audio:

3. Setup Wi-Fi Adapter in AP mode


4. Configure Raspbian to boot into read-only mode

5. Connect to the rPI network

  • Select the Wi-Fi network on your iPhone. It’ll connect to the network, but without DNS and Gateway settings you’ll still be able to use your cellular connection for data, so iTunes Match, Pandora, etc will still work.


At this point it works great during home testing. I can stream audio from the internet on my phone and have it play on the 3.5mm audio jack on the Raspberry Pi without stuttering or buffering. However, car testing has not worked well. I get frequent drops, which I’m attributing to Wi-Fi interference. I’m thinking a 5GHz Wi-Fi connecting will fix this problem, but I’ve yet to find a mini adapter that will work.




Ubuntu 12.04 LTS on an Apple Mac Mini (Late 2012)

I’m switching my web hosting to a Mac Mini running Ubuntu Linux. These are my notes for getting it set up.

Here’s the hardware specs:

  • Apple Mac Mini 6,2 (Late 2012)
  • Intel Core i7-3615QM 2.3 GHz quad-core processor
  • 16 GB DDR3-1600 memory
  • 128 GB solid state drive
  • 1 TB 5400 RPM hard drive

The Mac Mini is built to run OS X 10.8, but Ubuntu 12.04.1 runs nicely with a couple of tweaks.

  • Installing required the “noapic” flag (F6 when at the boot menu)
  • Set “Boot after power failure” by running the following, and adding it to /etc/rc.local:
    setpci -s 0:1f.0 0xa4.b=0
  • Fan control doesn’t work without applesmc and macfanctld installed from Ubuntu’s Mactel PPA
  • the network card doesn’t work out of the box, you need to download/compile a new version of the tg3 module from Broadcom

For networking, I didn’t want to have to remember to recompile the module after reinstalling each kernel. I setup DKMS to take care of it automatically.

  • Download the Linux “tg3” driver from Broadcom (version 3.124c (10/18/12) at the time of this writing)
  • Extract it
  • Navigate to Server/Linux/Driver/tg3-3.124c.tar.gz
  • Extract that file to /usr/src/tg3-3.124c/src/
  • Create a file called /usr/src/tg3-3.124c/dkms.conf with the following contents:
CLEAN="make -C src/ clean"
MAKE="cd src/ && make BUILD_KERNEL=${kernelver} KVER=${kernelver}"
  •  Add the module to DKMS so that it’s automatically built for new kernels:
sudo dkms add -m tg3 -v 3.124c
sudo dkms build -m tg3 -v 3.124c
sudo dkms install -m tg3 -v 3.124c
  • The module is now ready, either load it with “modprobe tg3” or reboot
  • If you need to remove it at a later time, do:
sudo dkms remove -m tg3 -v 3.124c --all

After these changes the Mac Mini is working great. I didn’t test Wi-Fi, Thunderbolt, or Sound, since I won’t be using them. USB works as far as being able to connect a keyboard and mouse, and Ubuntu’s 12.04.1 LiveCD boots into the full desktop.


Ubuntu has released 12.04.2 install/live CDs based on kernel version 3.5. I have not tested the above instructions with kernel 3.5, so if you’re following them you probably want to stick with the 12.04.1 install ISOs with kernel 3.2. If you install from 12.04.1, you will automatically stay on 3.2 even when updating to 12.04.2.

Update 2 (2014-10-05):

Ubuntu 14.04 and 12.04 with the Trusty hardware enablement stack (installed by default from the 12.04.5 ISO) have the required tg3 driver and do not need the custom DKMS config above.


Web Hosting on a Mac Mini

The new Mac mini is out (Late-2012 model), and I’m going to give Macminicolo a try. I’m moving from the dedicated server I’ve been on for the last two years:

  • quad-core 2.83 GHz (Intel Q9550)
  • 8 GB DDR2-800
  • dual 500 GB 7200RPM SATA drives with a hardware mirror (RAID 1)
  • Ubuntu 10.04 LTS

to the faster Mac mini:

  • quad-core 2.3 GHz (Intel Core i7-3615QM)
  • 16 GB DDR3-1600
  • 128 GB SSD
  • 1 TB SATA
  • Ubuntu 12.04 LTS

I’m moving because it’s less expensive and faster. Due to having to buy the Mini, my break-even point is in 12 months, but after that I’m saving money.

Compared to Amazon EC2, after two years I will have paid roughly the same as a Medium instance (2 CPU, 4GB RAM) with the 1/year reservation discount. The Mac Mini is much faster, but then, Amazon offers a lot more (paid) services and options.

The downside is that there’s no redundancy built into the Mac mini, and I become responsible for hardware failures. There’s a year of warranty built into the Mini, but after that there’s a chance I’ll be buying a new one, and my predicted savings will be pushed back a year. In case of a hardware failure, I’ll temporarily move to Amazon EC2. Being instantly available is worth the extra cost in that case.




Too Many Computers

I’ve recently been able to retire three general computers (my netbook, HTPC, and work desktop). I’m now down to 4 general use computers, here they are, in order of usage:

  1. MacBook Pro (15″, Late 2008, work supplied)
  2. iPhone 4
  3. iPad (Third Gen)
  4. Desktop (icebox)

On the weekend, the order changes to:

  1. iPad (Third Gen)
  2. iPhone 4
  3. MacBook Pro (15″, Late 2008, work supplied)
  4. Desktop (icebox)



failed hard drives

Keeping track of my drive failures, since April 2011.

Purchased Failed Model
141 2009-11 2021-08 1 TB Hitachi Deskstar 7K1000.B HDD
47 2016-07 2020-06 4 TB Seagate 2.5″ Laptop HDD
37 2016-11 2020-01 4 TB Seagate Desktop HDD.15
119 2010-01 2019-12 2 TB Hitachi Deskstar 7K2000 7200RPM
60 (52818 POH) unknown 2018-07 1.5 TB Seagate Barracuda 7200.11 7200RPM
47 2012-11 2016-10 3 TB Seagate Barracuda 7200.14 7200RPM
18 2014-12 2016-06 4 TB HGST Deskstar NAS 0S03664 7200RPM
68 2010-06 2016-02 2 TB Western Digital Caviar Green WD20EARS 5400RPM
66 2010-08 2016-02 2 TB Western Digital Caviar Green WD20EARS 5400RPM
66 2010-05 2015-11 2 TB Samsung Spinpoint F3EG HD203WI 5400RPM
56 2010-11 2015-07 2 TB Samsung Spinpoint F4 HD204UI 5400RPM
41 2010-06 2013-11 2 TB Western Digital Caviar Green WD20EARS 5400RPM
42 2008-11 2012-05 1.5 TB Seagate Barracuda 7200.11 7200RPM
66 2006-08 2012-02 400 GB Western Digital Caviar SE16 7200RPM
18 2010-04 2011-10 1.5 TB Western Digital Green 64MB Cache 5400RPM
15 2010-04 2011-07 1.5 TB Western Digital Green 64MB Cache 5400RPM
26 2009-02 2011-04 1 TB Hitachi Deskstar 7K1000.B 16MB Cache 7200RPM