The Linux filesystem can be damaged under various circumstances, e.g., system crash, power loss, disconnected disk, accidentally overwritten i-node, etc. Thus it is a good idea to check the integrity of the filesystem regularly to minimize the risk of filesystem corruption. When it comes to checking and repairing Linux filesystem, fsck is a useful tool.
In my case, I boot to Arch using an external USB drive. However, the cable is very finicky and I get disconnected. After which my system hangs. I can’t even get to a terminal. If you are stuck in this situation read this article. The article talks about doing a bunch of things using your terminal, but then the terminal is unavailable right? I am not sure if this is a recoverable situation. But it can get worse. When you reboot, you will find that you have a bad superblock error. Now you are really screwed. But, that’s where a live CD comes to your help. See this ArchISO article for more help on Live CD.
You will have to know more about hard disk partitions at this point. If you are a novice, you should also check out this article to learn about the different ways you can dig information about your hard disk. Anyway, back to the task at hand
Force Filesystem Checks
If the filesystem is large, you can force filesystem checks on a regular basis, instead of every boot time. In order to do so, first find out the filesystem configuration with tune2fs command. The following command line shows the current values of filesystem related parameters. Note that /dev/sda3 is the partition where the filesystem superblock is located.
$ sudo tune2fs -l /dev/sda3
From the tune2fs output, you can see not only the filesystem state (clean or not) but also parameters that are related to filesystem checks. “Maximum mount count” parameter is the number of mounts after which the filesystem check gets triggered. “Check interval” parameter shows the maximum time between two filesystem checks. On most Linux distros, these parameters are not set by default, meaning no regular filesystem checks are occurring.
To force filesystem check for every 30 mounts, run the following command.$ sudo tune2fs -c 30 /dev/sda1
To force filesystem check for every 3 months, use the command below.$ sudo tune2fs -i 3m /dev/sda1
Now verify that newly added filesystem check conditions are set properly.
$ sudo tune2fs -l /dev/sda3
tune2fs 1.44.4 (18-Aug-2018)
Filesystem UUID: 0fd92e4c-7c23-4983-bf4b-0c8b8730406a
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 122068992
Block count: 488247825
Reserved block count: 24412391
Free blocks: 475407831
Free inodes: 121670650
First block: 0
Block size: 4096
Fragment size: 4096
Group descriptor size: 64
Reserved GDT blocks: 1024
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
RAID stripe width: 8191
Flex block group size: 16
Filesystem created: Wed Oct 17 07:39:53 2018
Last mount time: Wed Nov 28 01:26:35 2018
Last write time: Wed Nov 28 01:26:35 2018
Mount count: 170
Maximum mount count: -1
Last checked: Wed Oct 17 07:39:53 2018
Check interval: 7776000 (3 months)
Next check after: Tue Jan 15 07:39:53 2019
Lifetime writes: 163 GB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 32
Desired extra isize: 32
Journal inode: 8
First orphan inode: 106825427
Default directory hash: half_md4
Directory Hash Seed: d30172f0-a8c1-483e-81e5-7111b958934d
Journal backup: inode blocks
Force One-Time Filesystem Check on the Next Reboot
If you want to trigger a one-time filesystem check on your next reboot, you can use this command.
$ sudo touch /forcefsck
Once you create an empty file named forcefsck in the top directory (/) like above, it will force filesystem check the next time you boot up. After successful booting, /forcefsck will automatically be removed.
This is a one-on-one message from VatiKos site which you are following. I would like to inform you that VatiKos has stopped posting new Christian Articles. Because we have launched a NEW and EALBORATE website for Christian Articles in the name CATHOLIGHT.COM. Therefore, we request you to take time to visit our new website https://catholight.com/ and follow us by entering your e-mail for subscription (which is completely FREE & SECURE).
Have a Great Day! God Bless!