util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonny Grant <jg@jguk.org>
To: Theodore Ts'o <tytso@mit.edu>,
	John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: util-linux@vger.kernel.org
Subject: Re: fsck needs /dev in path to check an ext4 partition
Date: Fri, 15 Jan 2021 22:56:03 +0000	[thread overview]
Message-ID: <772c9034-01c7-fae5-2420-07526f5fabbe@jguk.org> (raw)
In-Reply-To: <YAIQXILhhLfRupPY@mit.edu>



On 15/01/2021 21:59, Theodore Ts'o wrote:
> 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.


Thank you for the reply Ted.

I'll stick to using fsck.ext4 directly I think, and the /dev/sdb1 to keep it simple.

Cheers, Jonny

      parent reply	other threads:[~2021-01-15 22:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-15 20:06 fsck needs /dev in path to check an ext4 partition Jonny Grant
2021-01-15 20:15 ` John Paul Adrian Glaubitz
2021-01-15 21:35   ` Jonny Grant
2021-01-15 21:59   ` Theodore Ts'o
2021-01-15 22:10     ` John Paul Adrian Glaubitz
2021-01-15 22:56     ` Jonny Grant [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=772c9034-01c7-fae5-2420-07526f5fabbe@jguk.org \
    --to=jg@jguk.org \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=tytso@mit.edu \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).