? fsck - is there a simple way to use it?

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: ? fsck - is there a simple way to use it?

Post by rene »

t42 wrote: Sun Mar 26, 2023 12:45 pm or to be even less involved benefit from both fsck.mode=force fsck.repair=yes options?
fsck.repair is unknown on (at least) an Arch base and while I see that Ubuntu/Mint (and supposedly Debian) does support it, without it, the fsck is in both cases already run with -a which is for e2fsck to say it already does automatic repairs, even if only if they "can be safely fixed without human intervention". Now, as with -y itself the issue is going to nearly always be that asking the user is every bit as safe or unsafe as not even bothering and just going ahead, so well, whatever suits one's fancy and all, but you'd then at least want to be aware that it's not a universally understood parameter.
Cosmo.
Level 24
Level 24
Posts: 22968
Joined: Sat Dec 06, 2014 7:34 am

Re: ? fsck - is there a simple way to use it?

Post by Cosmo. »

rene wrote: Sun Mar 26, 2023 12:29 pm
Cosmo. wrote: Sun Mar 26, 2023 3:50 am Furthermore karlchen asked for a method to do the check on next boot.
The tune2fs -c1 does do that.
Only in the case, that the user has set it as a general check. In case of my example it can only work at the second next boot, and this is not the next (at least in my understanding). Who wants to do a check on every boot, shall do it; I don't want this and I think I made this clear. Besides that: tune2fs needs in case of a system with several a configuration for each of them. Far to laborious, not my way and quite obviously far more circumstantial as in the times before systemd.

The good thing: As long, as there is no sudden power loss, I will not need to do a check in years (taken from the experience of the past years). Out of this reason I said already, that this has in my eyes the least priority.
User avatar
karlchen
Level 23
Level 23
Posts: 18231
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: ? fsck - is there a simple way to use it?

Post by karlchen »

Seems I did not express my wish precisely enough:
When talking about doing an fsck on next reboot, I had in mind a one-time operation only, i.e. an fsck run only during the next reboot, not on every reboot.
I have just checked inserting the kernel parameter fsck.mode=force into the linux /boot/vmlinuz.... line at boot time.
It does precisely what I want.
fsck is invoked and checks the root filesystem of the LM system once, before it is started up.
When the LM splash screen appeared, I pressed ESC and was able to see fsck at work.
Once the system had come up normally thereafter, the logfile /var/log/boot.log held the log entries generated by fsck.

The test of fsck.mode=force has been executed on LMDE 5 32-bit.

Code: Select all

karl@paulchen:~$ inxi -Sx3
System:
  Host: paulchen Kernel: 5.10.0-21-686 arch: i686 bits: 32 compiler: gcc
    v: 10.2.1 Desktop: Cinnamon v: 5.6.8 tk: GTK v: 3.24.24 wm: muffin vt: 7
    dm: LightDM v: 1.26.0 Distro: LMDE 5 Elsie base: Debian 11.2 bullseye
What will be more interesting than my usage scenario is whether this thread has helped the thread starter mmm to find a way of invoking fsck at startup time as well.
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 792 days now.
Lifeline
mmm
Level 4
Level 4
Posts: 235
Joined: Sun Sep 03, 2017 6:57 am

Re: ? fsck - is there a simple way to use it?

Post by mmm »

karlchen » Sun Mar 26, 2023 5:32 pm wrote:
"What will be more interesting than my usage scenario is whether this thread has helped the thread starter mmm to find a way of invoking fsck at startup time."

Although I followed you experts with great interest as you compared various approaches, I did not find a method.
I remember from the distant past that it was easily done in Windows.
But I cheerfully accept a very few disadvantages of Linux because of its overwhelming advantages.
I intend never to go back to Windows.
And whenever I have tried a new distro I have always returned to Mint.

I have decided not to bother with fsck.
I will stick to making regular drive images using Image For Linux from TerabyteUnlimited, which has served me well for many years.
I may even install Timeshift as well.

The only problem I ever had was when I tried going from 20.3 to 21 by upgrading.
Things seemed to go all right, but the machine wouldn't resume from suspend.
So I clean installed 21 and all was well.
User avatar
spamegg
Level 14
Level 14
Posts: 5096
Joined: Mon Oct 28, 2019 2:34 am
Contact:

Re: ? fsck - is there a simple way to use it?

Post by spamegg »

mmm wrote: Mon Mar 27, 2023 2:39 pm I remember from the distant past that it was easily done in Windows.
But I cheerfully accept a very few disadvantages of Linux because of its overwhelming advantages.
I think these guys scared you off a bit. Linux does not have a disadvantage here. It's actually quite easy: sudo tune2fs -c 1 /dev/the-partition-you-want. You can turn it off by using the same command with -c 0.
mmm
Level 4
Level 4
Posts: 235
Joined: Sun Sep 03, 2017 6:57 am

Re: ? fsck - is there a simple way to use it?

Post by mmm »

Tue 28 Mar 12:06:01 BST 2023

Thanks spamegg - I tried your method and it seemed to work on a Dell N5040 bios laptop with just one partition with Partition Table msdos.

I used these commands, rebooting when appropriate:
sudo tune2fs -l /dev/sda1 | grep checked...which gave Sat Dec 24 15:24:12 2022
sudo tune2fs -c 1 /dev/sda1
sudo tune2fs -l /dev/sda1 | grep checked...which gave Tue Mar 28 11:37:22 2023
sudo tune2fs -c 0 /dev/sda1
sudo tune2fs -l /dev/sda1 | grep checked...which gave Tue Mar 28 11:37:22 2023

Will the file system still be checked by the OS if an actual problem arises?
(as it did last christmas eve).
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: ? fsck - is there a simple way to use it?

Post by rene »

Yes, it will and it's fine.

Will however also still point out viewtopic.php?p=2310742#p2310742, while as per discussion noting that you can rather than break also use fsck.mode=force. Getting to know these things before disaster strikes tends to help at latter time...
mmm
Level 4
Level 4
Posts: 235
Joined: Sun Sep 03, 2017 6:57 am

Re: ? fsck - is there a simple way to use it?

Post by mmm »

rene wrote: Tue Mar 28, 2023 2:17 pm Yes, it will and it's fine.

Will however also still point out viewtopic.php?p=2310742#p2310742, while as per discussion noting that you can rather than break also use fsck.mode=force. Getting to know these things before disaster strikes tends to help at latter time...
rene - your first comment reassured me - but I do not understand at all your second point!
Is it about getting to the grub menu on booting?
I cannot do that.
None of the methods work e.g. holding shift while booting, or pressing escape while booting etc. etc.
Please can you clarify your comment?
Is it just another way of doing what I did?
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: ? fsck - is there a simple way to use it?

Post by rene »

mmm wrote: Tue Mar 28, 2023 3:27 pm Is it just another way of doing what I did?
Not "mechanically" but eventually, sure.

What the tune2fs does is record in the filesystem itself that fsck should be force-checking it on each mount. This is why you need to again set it back to 0 after rebooting and checking once so as to not have it check on every boot. The break or fsck.mode=force parameter on the kernel command line is about "check once now" and is as such more directly keeping with the expressed want of invoking fsck specifically -- but yes, for that you need to get into the Grub menu, and if that's an issue let's just consider things solved by the tune2fs alternative. It's as said fine.
Reddog1
Level 7
Level 7
Posts: 1939
Joined: Wed Jun 01, 2011 2:12 pm

Re: ? fsck - is there a simple way to use it?

Post by Reddog1 »

You don't have to use "1" with tune2fs. You can use any number, and fsck will run at boot time at that set number of boots. I don't boot my machines often, and the spinner drives I have set to run every 5 boots.

You can also use this command to run fsck periodically. For example you could set fsck to run a filesystem check every 10 boots, by using -c 10:

Code: Select all

sudo tune2fs -c 10 /dev/sdX
Of course, replace the "X" with the drive partition you wish to check periodically
linux-rox
Level 10
Level 10
Posts: 3334
Joined: Sun Jul 19, 2020 9:17 pm

Re: ? fsck - is there a simple way to use it?

Post by linux-rox »

t42 wrote: Sun Mar 26, 2023 12:45 pm or to be even less involved benefit from both fsck.mode=force fsck.repair=yes options?
FWIW, I have since had an opportunity to test this question. The answer, as implied by the man page, is that both options are required. At least in Mint, if one runs only fsck.mode=force, it returns error code 4 and advises to run a repair, whereas both together works in one go.
User avatar
MiZoG
Level 8
Level 8
Posts: 2381
Joined: Fri Jan 26, 2018 8:30 pm
Location: Athens, Greece

Re: ? fsck - is there a simple way to use it?

Post by MiZoG »

Easy fsck checks for the people are high on the agenda of President (not Jimmy, Jonathan!) Carter.
User avatar
spamegg
Level 14
Level 14
Posts: 5096
Joined: Mon Oct 28, 2019 2:34 am
Contact:

Re: ? fsck - is there a simple way to use it?

Post by spamegg »

MiZoG wrote: Tue May 02, 2023 9:07 pm Easy fsck checks for the people are high on the agenda of President (not Jimmy, Jonathan!) Carter.
Wow, good on him! He's got my vote for sure. :lol:
Locked

Return to “Beginner Questions”