[ SOLVED ] Bash command to check system integrity ?
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
[ SOLVED ] Bash command to check system integrity ?
Hi,
I sometimes use the "chkdsk" or "sfc /scannow" command line tools to check the integrity of my Windows system.
I would like to know if there are equivalent routine commands to verify/repair the complete integrity of a Linux system ?
Thanks for your tips.
I sometimes use the "chkdsk" or "sfc /scannow" command line tools to check the integrity of my Windows system.
I would like to know if there are equivalent routine commands to verify/repair the complete integrity of a Linux system ?
Thanks for your tips.
Last edited by LockBot on Sat Sep 23, 2023 10:00 pm, edited 4 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Bash command to check system integrity ?
Yes, it's called
A short summary:
Here
Please note that in order to repair anything, the file system has to be UNMOUNTED.
You can automate this file system check to run at every boot:
fsck
. You can read up on it in the manuals: man fsck
A short summary:
Code: Select all
➜ tldr fsck
fsck
Check the integrity of a filesystem or repair it. The filesystem should be unmounted at the time the command is run.More information: https://manned.org/fsck.
- Check filesystem /dev/sdXN, reporting any damaged blocks:
sudo fsck {{/dev/sdXN}}
- Check filesystem /dev/sdXN, reporting any damaged blocks and interactively letting the user choose to repair each one:
sudo fsck -r {{/dev/sdXN}}
- Check filesystem /dev/sdXN, reporting any damaged blocks and automatically repairing them:
sudo fsck -a {{/dev/sdXN}}
/dev/sdXN
is something like: /dev/sda1
or /dev/nvme0n1p1
. You can see them with lsblk
.Please note that in order to repair anything, the file system has to be UNMOUNTED.
You can automate this file system check to run at every boot:
sudo tune2fs -c 1 /dev/sdXN
but some might consider this overkill.Re: Bash command to check system integrity ?
Thank you very much for your very comprehensive answer.
It will be very useful to me before each backup of the evolution of my system.
It will be very useful to me before each backup of the evolution of my system.
Re: Bash command to check system integrity ?
One more thing...
Do you know how I do to unmount my partition ?
Because hot it's impossible. And the recoverymode also does not want.
Maybe from a live boot ?
Do you know how I do to unmount my partition ?
Because hot it's impossible. And the recoverymode also does not want.
Maybe from a live boot ?
Re: Bash command to check system integrity ?
Yes, live boot will work.
tune2fs
also works: it will do fsck
right before mounting and booting. You can't unmount it when the system is already booted on that file system. All the other file systems (the ones that don't have the root /
) can be unmounted. You can click on their triangle icons in the file manager:
The Terminal command is umount
:
Code: Select all
➜ tldr umount
umount
Unlink a filesystem from its mount point, making it no longer accessible.A filesystem cannot be unmounted when it is busy.More information: https://manned.org/umount.8.
- Unmount a filesystem, by passing the path to the source it is mounted from:
umount {{path/to/device_file}}
- Unmount a filesystem, by passing the path to the target where it is mounted:
umount {{path/to/mounted_directory}}
- Unmount all mounted filesystems (except the proc filesystem):
umount -a
Re: Bash command to check system integrity ?
How do I run Tune2fs ?
Hot or before boot ?
Because I didn't see any way to launch a pre-boot terminal...
Hot or before boot ?
Because I didn't see any way to launch a pre-boot terminal...
Re: Bash command to check system integrity ?
You misunderstood. Tune2fs itself does not do a file system check, but it enables you to set a frequency for automatic execution. As with the command I gave you the check gets done at boot time and anything different is impossible for partitions, which are needed for the system (at least the system partition). Several years ago regularly checks got done by default, but since some years this is assumed as senseless and only time consuming. If you really think, that regular checks are needed, I would no longer trust the hardware. Checks cannot prevent, that the hardware fails.
Re: Bash command to check system integrity ?
Aaah ok, ok thank you. I didn't understand, yes.
No, but it's just to check my system sometimes before making a backup.
I'm going to do this in live boot. It will be very good.
Thanks again.
No, but it's just to check my system sometimes before making a backup.
I'm going to do this in live boot. It will be very good.
Thanks again.
Re: [ SOLVED ] Bash command to check system integrity ?
Perhaps you are interested to read this: viewtopic.php?t=393884
Re: [ SOLVED ] Bash command to check system integrity ?
Thanks Cosmo, i will look.
At the same time I was looking for commands to specifically check the integrity of my software, not hardware.
The hardware can fail over time, I know, and the software also because of the hardware, precisely.
Just to make sure that my software is integrated to migrate it from hardware to hardware over the years.
So. Thanks again...
At the same time I was looking for commands to specifically check the integrity of my software, not hardware.
The hardware can fail over time, I know, and the software also because of the hardware, precisely.
Just to make sure that my software is integrated to migrate it from hardware to hardware over the years.
So. Thanks again...