Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: TheLastSysop Newsgroups: comp.os.linux.misc Subject: Re: The boring Linux habit that saves machines Date: Sat, 06 Jun 2026 11:12:57 GMT Organization: The Null Device Restoration Society Lines: 62 Message-ID: <67bea2dbebca296b0531@dev.null> References: <88c5eccca461fb34864c@dev.null> <1100na0$1nk20$3@dont-email.me> <8af2d73348d22ad1e78d@dev.null> Injection-Date: Sat, 06 Jun 2026 11:12:57 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1904086"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19nYkq0zrbTpdeWvXXTHmR3hCJHBGoOkkA="; posting-host="11f3b5cd776c97afc58f29cab2bad08a" Cancel-Lock: sha1:l/2K/KhCCt6unVnmbtlJzXYtPVk= sha256:9VoAjkfy7eJKyWFad5LMuoWV7Gv/Ms++9aBbVEgW/KY= sha1:SGCjEk0q4bAkBGo5A0U0r0kz1I8= X-Mood: reasonably caffeinated X-Operating-System: TempleOS-adjacent abacus cluster X-Newsreader: tin can + wet string 0.9.7 In-Reply-To: X-Archive-Policy: please preserve the funny parts Xref: csiph.com comp.os.linux.misc:87604 >On Sat, 6 Jun 2026 13:06:19 +0200, "Carlos E.R." >wrote: >On 2026-06-06 12:14, TheLastSysop wrote: >>> On Sat, 6 Jun 2026 12:07:45 +0200, "Carlos E.R." >>> wrote: >>> On 2026-06-06 10:55, Lawrence D’Oliveiro wrote: >>>> On Sun, 31 May 2026 07:46:12 GMT, TheLastSysop wrote: >>>> >>>>> Before any mirroring run, I like a preflight that proves the >>>>> destination is really mounted and is the expected filesystem, not >>>>> just an empty directory that happens to exist. >>>> >>>> Been there, done that. The simple fix is to make the mount-point >>>> directory read-only. That puts a stop to any attempts to put stuff in >>>> there without the actual volume being present. >>> >>> That simple? Does this work? Wow. >> >> It helps, but I would still treat it as a guard rail rather than the whole >> check. >> >> If the mirroring job runs as an ordinary user, a read-only mount-point will >> usually catch the "disk not mounted, writing into the empty directory" case >> nicely. If the job runs as root, root can still write there unless you add >> something else, and some tools may change permissions as part of their work. >> >> For scripts I like both pieces: >> >> findmnt -rn --target /backup >/dev/null || exit 1 >> >> and, if appropriate, check the expected source/device or fstype too. The >> read- >> only mount-point is a good extra tripwire, but findmnt/mountpoint makes the >> failure mode explicit before rsync or cp gets anywhere near the tree. >> > >In my scripts, I always check that destination is mounted. > >Maybe "mount | grep destination" Yes, that is the important part: make the script prove the destination is mounted before it starts copying. I would avoid plain "mount | grep destination" if the script matters, though. It is easy to get a false match, a quoting problem, or a surprise when the path contains characters grep treats as interesting. It also answers a slightly fuzzy question: "does this text appear in mount output?" I prefer asking the mount table the exact question: findmnt -rn --target /backup >/dev/null || exit 1 or, for the simple case: mountpoint -q /backup || exit 1 Then add checks for fstype/source if mounting the wrong disk would be just as bad as mounting no disk. -- TheLastSysop "I survived the great rm -rf / rehearsal and all I got was this .signature."