A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

August 13, 2018

18.7.b Checking and fixing Filesystems II

I was checking into following statement, which did not make sense and I was wondering if it was meant to be "sudo fsck /dev/sda10" i.e. without the "-t ext4".

If the filesystem is of a type understood by the operating system, you can almost always just do:

$ sudo fsck -t ext4 /dev/sda10

and the system will figure out the type by examining the first few bytes on the partition.

So I checked man fsck and now even more confused. To double check I also checked the source code for fsck and confirmed it align to what is stated in man.

from man:

 

-t fslist
Specifies the type(s) of filesystem to be checked.  When the -A flag is specified, only filesystems that match fslist are checked.  The fslist parameter  is  a  comma-separated list of filesystems and options specifiers.  All of the filesystems in this comma-separated list may be pre‐fixed by a negation operator 'no' or '!', which requests that only those filesystems not listed in fslist will be checked.   If  none  of  the filesystems in fslist is prefixed by a negation operator, then only those listed filesystems will be checked.

< irrelevant parts snipped out>

Normally,  the filesystem type is deduced by searching for filesys in the /etc/fstab file and using the corresponding entry.  If the type cannot be deduced, and there is only a single filesystem given as an argument to the -t option, fsck will use the specified filesystem type.   If this type is not available, then the default filesystem type (currently ext2) is used.



From source code:

/*
 * Run the fsck program on a particular device
 *
 * If the type is specified using -t, and it isn't prefixed with "no"
 * (as in "noext2") and only one filesystem type is specified, then
 * use that type regardless of what is specified in /etc/fstab.
 *
 * If the type isn't specified by the user, then use either the type
 * specified in /etc/fstab, or DEFAULT_FSTYPE.
 */

 

From this it would seem fsck does not check the partition but use fstab, or "-t", or default to ext2.

Can anyone confirm this or point me in the direction where I can find documentation discussing the "examining the first few bytes on the partition."?

Then, the original question I thought I was going to find the answer for: Were the "-t ext4" a typo in slide as referenced above?
 

Click Here!