? 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.
mmm
Level 4
Level 4
Posts: 230
Joined: Sun Sep 03, 2017 6:57 am

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

Post by mmm »

? fsck - is there a simple way to use it?
Could I just run it from a live usb stick so that the ext4 partition will be unmounted?
Last edited by LockBot on Sun Sep 24, 2023 10:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
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. »

One option:
Enter in a terminal

Code: Select all

sudo touch /forcefsck
When the coputer gets booted the next time, the file system will get checked, before the drives gets mounted.
User avatar
spamegg
Level 13
Level 13
Posts: 4862
Joined: Mon Oct 28, 2019 2:34 am
Contact:

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

Post by spamegg »

I've read that touch /forcefsck is not working anymore due to systemd:
https://askubuntu.com/a/1352782
https://www.linuxuprising.com/2019/05/h ... ystem.html
mmm
Level 4
Level 4
Posts: 230
Joined: Sun Sep 03, 2017 6:57 am

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

Post by mmm »

Cosmo - thanks for your reply - but is it up-to-date?
I found this website:
https://www.linuxuprising.com/2019/05/h ... ystem.html
Which says:
"With old sysvinit and Upstart, users could force a disk check on next reboot using a simple command (sudo touch /forcefsck), but that's no longer the case nowadays, with most Linux distributions using systemd. "
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. »

I am not sure.

If I read the article at askubuntu (the 1st link by spamegg), than it says there (giving Ubuntu 20.04 in the title): "the trick of creating that file does not work anymore". Well, I tried it in LM 20.3 and LM 21, and in both cases the file got created with the command given by me. ls / showed it. I rebootet LM 21 (it's a virtual machine and so it does not break my work) and I see, that the file got automatically removed. Why, if it does not get used? This is no proof, that the file system check had been executed, but from reading the article I expected something different. As the topic has for me very last priority I leave this open. (BTW: tune2fs is far to circumstantial and IMO only of theoretical interest.
rene
Level 20
Level 20
Posts: 12240
Joined: Sun Mar 27, 2016 6:58 pm

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

Post by rene »

Easiest full-proof way of fscking your rootfs is booting into the initramfs. If you from the Grub menu edit the kernel command line and add break to the end of the linux line and boot with F10, you pause in the initramfs, and can use e.g. fsck -fy /dev/sda1 if /dev/sda1 is the partition holding said rootfs for you. exit to continue the boot once done.

If you don't know the device to specify first use mount | grep "on / " to identify it. If you don't get the Grub menu automatically on boot, tapping Esc or on a legacy system holding down Left-Shift when the BIOS starts loading Grub should bring it up.
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. »

In continuation to my post above: viewtopic.php?p=2310730#p2310730

Today I booted my LM 20.3 host, where I did create /forcefsck yesterday. And I noticed, what I did not see in the virtual machine yesterday, because it booted too quick, a notice in the boot splash screen, that I can stopp the file system check by pressing ctrl-c (only for a second). So regardless, what other people write (and copy from other sources), the file system check can get forced with the old method I described above - at least in Mint. I did not test in Ubuntu (20.04 / 22.04), but I am not aware, that anywhere was a notice, that the Mint devs have changed anything against Ubuntu regarding systemd.

So regarding the question of the OP:
mmm wrote: Fri Mar 24, 2023 3:56 pm Cosmo - thanks for your reply - but is it up-to-date?
I can now answer with Yes.
User avatar
karlchen
Level 23
Level 23
Posts: 18177
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

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

Post by karlchen »

spamegg wrote: Fri Mar 24, 2023 3:51 pm I've read that touch /forcefsck is not working anymore due to systemd:
https://askubuntu.com/a/1352782
https://www.linuxuprising.com/2019/05/h ... ystem.html
I can confirm that touch /forcefsck does not make fsck check the filesystem any longer on recent Mint releases.
(My memory tells me that it last worked on Mint 17.x (Ubuntu 14.04) and stopped working from Mint 18.x (Ubuntu 16.04) onwards.)

As the oldest release here is Mint 19.3 (Ubuntu 18.04), I will provided pieces of evidence that /forcefsck has got no more effect during system startup on my Mint 19.3 xfce system.

In my last post I will also present a (less) convenient way of triggering a full fsck at startup time, which does work.
Last edited by karlchen on Sat Mar 25, 2023 10:40 am, edited 1 time in total.
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 762 days now.
Lifeline
User avatar
karlchen
Level 23
Level 23
Posts: 18177
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

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

Post by karlchen »

1. Starting point:
Normal startup. No /forcefsck present. No other trigger enabled to trigger an fsck of the root file system at startup time.

date: Sa 25. Mär 14:35:08 CET 2023


Current mount count:
sudo dumpe2fs -h /dev/sda5 | grep -i "mount count"
dumpe2fs 1.44.1 (24-Mar-2018)
Mount count: 3 <=== current mount count
Maximum mount count: 20

Code: Select all

karl@paulchen:/$ inxi -Sx3
System:    Host: paulchen Kernel: 4.15.0-206-generic arch: i686 bits: 32 compiler: gcc v: 7.5.0 Desktop: Xfce v: 4.14.1 tk: Gtk
             v: 3.22.30 info: xfce4-panel wm: xfwm v: 4.14.0 vt: 7 dm: LightDM v: 1.26.0 Distro: Linux Mint 19.3 Tricia
             base: Ubuntu 18.04 bionic


Very early startup activities are logged in the file /var/log/boot.log.
Because it may hold ansi escape sequences to format its screen output, not all editors may be able to display its content properly.
You need root privileges to read the files.

Code: Select all

karl@paulchen:/var/log$ ls -l boot.log*
-rw------- 1 root root     0 Mär 25 14:36 boot.log
-rw------- 1 root root 12058 Mär 25 14:36 boot.log.1 <=== current boot log (before journalctl sets in)
-rw------- 1 root root 12316 Mär 23 22:46 boot.log.2
-rw------- 1 root root 22856 Mär 22 22:56 boot.log.3
-rw------- 1 root root 11604 Mär 20 21:01 boot.log.4
-rw------- 1 root root 11662 Mär 18 23:59 boot.log.5
-rw------- 1 root root 33936 Mär 14 21:42 boot.log.6
-rw------- 1 root root 22858 Mär 11 21:50 boot.log.7

Code: Select all

karl@paulchen:/var/log$ sudo cat boot.log.1
[sudo] Passwort für karl:           
done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... Scanning for Btrfs filesystems
done.
Begin: Will now check root file system ... fsck from util-linux 2.31.1
[/sbin/fsck.ext4 (1) -- /dev/sda5] fsck.ext4 -a -C0 /dev/sda5 ]<===== fsck only checks for dirty flag or another[
Mint19: clean, 404368/4603904 files, 3215212/18412032 blocks           trigger to execute full fsck.
done.                                                                  None found. Fo fsck executed.
done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... done.

Welcome to Linux Mint 19.3!
                                                                     <=== the rest can be found in journalctl as well
[  OK  ] Started Forward Password Requests to Wall Directory Watch.
[  OK  ] Set up automount Arbitrary Executable File Formats File System Automount Point.
[...rest cut...]
Note:
This will always displayed when fsck has only checked whether there is any reason to execute a full filesystem check.
These 2 lines tell that no such reason has been found. Filesystem is clean.

Now preparing next reboot and creating /forefsck file

Code: Select all

karl@paulchen:/$ sudo touch /forcefsck
karl@paulchen:/$ ls -l forcefsck 
-rw-r--r-- 1 root root 0 Mär 25 14:44 forcefsck
karl@paulchen:/$
If /forcefsck is still honoured, then boot.log should log the fsck activities during startup.

Rebooting the system now.
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 762 days now.
Lifeline
User avatar
karlchen
Level 23
Level 23
Posts: 18177
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

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

Post by karlchen »

2. Rebooted with /forcefsk:

Code: Select all

karl@paulchen:~$ date
Sa 25. Mär 14:54:06 CET 2023

New mount count:

Code: Select all

sudo dumpe2fs -h /dev/sda5 | grep -i "mount count"
dumpe2fs 1.44.1 (24-Mar-2018)
Mount count:              4 <======  current mount 4
Maximum mount count:      20
If fsck had checked the filesystem, the mount count would have been reset to 1.

Code: Select all

karl@paulchen:~$ LC_ALL=C ls -l /forcefsck <===== the file is gone
ls: cannot access '/forcefsck': No such file or directory
The flagfile has been removed during startup.

Code: Select all

karl@paulchen:~$ inxi -Sx3
System:    Host: paulchen Kernel: 4.15.0-206-generic arch: i686 bits: 32 compiler: gcc v: 7.5.0 Desktop: Xfce v: 4.14.1 tk: Gtk
             v: 3.22.30 info: xfce4-panel wm: xfwm v: 4.14.0 vt: 7 dm: LightDM v: 1.26.0 Distro: Linux Mint 19.3 Tricia
             base: Ubuntu 18.04 bionic

Code: Select all

karl@paulchen:/var/log$ ls -l boot.*
-rw------- 1 root root 11432 Mär 25 14:53 boot.log <========== current boot log
-rw------- 1 root root 12058 Mär 25 14:36 boot.log.1
-rw------- 1 root root 12316 Mär 23 22:46 boot.log.2
-rw------- 1 root root 22856 Mär 22 22:56 boot.log.3
-rw------- 1 root root 11604 Mär 20 21:01 boot.log.4
-rw------- 1 root root 11662 Mär 18 23:59 boot.log.5
-rw------- 1 root root 33936 Mär 14 21:42 boot.log.6
-rw------- 1 root root 22858 Mär 11 21:50 boot.log.7

Code: Select all

karl@paulchen:/var/log$ sudo cat boot.log
done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... Scanning for Btrfs filesystems
done.
Begin: Will now check root file system ... fsck from util-linux 2.31.1
[/sbin/fsck.ext4 (1) -- /dev/sda5] fsck.ext4 -a -C0 /dev/sda5  <===== fsck only checks for dirty flag or another
Mint19: clean, 404370/4603904 files, 3201322/18412032 blocks          trigger to execute full fsck.
done.                                                                 None found. Fo fsck executed.
done.                                                                 Next boot log will illustrate the difference,
Begin: Running /scripts/local-bottom ... done.                        what fsck logs, when really running an fsck
Begin: Running /scripts/init-bottom ... done.

Welcome to Linux Mint 19.3!

[  OK  ] Created slice System Slice.
[  OK  ] Listening on Journal Socket (/dev/log).
[...cut...]
fsck has not logged any filesystem checking activities. It has only checked the firty flag. None found. Filesystem still clean. Nothing to b done. No forced fsck filesystem check has been executed.


Preparing another forced fsck at boot time

The current mount count is 4. We will set it to 21, which exceeds the defined maximum mount count between forced fsck's.
(Max count has been defined by me.)

Code: Select all

sudo dumpe2fs -h /dev/sda5 | grep -i "mount count"
Current mount count: 4
dumpe2fs 1.44.1 (24-Mar-2018)
Mount count:              4
Maximum mount count:      20

Code: Select all

karl@paulchen:~$ sudo tune2fs -C 21 /dev/sda5 <== mount count set to 21, max. is 20, so fsck should be triggered on reboot
tune2fs 1.44.1 (24-Mar-2018)
Die Anzahl der Einhängungen wird auf 21 gesetzt

Code: Select all

sudo dumpe2fs -h /dev/sda5 | grep -i "mount count"
dumpe2fs 1.44.1 (24-Mar-2018)
Mount count:              21
Maximum mount count:      20
Rebooting the system again.
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 762 days now.
Lifeline
User avatar
karlchen
Level 23
Level 23
Posts: 18177
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

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

Post by karlchen »

3. Rebooted with mount count greater than Max Mount Count between forced fsck's

Code: Select all

karl@paulchen:~$ date
Sa 25. Mär 15:08:33 CET 2023

Code: Select all

karl@paulchen:~$ sudo dumpe2fs -h /dev/sda5 | grep -i "mount count"
[sudo] Passwort für karl:           
dumpe2fs 1.44.1 (24-Mar-2018)
Mount count:              1 <======= current mount count on 1, because fsck has reset it
Maximum mount count:      20

Code: Select all

karl@paulchen:~$ cd /var/log
karl@paulchen:/var/log$ ls -l boot.*
-rw------- 1 root root 33177 Mär 25 15:07 boot.log <===== current boot.log
-rw------- 1 root root 12058 Mär 25 14:36 boot.log.1
-rw------- 1 root root 12316 Mär 23 22:46 boot.log.2
-rw------- 1 root root 22856 Mär 22 22:56 boot.log.3
-rw------- 1 root root 11604 Mär 20 21:01 boot.log.4
-rw------- 1 root root 11662 Mär 18 23:59 boot.log.5
-rw------- 1 root root 33936 Mär 14 21:42 boot.log.6
-rw------- 1 root root 22858 Mär 11 21:50 boot.log.7
karl@paulchen:/var/log$ 

Note:
We will this time read boot.log using sudoedit in order to see the complete lines logged by the fsck filesystem check.
(Using sudoedit in this case is more convenient that using "cat" or "less", because I want to catch all lines for this post here.)

Code: Select all

sudoedit boot.log

Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... Scanning for Btrfs filesystems
done.
Begin: Will now check root file system ... fsck from util-linux 2.31.1
[/sbin/fsck.ext4 (1) -- /dev/sda5] fsck.ext4 -a -C0 /dev/sda5
Mint19 has been mounted 21 times without being checked, check forced.
^AMint19: |                                                        |  0.1%
^AMint19: |=                                                       /  2.1%
^AMint19: |=                                                       -  2.2%
^AMint19: |==                                                      \  4.1%
^B^AMint19: |===                                                     |  6.1%
^AMint19: |=====                                                   /  8.1%
^AMint19: |=====                                                   -  8.2%
^AMint19: |======                                                  \ 10.1%
^AMint19: |======                                                  | 10.2%
^AMint19: |======                                                  / 10.3%
^B^AMint19: |=======                                                 - 12.1%
^AMint19: |========                                                \ 14.1%
^AMint19: |=========                                               | 16.1%
^AMint19: |==========                                              / 18.1%
^AMint19: |===========                                             - 20.1%
^AMint19: |============                                            \ 22.0%
^AMint19: |===============                                         | 26.0%
^AMint19: |================                                        / 28.0%
^AMint19: |====================                                    - 36.0%
^AMint19: |====================                                    \ 36.1%
^AMint19: |=====================                                   | 38.0%
^AMint19: |=====================                                   / 38.1%
^AMint19: |======================                                  - 40.0%
^AMint19: |========================                                \ 42.0%
^AMint19: |=========================                               | 44.0%
^AMint19: |===========================                             / 48.0%
^AMint19: |===========================                             \ 48.2%
^AMint19: |===========================                             | 48.3%
^AMint19: |===========================                             / 48.5%
^AMint19: |===========================                             - 48.6%
^AMint19: |============================                            \ 49.9%
^AMint19: |============================                            | 50.1%
^AMint19: |=============================                           / 51.9%
^AMint19: |=============================                           - 52.2%
^AMint19: |==============================                          \ 53.9%
^AMint19: |==============================                          | 54.1%
^AMint19: |==============================                          / 54.2%
^AMint19: |===============================                         - 55.9%
^AMint19: |===============================                         \ 56.0%
^AMint19: |===============================                         | 56.2%
^AMint19: |================================                        / 57.9%
^AMint19: |=================================                       - 58.0%
^AMint19: |==================================                      \ 59.9%
^AMint19: |==================================                      | 60.0%
^B^AMint19: |===================================                     / 61.9%
^AMint19: |===================================                     - 62.0%
^AMint19: |====================================                    \ 63.9%
^AMint19: |====================================                    | 64.0%
^AMint19: |=====================================                   / 65.9%
^AMint19: |=====================================                   - 66.0%
^AMint19: |=====================================                   \ 66.1%
^AMint19: |=====================================                   | 66.4%
^AMint19: |=====================================                   / 66.8%
^AMint19: |=======================================                 | 69.1%
^AMint19: |=======================================                 / 70.1%
^AMint19: |=======================================                 - 70.3%
^AMint19: |========================================                \ 70.8%
^AMint19: |========================================                | 71.2%
^B^AMint19: |========================================                / 71.3%
^AMint19: |========================================                - 72.0%
^B^AMint19: |========================================                \ 72.2%
^AMint19: |=========================================               | 72.7%
^AMint19: |=========================================               / 73.0%
^AMint19: |=========================================               - 73.2%
^AMint19: |=========================================               \ 73.7%
^AMint19: |=========================================               | 74.0%
^B^AMint19: |==========================================              / 74.3%
^AMint19: |==========================================              - 74.8%
^AMint19: |==========================================              \ 75.3%
^AMint19: |==========================================              | 75.6%
^AMint19: |===========================================             / 76.0%
^AMint19: |===========================================             - 76.3%
^AMint19: |===========================================             \ 76.7%
^AMint19: |===========================================             | 76.9%
^AMint19: |===========================================             / 77.5%
^AMint19: |============================================            - 77.8%
^AMint19: |============================================            \ 78.3%
^AMint19: |============================================            | 78.7%
^AMint19: |============================================            / 79.1%
^AMint19: |============================================            - 79.3%
^AMint19: |=============================================           \ 79.7%
^AMint19: |=============================================           | 80.2%
^AMint19: |=============================================           / 80.7%
^AMint19: |=============================================           - 81.1%
^AMint19: |==============================================          \ 81.6%
^AMint19: |==============================================          | 82.0%
^AMint19: |==============================================          / 82.1%
^AMint19: |==============================================          - 82.5%
^B^AMint19: |===============================================         \ 83.1%
^AMint19: |===============================================         | 83.5%
^AMint19: |===============================================         / 84.0%
^AMint19: |===============================================         - 84.4%
^AMint19: |===============================================         \ 84.8%
^AMint19: |================================================        | 85.2%
^AMint19: |================================================        / 85.7%
^AMint19: |================================================        - 86.1%
^AMint19: |================================================        \ 86.5%
^AMint19: |=================================================       | 86.8%
^AMint19: |=================================================       / 87.2%
^AMint19: |=================================================       - 87.5%
^AMint19: |=================================================       \ 87.8%
^AMint19: |=================================================       | 88.0%
^AMint19: |=================================================       / 88.2%
^AMint19: |===============================================         | 83.5%
^AMint19: |===============================================         / 84.0%
^AMint19: |===============================================         - 84.4%
^AMint19: |===============================================         \ 84.8%
^AMint19: |================================================        | 85.2%
^AMint19: |================================================        / 85.7%
^AMint19: |================================================        - 86.1%
^AMint19: |================================================        \ 86.5%
^AMint19: |=================================================       | 86.8%
^AMint19: |=================================================       / 87.2%
^AMint19: |=================================================       - 87.5%
^AMint19: |=================================================       \ 87.8%
^AMint19: |=================================================       | 88.0%
^AMint19: |=================================================       / 88.2%
^AMint19: |===============================================         | 83.5%
^AMint19: |===============================================         / 84.0%
^AMint19: |===============================================         - 84.4%
^AMint19: |===============================================         \ 84.8%
^AMint19: |================================================        | 85.2%
^AMint19: |================================================        / 85.7%
^AMint19: |================================================        - 86.1%
^AMint19: |================================================        \ 86.5%
^AMint19: |=================================================       | 86.8%
^AMint19: |=================================================       / 87.2%
^AMint19: |=================================================       - 87.5%
^AMint19: |=================================================       \ 87.8%
^AMint19: |=================================================       | 88.0%
^AMint19: |=================================================       / 88.2%
^AMint19: |===============================================         | 83.5%
^AMint19: |===============================================         / 84.0%
^AMint19: |===============================================         - 84.4%
^AMint19: |===============================================         \ 84.8%
^AMint19: |================================================        | 85.2%
^AMint19: |================================================        / 85.7%
^AMint19: |================================================        - 86.1%
^AMint19: |================================================        \ 86.5%
^AMint19: |=================================================       | 86.8%
^AMint19: |=================================================       / 87.2%
^AMint19: |=================================================       - 87.5%
^AMint19: |=================================================       \ 87.8%
^AMint19: |=================================================       | 88.0%
^AMint19: |=================================================       / 88.2%
^AMint19: |==================================================      \ 88.7%
^AMint19: |==================================================      | 88.8%
^AMint19: |==================================================      / 88.9%
^AMint19: |==================================================      - 89.0%
^AMint19: |==================================================      \ 89.1%
^AMint19: |==================================================      | 89.3%
^B^AMint19: |==================================================      / 89.5%
^AMint19: |==================================================      - 89.6%
^AMint19: |==================================================      \ 89.7%
^AMint19: |==================================================      | 89.9%
^AMint19: |==================================================      / 90.0%
^B^AMint19: |====================================================    - 92.2%
^AMint19: |====================================================    \ 92.7%
^AMint19: |====================================================    | 93.2%
^AMint19: |=====================================================   / 93.8%
^AMint19: |=====================================================   - 94.2%
^AMint19: |=====================================================   \ 94.7%
^AMint19: |=====================================================   | 95.0%
^B^AMint19: |=====================================================   / 95.1%
^B^AMint19: |======================================================= - 97.6%
^AMint19: |========================================================\ 99.9%
^AMint19: |========================================================| 100.0%

Mint19: 404365/4603904 files (0.3% non-contiguous), 3201070/18412032 blocks
done.
done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... done.

Welcome to ^[[1mLinux Mint 19.3^[[0m!

[^[[0;32m  OK  ^[[0m] Created slice User and Session Slice.
[^[[0;32m  OK  ^[[0m] Reached target User and Group Name Lookups.
[...cut...]

Summary:

On recent Mint releases creating the flag file /forcefsck will no longer make fsck execute a filesystem check at startup time.

One way of achieving so is e.g. using tune2fs and set the current mount count to a higher number than the maximum mount count.
Another way would be to set the maximum mount count to 1 before the next reboot. But in this case you may want to set it to a bigger number afterwards, else the system will do a full filesystem check on every reboot.
This is why I prefer to manipulate the current mount instead.

If anybody knows a more convenient (and really working) way of triggering a filesystem check on next reboot, please, speak up.
(I suspect it may be some systemd commandline.)
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 762 days now.
Lifeline
rene
Level 20
Level 20
Posts: 12240
Joined: Sun Mar 27, 2016 6:58 pm

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

Post by rene »

karlchen wrote: Sat Mar 25, 2023 10:38 am I can confirm that touch /forcefsck does not make fsck check the filesystem any longer on recent Mint releases.
Quite. What Cosmo was seeing was just the normal fsck which happens regardless of /forcefsck being present or not, and which only actually checks if the filesystem is marked unclean or if a maximum mount count has been (enabled for the filesystem and) reached. The point of /forcefsck as well as the context of this thread is to trigger one on request.

This is also the sense in which my above post viewtopic.php?p=2310742#p2310742 species the -f, i.e., force, flag to fsck. The there described method is the "most full-proof" in the sense of having the system boot into the guaranteed same block-device environment as normal for said system: specifically doing things from a Live system can due to potentially differently configured kernel be an issue there.

What's also possible is booting into "recovery mode" (or what did Ubuntu call it...) from the "Advanced Options" Grub entry and launching the fsck from the resulting text-mode menu -- but once you're in the Grub menu anyway I suggest my above break method. If nothing else it demystifies the initramfs for you when you're due to root-fs damage dumped into it at a point you did not explicitly request it. A slightly different way with systemd is using not break but fsck.mode=force on the kernel command line, but once again see foregoing and just do it manually.

I.e., as to that requested "more convenient" way please see that above post viewtopic.php?p=2310742#p2310742. Not aware of any (even) more convenient methods, certainly not over multiple distributions.
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. »

I summarize in my words:

Forcing a file system check as in previous time is no longer doable.

The information from sources like askubuntu, that creating the said file is impossible, is misleading or sup-optimal formulated.

The fact, that the system shows an information during boot time about stopping the file system check and removing the said file, is misleading; I judge it as features, that have been forgotten to get removed.

The way to go is one of those, which rene described. (As not so seldom there are multiple ways to the same result.) As I said already, the question itself has the least priority for me, so I do not bother about it further. I did the test with forcefsck because this did cost me 10 seconds and the wording on askubuntu cried for contradiction.
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. »

Cosmo. wrote: Sat Mar 25, 2023 4:26 am In continuation to my post above: viewtopic.php?p=2310730#p2310730

Today I booted my LM 20.3 host, where I did create /forcefsck yesterday. And I noticed, what I did not see in the virtual machine yesterday, because it booted too quick, a notice in the boot splash screen, that I can stopp the file system check by pressing ctrl-c (only for a second). So regardless, what other people write (and copy from other sources), the file system check can get forced with the old method I described above - at least in Mint. I did not test in Ubuntu (20.04 / 22.04), but I am not aware, that anywhere was a notice, that the Mint devs have changed anything against Ubuntu regarding systemd.

So regarding the question of the OP:
mmm wrote: Fri Mar 24, 2023 3:56 pm Cosmo - thanks for your reply - but is it up-to-date?
I can now answer with Yes.
EDIT: Read further. This result is wrong.
mmm
Level 4
Level 4
Posts: 230
Joined: Sun Sep 03, 2017 6:57 am

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

Post by mmm »

OP here. Thanks for the work done to address my question.
Most of it is beyond my level of understanding.
The machine I am experimenting on is a Lenovo Ideapad z570 laptop of 2021 - 12 years old.
Single booting LM 21.1 cinnamon.
UEFI.
Two partitions:
sda1 fat32 efi (very small)
sda2 ext4 (rest of the SSD)

Does sda1 need to be checked?
is there a step-by-step guide suitable for a beginner?

I tried: john@z570:~$ sudo tune2fs -l /dev/sda2 | grep checked
and got: Last checked: Mon Sep 12 14:00:13 2022

That check happened by itself after the laptop failed to recover from suspend.
In the end I did a clean install, after saving my data using a live usb.

I don't want to make a fuss about this - because I hardly ever get problems of any kind using LM.
I just thought it would be useful to have a way of checking the file system before further diagnostic procedures.
User avatar
karlchen
Level 23
Level 23
Posts: 18177
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

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

Post by karlchen »

karlchen wrote: Sat Mar 25, 2023 11:20 amIf anybody knows a more convenient (and really working) way of triggering a filesystem check on next reboot, please, speak up.
My current favourite approach is
  • invoking the Grub boot menu
  • pressing e like edit on the desired system
  • adding the kernel parameter fsck.mode=force to the Grub commandline, which starts with linux /boot/vmlinuz..., at boot time
  • pressing <F10> to boot the system using the modified boot entry
Cf. rene's post above. The fsck.mode=force approach should work, too, on all those systems, where no maximum mount count has been defined between fsck runs. (By default, max. mount count has not been set.)
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 762 days now.
Lifeline
User avatar
spamegg
Level 13
Level 13
Posts: 4862
Joined: Mon Oct 28, 2019 2:34 am
Contact:

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

Post by spamegg »

karlchen wrote: Sat Mar 25, 2023 11:20 am If anybody knows a more convenient (and really working) way of triggering a filesystem check on next reboot, please, speak up.
My favorite is sudo tune2fs -c 1 /dev/nvme0n1p1. It triggers a file system check on every boot without exception. I've been using it for 2 years. I disabled all the boot splash screens so I can clearly see all the kernel and systemd messages, and I can watch the file system check happen every time without fail. To clarify, I only use this command ONCE. And then forget about it forever. It keeps working for years after using it only once.

Here the -c parameter stands for count, specifically maximum mount count. If you use, say, -c 5 then it will trigger a file system check every 5 mounts. One can also use -i which stands for interval between checks (in days). Using -i 3 will trigger once every 3 days. So if you don't want a check at every boot like I do, you can adjust the parameters to your preference.

Once again, the command needs to be used only once. Read more in man tune2fs.
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. »

Doing a check at every boot. :shock: That is extreme and of course it costs in the sum extreme time.

Doing a check every month, or 5 month or whatever: This is pointless. The file system might break just a day after the last check, so this brings nothing.

In years I did not encounter trouble with the file system and saw no need to reintroduce, what Ubuntu had removed several years ago. There are extremely seldom situations, where a check is useful, but they exist: Assume a power breakdown in your home. Consequently your computer will be off just in the same way, as if you would have used the infamous hold power button method. When power is back it does really make sense to do a file system check and for this case setting up tune2fs is far too laborious. Furthermore karlchen asked for a method to do the check on next boot.
rene
Level 20
Level 20
Posts: 12240
Joined: Sun Mar 27, 2016 6:58 pm

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

Post by rene »

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. It just also does for the boot after that, and the one after that, and the one after that, and the one...

spamegg has previously argued that having an fsck be automatic on boot also has it be automatic when it's in fact needed due to rootfs damage, and in specific response to a fair few bewildered new users staring at an (initramfs) text prompt after an e.g. power outage. I as mentioned find addressing bewilderment at the core by demystifying the initramfs through mentioned break method better, and I'll settle for the fsck.mode=force alternative so as to have said dear bewildered new user at least not needing to know the device. But should one be the type to generally run a system 24/24 anyway -- be American or an otherwise vile energy waster... -- the tune2fs works.
t42
Level 11
Level 11
Posts: 3709
Joined: Mon Jan 20, 2014 6:48 pm

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

Post by t42 »

rene wrote: Sun Mar 26, 2023 12:29 pm settle for the fsck.mode=force alternative so as to have said dear bewildered new user at least not needing to know the device
or to be even less involved benefit from both fsck.mode=force fsck.repair=yes options?
-=t42=-
Locked

Return to “Beginner Questions”