I am dual booting NixOS in the same zfs pool with FreeBSD.
What would be the best way to export the root pool during shutdown automatically?
What would be the best way to export the root pool during shutdown automatically?
You could write an rc script and give it the shutdown keyword. I don't know if that's the best way, but it's what I would try.
Can you elaborate what you mean?Be careful about exporting a pool, then trying to reimport it later if you've imported it on a different system.
I am already exporting the external zfs drives with it, but not with a script, only with a line of "zpool export <pool>" in rc.shutdown. But as cracauer@ mentions it does not work for system pool.You could write an rc script and give it the shutdown keyword. I don't know if that's the best way, but it's what I would try.
Sure. In theory "export" a ZFS pool is like a "super scrub". The intent is to make sure everything that is actually on the disk is consistent. ZFS is endianess agnostic which is why if you export from system A that is big endian you can import on system B that is little endian.Can you elaborate what you mean?
I am experimenting with dual boot FreeBSD x Linux to share disk space and being able to use snapshots mainly. On Linux it is force importing the zroot pool, on FreeBSD it just imports without complaining, probably force imports too.Sure. In theory "export" a ZFS pool is like a "super scrub". The intent is to make sure everything that is actually on the disk is consistent. ZFS is endianess agnostic which is why if you export from system A that is big endian you can import on system B that is little endian.
My "be careful" is mostly "if you export from system A, then import on system B make sure you export on system B before you import on system A".
You may get away with it 99% of the time, but that 1% it's going to be super critical data that is lost or messed up.
system pool/zroot stays mounted until almost the end so I think would be almost impossible.
The typical reason for export is to import on another system. To me this makes sense for say a zpool that represents user home or data, not your root pool. If your intent is to import a root pool into a new system at an altroot so you can compare, there may be other ways to accomplish that.
I am experimenting with dual boot FreeBSD x Linux to share disk space and being able to use snapshots mainly. On Linux it is force importing the zroot pool, on FreeBSD it just imports without complaining, probably force imports too.
It is a single disk M.2 ssd disk pool. So you think even though the same pool will not be used at the same time with 2 systems, it might cause problems? It doesn't share any datasets.
My setup is in the previous message. What would be the consequences of import -f every time? if any? I will not be upgrading the pool to linux one as linux has a higher version, upgrade only on FreeBSD.So is your FreeBSD root inside that pool?
It sounds like a situation where I would just use `import -f`` every time. You need that for unclean shutdowns anyway.
Maybe I'm overlooking something as I don't have dual boot experience, but I presume that you only need to share (ZFS based) data between OSs. *If* you assign that shared data pool to a separate data pool, couldn't you write a simple script that first exports the pool, then use zfs-unmount(8) for that pool (and verify that that has been successful) and finally issue a shutdown? I realise that in that case you'd have to "abandon" the usual shutdown command.I am dual booting NixOS in the same zfs pool with FreeBSD.
What would be the best way to export the root pool during shutdown automatically?
I'm not a fan of using -forced options, especially when needed to be used on a regular basis as a casual method. For example, zpool-import(8):My setup is in the previous message. What would be the consequences of import -f every time? if any?
-f Forces import, even if the pool appears to be potentially
active.
You are running ZFS without any redundancy; ZFS 101—Understanding ZFS storage and performance :[...] It is a single disk M.2 ssd disk pool.
There may be situations where one is practically forced to use ZFS without any redundancy (i.e., without using a mirror or a RaidZx setup) such as a laptop setup where only one disk drive can be installed. For any other set up I'd never choose to use ZFS without redundancy. Without redundancy, any data integrity error cannot be rectified by ZFS and losing the pool means you'll have lost all your data.Single-device vdevs are also just what they sound like—and they're inherently dangerous. A single-device vdev cannot survive any failure—and if it's being used as a storage or SPECIAL vdev, its failure will take the entire zpool down with it. Be very, very careful here.
zpool export mypool &
sleep 10 ; zpool export -f mypool &