You are not logged in.

#1 2021-02-18 20:53:20

860lacov
Member
Registered: 2020-05-02
Posts: 497

Do I need fsck HOOK with btrfs?

I'm not sure but I think that I read somewhere that fsck hook is not needed when I use btrfs fs.

In my fstab I have
EFI partition formatted with fat32 dump 0 and pass 2 (automatically generated during system installation)
and root partition formatted with btrfs with dump 0 and pass 0

Can/should I remove fsck hook from mkinitcpio.conf or should it stay for EFI partiton?

Offline

#2 2021-02-18 21:18:30

loqs
Member
Registered: 2014-03-06
Posts: 19,025

Re: Do I need fsck HOOK with btrfs?

The fsck hook is only used for the root file-system,  the fstab is on the root filesystem so can not be accessed.
If the fsck hook is specified it will fsck the root filesystem,  if it is mounted ro by the bootloader systemd will fsck it again.
fsck.btrfs is shell script that exits without error after checking the device exists and the fsck type is automatic which is the type the hook uses. 

cat /usr/bin/fsck.btrfs

Edit:
Fixed the use of ro vs rw parameter.

Last edited by loqs (2021-02-18 21:26:00)

Offline

#3 2021-02-18 21:40:46

860lacov
Member
Registered: 2020-05-02
Posts: 497

Re: Do I need fsck HOOK with btrfs?

Thank you for your answer but to be honest I don't understand
I understand what is going here:

The fsck hook is only used for the root file-system,  the fstab is on the root filesystem so can not be accessed.

If the fsck hook is specified it will fsck the root filesystem

Is that bad?

if it is mounted ro by the bootloader systemd will fsck it again.

I have rw in systemd-boot so I believe that it will not run again. I don't understand what to do with this.

fsck.btrfs is shell script that exits without error after checking the device exists and the fsck type is automatic which is the type the hook uses.

If there is not error then ther will be no information and when error occurs something will happen?

Offline

#4 2021-02-18 21:53:13

loqs
Member
Registered: 2014-03-06
Posts: 19,025

Re: Do I need fsck HOOK with btrfs?

860lacov wrote:
loqs wrote:

If the fsck hook is specified it will fsck the root filesystem

Is that bad?

No.

860lacov wrote:
loqs wrote:

if it is mounted ro by the bootloader systemd will fsck it again.

I have rw in systemd-boot so I believe that it will not run again. I don't understand what to do with this.

Nothing you have it setup correctly.

860lacov wrote:
loqs wrote:

fsck.btrfs is shell script that exits without error after checking the device exists and the fsck type is automatic which is the type the hook uses.

If there is not error then ther will be no information and when error occurs something will happen?

As btrfs does not have a normal fsck command as long as you pass valid options to the command it returns without error without performing any check on the device.
The kernel itself checks btrfs file-systems on mount.

$ cat /usr/bin/fsck.btrfs 
#!/bin/sh -f
#
# Copyright (c) 2013 SUSE
#
# copied from fsck.xfs
# Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
#

# fsck.btrfs is a type of utility that should exist for any filesystem and is
# called during system setup when the corresponding /etc/fstab entries contain
# non-zero value for fs_passno. (See fstab(5) for more.)
#
# Traditional filesystems need to run their respective fsck utility in case the
# filesystem was not unmounted cleanly and the log needs to be replayed before
# mount. This is not needed for BTRFS. You should set fs_passno to 0.
#
# If you wish to check the consistency of a BTRFS filesystem or repair a
# damaged filesystem, see btrfs(8) subcommand 'check'. By default the
# filesystem consistency is checked, the repair mode is enabled via --repair
# option (use with care!).

AUTO=false
while getopts ":aApy" c
do
	case $c in
	a|A|p|y)	AUTO=true;;
	esac
done
shift $(($OPTIND - 1))
eval DEV=\${$#}
if [ ! -e $DEV ]; then
	echo "$0: $DEV does not exist"
	exit 8
fi
if ! $AUTO; then
	echo "If you wish to check the consistency of a BTRFS filesystem or"
	echo "repair a damaged filesystem, see btrfs(8) subcommand 'check'."
fi
exit 0

Offline

Board footer

Powered by FluxBB