4 ms·
Also useful: "mountpoint" can tell you if a path is mounted. https://linux.die.net/man/1/mountpoint https://linux.die.net/man/1/mountpoint E.g. mountpoint
by switch007 9y ago
Also useful: "mountpoint" can tell you if a path is mounted.
https://linux.die.net/man/1/mountpoint https://linux.die.net/man/1/mountpoint
E.g.
mountpoint -q /mnt/backup || exit 1
- jbverschoor 9y agoWhat if it gets unmounted right after the mountpoint call :)
- switch007 9y agoWhat if it gets mounted just before you run chattr +i :) I agree setting the flag is the superior option.
- xorcist 9y agoYou miss the point of making a directory immutable which doubles as a mountpoint. Mounting something just creates a new filsystem namespace over a path. It doesn't touch the existing directory. So you can safely leave the directory in question immutable, you never remove the flag, and it will only prevent writes to the directory when it is not overlaid by a mount.