disko
disko copied to clipboard
Unmount mode
Originally posted by @Lassulus in https://github.com/nix-community/disko/issues/842#issuecomment-2457376112
What would be interesting (in the future in a new PR) would be a real unmount mode, where we don't destroy disks but just umount -Rl and deactivate the LVM/mdadm stuff for affected devices, something similiar to disk-deactivate but less destructive :)
I'm not opposed to this at all, but what would this generally be useful for?
It's useful if you want to flash a nixos installation to an external device and than remove the said device without reboot:
sudo disko-install --disk disk1 /dev/sda --mode mount --flake .#lenovo-t14-amd-debug
If you just remove the device as is, the zpool will still be around, if you forgot to remove it, you won't be able to use the zpool until reboot. Very annoying. Also had fun with swap: https://github.com/nix-community/disko/pull/890
so there are 2 ways unmounting can happen.
- a declarative way, where we have an unmount section in each type, which would run the defined script. We can only unmount disks/devices/fs which are created by disko that way. But building that is the easier solution
- a dynamic unmount, where we extract the currently mounted devices/fs/disks from the output of lsblk and other scripts. this would be similiar to what disk-deactivate does. This would be harder, but would be a more general solution :)
I am currently implementing the first option because for veritysetup we also need to inject stuff that would be hard to do in generic way.
we can also add hooks for unmounting, which people could define in their config and would be run before/after unmounting the specified type.