disko icon indicating copy to clipboard operation
disko copied to clipboard

Unmount mode

Open iFreilicht opened this issue 1 year ago • 4 comments

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?

iFreilicht avatar Nov 06 '24 20:11 iFreilicht

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

Mic92 avatar Nov 21 '24 15:11 Mic92

so there are 2 ways unmounting can happen.

  1. 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
  2. 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 :)

Lassulus avatar Nov 21 '24 17:11 Lassulus

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.

Mic92 avatar Nov 21 '24 17:11 Mic92

we can also add hooks for unmounting, which people could define in their config and would be run before/after unmounting the specified type.

Lassulus avatar Nov 21 '24 17:11 Lassulus