Getting started with ZFS

When ZFS first came out, it was a proprietary filesystem but it had some very interesting characteristics – at the time it’s ability to scale massively and protect your data seemed very cool. My interest in filesystems goes back to my C64 days editing floppy disks to create infinite directory listings and the like.  Talking about filesystems reminds me of when I was a COOP student at QNX, they had ‘QFS’ and meeting the developer helped de-mystify filesystems for me.

For some reason ZFS is also linked in my memory with the ‘shouting in the datacenter’ video. As best I can tell this is likely because both DTrace and ZFS both came out of Sun around the same time.

I finally decided to fully decommission my old server and the RAID5 array of 1TB drives. I’ve also recently been experimenting with NixOS, and I’ve really enjoyed that so far. I figured why not setup a dedicated backup server? This also presented a good chance to setup and play with ZFS which now has reliable open source versions available.

First I spent some time learning what I would consider ZFS basics. This video was useful for me. Also, these two blog posts were good starting points.

Since I’m using NixOS as my base operating system, I’ll be following the doc on setting up ZFS on NixOS. Now, while I’m not setting up my boot volume to be ZFS – it turns out you still need to do the same basic setup if you want ZFS capabilities in your NixOS.

You need to generate a unique ‘hostid’ – the doc suggests using

Now we need to modify the /etc/nixos/configuration.nix to include

Rebuild and reboot, then you can query available zpools

Now we create a pool, I think in this step we are actually adding a bunch of devices to a vdev, which is then wrapped in a pool. Using fdisk I’m able to identify the four 1TB drives which are all partitioned and ready to roll: sdd, sde, sdf, and sdg.

This process took a short while to complete, but after it was done running sudo fdisk -l /dev/sdd gave me this:

It seems new partitions were created and I now have a zpool

I don’t believe you can reasonably expand or shrink a RAIDZ vdev, this means you need to plan ahead for your storage needs. Also important to remember that the guidance is to not have ZFS volumes at more than 80% usage, beyond this level performance starts to suffer. Storage is cheap, and with pools I think you can have multiple vdev’s in a single pool, so while a single RAIDZ vdev has limitations I think ZFS offers some interesting flexibility.

Unexpectedly, it seems that the newly created ZFS is also mounted and ready to roll

That’s not where I want to mount the volume, so let’s go figure out how to move it.

Cool. I’ve got a ZFS filesytem. One snag, it isn’t mounted automatically after a reboot. I can manually mount it:

And digging into the NixOS doc, we find the configuration we need to add

This fixed me up, and ZFS is auto mounted on reboots.

One last configuration tweak, let’s enable scrubbing of the ZFS pool in our NixOS configuration

Setting up ZFS on NixOS is very easy. Why would you want ZFS over another filesystem or storage management system? I’ve been using snapraid.it for a while on my main server, and I like the data integrity that it brings beyond just a RAID5 setup. The snapraid site has an interesting comparison matrix. I will say that setting up ZFS RAIDZ was a lot less scary than any of my adventures using mdadm to setup a software RAID5.

What do I see as the key strengths of ZFS?

  • Data integrity verification and automatic repair – all files are check-summed, and with RAIDZ redundancy we can recovery from underlying data corruption.
  • Pooled Storage – something I need to explore more, but I think this will give me flexibility over adding more storage over time if needed.
  • Copy-on-write – this is about consistency of the filesystem, especially over power failure events.

Remember I started out with some old hardware I was repurposing? Those 1TB drives were all surprisingly in ‘good’ shape, but between 10 and 13 years of power on time (some of them have manufacture data of 2009). In my next blog post we’ll cover how ZFS handles failures as we see these ancient drives start to fail.

Comparing images to detect duplicates

I’ve been using Photoprism to manage my large and growing photo library. We had simply outgrown using a single machine to manage the library, and Apple had burned us a couple of times by changing their native photo management system. I’m also not the type to trust someone else to keep and secure my photos, so I’m going to host it myself.

I have backups of those photo libraries which I’m working from, and unfortunately those backups seem to have replication of the photos. No problem right? Photoprism has the ability to detect duplicates and reject them. Sweet. However, it does rely on the photos being exactly the same binary.

My problems start when I have a bunch of smaller photos, which look ok – but are clearly not the original. In this particular case the original is 2000×2000, and the alternate version is 256×256 (see top of post for an example of two images). Great – just delete the small one, but with 1000’s of photos how do I know that one is a duplicate of another but resized?

There are other flags here too, the smaller resized version is missing a proper EXIF date stamp. So sure, I can just sort out the photos based on ones with valid EXIF data and then I have a bunch of others which don’t have data. But, what if one of those photos isn’t a resized version? Maybe it’s a photo of something that I only have a small version of?

Again, with 1000’s of photos to review, I’m not going to be able to reasonably figure out which ones are keepers or not. Good thing that doing dumb stuff is what computers are good at. However, looking at two images and determining if they are the same thing is not as easy as you might think.

The folks at imagemagick have some good ideas on comparing for differences, they even tackle the same issue of identifying duplicates but still end up relying on you creating your own solution based on some advice.

Since I had this problem, I did cook up some scripting and an approach which I’ll share here. It’s messy, and I still rely on a human to decide – but for the most part I get a computer to do some brute force work to make the problem human sized.

Continue reading “Comparing images to detect duplicates”

Google Pixel 7

The Pixel 4a was a fantastic phone for me. I bought it new from Google back in the fall of 2020 when it was a current model. The end of support date snuck up on me, had it already been 3 years? I noticed in October I hadn’t had a reboot (and thus a security patch) in quite some time. The 4a had a surprise extra update in November – but this was clearly the end of the line.

The 4a was a change for me, for the most part I’d bought gently used phones at around the $200 price point that were 2-3 years old, and then used them for a year and a bit. This gave me a new toy regularly, and was fairly cost effective. Still, I was probably spending about $500 over 3 years easily -this helped me justify the purchase of a new 4a. Little did I know how much I’d enjoy having the 4a and not doing the upgrade dance regularly.

In the first weeks of 2024, my Pixel 4a was still performing well. I’d generally only need to charge it every second day. Yes, over time the battery had gotten a little worse – but not by much. The camera continued to be amazing. And wrapped in a bumper case and screen protector the phone itself was in mint condition. If it was still getting regular security patches from Google I’d have no problem continuing to use it.

Of course, LineageOS is an option. Migrating to this would give me a community supported version of Android 13. A few worries kept from from this path. I use my phone for work, and have the mobile device management stuff installed, I wasn’t convinced this would work smoothly with LineageOS.. but it has in the past (honestly I think I was looking for reasons to upgrade). The migration of apps also seemed daunting. While most things have a ‘cloud’ story and are linked to various accounts etc, some of the games I have don’t have a backup/restore story. The other pain is the lack of SafetyNet support, practically this means only Netflix won’t work for me (again, I’m looking for an excuse).

Honestly, looking back, if I’d gone through the migration effort and moved to LineageOS it would have all worked out. I would have had my security updates but been stuck back on Android 13. The work device policy is good with support for devices back to Android 12 currently. There is also a good chance the WorkProfile is still properly supported in LineageOS (it was in the past). I would have lost state in a few games, but that is minor.

Post Black Friday and leading into Christmas and Boxing week there were some crazy sales on mobile plans in Canada. CostCo was apparently offering a plan that was very low and provided a Pixel 7 on a 2 year contract for $1/mo. This has the result of many BNIB phones showing up on the local used market.

The Pixel 7 still lists for $799 directly from Google. Many of the used market phones where listing between $350-$500 still with the security seal in place. Relative to Google the local pricing is lower for a BNIB or refurbished options from retail stores.

I found someone listing one for $300, and it check out as legit. He’d done a plan upgrade/renew back in October gotten a new Pixel 7 but already had one, so he had this sealed BNIB one to sell. I suspect he’d started at a much higher price, but the recent glut of new phones on the used market pushed his price down. There were other similar phones for $330 to be had. This price point made getting a phone upgrade a smart move for me as it still has 3+ years of support from Google.

There are plenty of phone comparison sites, but let me run down things that I see as trade offs.

  • I’ll probably miss the back fingerprint sensor, the in screen optical one is “ok” but not nearly as reliable.
  • The 4a has a 3.5mm headphone jack, this is a useful way to interrupt bluetooth connectivity nonsense with my car/ bluetooth headphones. I can use a USB-C adapter, but it’s not the same.
  • The Pixel 7 is bigger, there are pros and cons to a larger phone.
  • As stated above, the Pixel 7 is still currently supported. This is a big win.
  • The camera is better in the Pixel 7, but the 4a certainly held it’s own. Very minor difference.

The Pixel 7 is a very pretty phone, I’m not a fan of the all glass back, but it is very sexy. Of course, the first thing is to buy a case and screen protector before I even take it out of the box. I grabbed a case very similar to the one I’ve had on my 4a from Amazon. I headed to eBay to get a screen protector from a seller I’ve used previously. This meant a few day wait, but that wasn’t a big deal.

All good – now it’s wrapped and ready to roll. The bumper case has these nice extended corners which add protection, but also give you something to grip onto. There is a subtle roughness on the sides too, making the phone less slick. The screen protector doesn’t have any cut-outs for the camera, this is similar to the one I had on my 4a and it had no negative impact for my use.

The phones are significantly different in size, with the Pixel 4a on the left and the Pixel 7 on the right. I’ll point at a comparison article if you want to look at the specifications side by side. I was interested in the in pocket weight, including the case. The 4a is 175g vs the 7 at 231g – yikes, 32% heavier. This is enough that you notice the difference, but I’ve gotten use to the added heft and size.

Continue reading “Google Pixel 7”