Score:0

Automatically mount and unlock ZFS dataset on external USB drive connection

cn flag

As the title says, I'm trying to mimic the behavior of a LUKS encrypted drive with ZFS.

An external USB drive with LUKS can automatically mount when connected. Ubuntu will show a dialog for the password. It provides an option to cache the password in your keyring, protected by your login password. Next time you plug in the external USB drive, it will automatically mount with the cached password

I would like to mimic that behavior with a ZFS dataset on a USB SATA drive dock, so that it automatically unlocks and mounts when plugged in.

How can I most closely achieve this?


P.S. - I know using a single external drive is not the main raison d'être for ZFS, but the copies=N setting was designed for single disk redundancy. While this is moderately useful for recovering from minor corruption (i.e. bit rot), it obviously does not protect against device failure.

Still, with ZFS copies=3, it proves useful for utilizing disks (e.g. healthy but old ones that were replaced as a precaution) as economic offline backups.

Score:1
cn flag

I am not sure that ZFS is accurate to be involved in a data transfer process using removable drives. Send and receive is the native way to shares data between ZFS pools.

You said «with a ZFS dataset on an external USB drive», if the point is really about filesytem datasets, this will not be possible.

That said, to reach your goal, you could probably build a script on the host doing those steps:

  1. watching USB plug-in events
  2. run a zpool import to ensure a pool is available
  3. reading local configuration
  4. asking questions to user (password, option, mountpoint, …)
  5. importing the pool with a command built with all the informations
cn flag
I'm hoping someone with better scripting skills preceded me in this endeavor, perhaps even with a tool or project. Surely I'm not the first one to recognize ZFS `copies=N` as a valuable protection against bit rot on single-disk offline backups. As for your initial concern, which is valid and probably shared by a majority of readers, I have addressed that by editing my initial question. I have also re-worded parts to make a bit more sense.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.