Can anybody explain why this is here?
|
if (stat.f_flag & ST_RDONLY) { |
|
if (mount(0, realStoreDir.get().c_str(), "none", MS_REMOUNT | MS_BIND, 0) == -1) |
|
throw SysError("remounting %1% writable", realStoreDir); |
I traced it back to b9124a5. It looks like the original codepath would check if /nix/store was a --bind mount and act only in that specific situation.
The comment says:
|
/* To improve purity, users may want to make the Nix store a read-only |
|
bind mount. So make the Nix store writable for this process. */ |
Note that this codepath gets hit not only for the /nix/store store, but also when you use nix copy --from /mnt/somewhere/nix/store. For example when recovering from a mangled system and trying to copy off whatever can be salvaged. Why would the --from store need to be remounted read-write for that to happen?
Some filesystems, in particular btrfs, will react to serious problems by switching the filesystem to readonly mode, and interpret any subsequent mount -o remount,rw as a "I know what I'm doing" signal by the root user. I don't think it's a good idea for nix-daemon to signal this unilaterally. Remounting read-write without doing an fsck first is usually a bad decision, and bad decisions should be left up to the humans :)
I think this behavior (remount read-write without an fsck) is one of the two reasons why Nixfolk have such strange (and strong!) opinions about btrfs. The other reason is explained in #7126 (comment). I'd hate to see the same thing happen with bcachefs.
Can anybody explain why this is here?
nix/src/libstore/local-store.cc
Lines 576 to 578 in 516e7dd
I traced it back to b9124a5. It looks like the original codepath would check if
/nix/storewas a--bindmount and act only in that specific situation.The comment says:
nix/src/libstore/local-store.cc
Lines 565 to 566 in 516e7dd
Note that this codepath gets hit not only for the
/nix/storestore, but also when you usenix copy --from /mnt/somewhere/nix/store. For example when recovering from a mangled system and trying to copy off whatever can be salvaged. Why would the--fromstore need to be remounted read-write for that to happen?Some filesystems, in particular btrfs, will react to serious problems by switching the filesystem to readonly mode, and interpret any subsequent
mount -o remount,rwas a "I know what I'm doing" signal by the root user. I don't think it's a good idea fornix-daemonto signal this unilaterally. Remounting read-write without doing an fsck first is usually a bad decision, and bad decisions should be left up to the humans :)I think this behavior (remount read-write without an fsck) is one of the two reasons why Nixfolk have such strange (and strong!) opinions about btrfs. The other reason is explained in #7126 (comment). I'd hate to see the same thing happen with bcachefs.