On Fri, Jan 15, 2021 at 09:15:02PM +0100, John Paul Adrian Glaubitz wrote: > Hello Jonny! > > On 1/15/21 9:06 PM, Jonny Grant wrote: > > Apologies I am not using 2.36.1 yet. I'm on latest Ubuntu LTS, but it's using 2.34 > > > > I noticed fsck only works if I write as "/dev/sdb1" not just "sdb1" I was in /dev/ as > > root, so it shouldn't need long path? > > > > These work as expected when called from /dev/ as user root > > > > # fsck.ext4 sdb1 > > # fsck.ext4 /dev/sdb1 > > > > This does not work: > > # fsck sdb1 > > That's because it must be: > > # fsck.ext4 ./sdb1 > > Filenames are expanded by your shell in this case, not by the fsck utilities. That's not what is going on --- and it has nothign to do with PATH searching. The way fsck parses its arguments is that it has to distinguish between: * device names ("/dev/sdb1") * label or UUID specifiers (e.g., "LABEL=backup") * options to be interpreted by fsck (e.g., "-N") * options to be interpreted by the fsck.XXX driver (e.g., "-f") * arguments to fsck.XXX's options (e.g.,"discard" in "-E discard") The generic fsck driver doesn't know that for fsck.ext4 (aka e2fsck) that -E takes an argument. So when you run something like "fsck -E discard /dev/sdb1", fsck can't distinguish between the file "discard" in your current working directory, and passing in multiple devices which are designed to be running in parallel, e.g.: "fsck -p /dev/sda3 /dev/sdb1". The bottom line is if you want to pass a pathname to a device, it must not be a relative pathname. It also means that if you need to pass in an argument to a pathname, e.g.: /sbin/e2fsck -j /dev/VG/ext-journal /dev/VG/filesystem you can't just do something like: /sbin/fsck -j /dev/VG/ext-journal /dev/VG/filesystem since /dev/VG/ext-journal won't be interpreted as an argument to the -j option. You could do something like: /sbin/fsck /dev/VG/filesystem -- -j /dev/VG/ext-journal But honestly, you're probably better just explicitly specifying the file system driver specifier (e.g., /sbin/fsck.ext4 or /sbin/e2fsck) instead of using the fsck front-end. The original use of fsck was so we could run multiple fsck processes in parallel. With distributions which use systemd, the only real value which fsck adds is that it will automatically figure out the file system type. But if you're manually running fsck, most of the time you know the file system type --- and if you are using filesystem type specific option, you really do know the file system type ahead of time, so you might as well skip using the fsck front-end. Cheers, - Ted