如何检查在自动检查之前根文件系统可以挂载多少次?

如何检查在自动检查之前根文件系统可以挂载多少次?

如何检查在自动检查之前根文件系统可以挂载多少次?我想知道在我的系统上它可以挂载多少次。

答案1

如果您的根文件系统是ext4,您可以使用tune2fs来检查(也可以修改)在自动检查之前可以挂载多少次。请参阅man tune2fs

 -l     List the contents of the filesystem superblock, including the
        current values of the parameters that can be set via this program.

使用我的根文件系统作为示例:

sudo tune2fs -l /dev/sda1

或更加专注

$ LANG=C sudo tune2fs -l /dev/sda1|grep -A4 'Mount count:'
[sudo] password for sudodus: 
Mount count:              30
Maximum mount count:      40
Last checked:             Tue Dec 25 05:50:43 2018
Check interval:           2592000 (1 month)
Next check after:         Thu Jan 24 05:50:43 2019

您可以同时拥有多个挂载标准和一个时间标准,并且(在启动期间)当满足第一个标准时,就会进行检查。


请注意,在许多新版本(tune2fs和 Linux 文件系统)中,默认情况下禁用依赖于挂载计数的检查,以避免在e2fsck其工作时出现意外的长时间重启。

   -c max-mount-counts
          Adjust the number of mounts after which the filesystem will be checked by
          e2fsck(8).  If max-mount-counts is 0 or  -1,  the  number  of  times  the
          filesystem is mounted will be disregarded by e2fsck(8) and the kernel.

          Staggering  the  mount-counts  at  which filesystems are forcibly checked
          will avoid all filesystems being checked at one time when using journaled
          filesystems.

          Mount-count-dependent  checking is disabled by default to avoid unantici‐
          pated long reboots while e2fsck does its work.  However, you may wish  to
          consider  the  consequences  of  disabling mount-count-dependent checking
          entirely.  Bad disk drives, cables, memory, and  kernel  bugs  could  all
          corrupt  a  filesystem  without marking the filesystem dirty or in error.
          If you are using journaling on  your  filesystem,  your  filesystem  will
          never  be marked dirty, so it will not normally be checked.  A filesystem
          error detected by the kernel will still force an fsck on the next reboot,
          but it may already be too late to prevent data loss at that point.

          See also the -i option for time-dependent checking.

相关内容