ZFS on an external USB drive
I’m liking ZFS so much I decided to use it on my new media storage drive. A 14TB external USB drive with video and music files. The serious nerds who use ZFS will tell you that USB is unsuitable and there’s no point in using ZFS without reundancy. Phooey!
It works quite well. You plug the disk in, create a pool on it (with just the one disk), and you’re done. It automounts for you. You can create datasets to segregate data and they automount. (Be aware you can’t efficiently move files between datasets, that ends up being a byte by byte copy.) And as a bonus you get ZFS features like checksums, deduplication, snapshots, etc. It’s nice!
What happens if you unplug the disk? If you unplug while the disk is mounted (“imported”) it’s a total mess. Don’t do that. This is the problem with USB, it can be a bit flaky and act like it unplugs itself, but I think that’s mostly a problem of the bad old days. So far so good!
If the disk is unplugged and the system is rebooted, the directories won’t exist at all. This is different from ext4 or other fstab filesystems. For instance, say /jukebox is my USB disk. With ext4fs I have to do a mkdir /jukebox before mounting, so there’s a /jukebox present on the root filesystem. The mount replaces the directory. If the disk doesn’t mount you still have that /jukebox visible and other stuff might try to use it. Instead if you have a ZFS pool named “jukebox” it just automounts to /jukebox even if that name doesn’t exist at all in the root filesystem. And if it doesn’t mount, that means there’s no /jukebox at all. In my case I’m using these USB disks as bindmounts for LXC containers. Proxmox notices the directory doesn’t exist and refuses to even start the container. I like that failure mode.
Mostly the disk is plugged in though and ZFS seems to work pretty well with it.
(Elsewhere I have a deployed system with ZFS mirroring deployed on two USB disks in the same enclosure. This also seems to work reliably, after one USB hiccup scared me right at the start.)