Table of Contents
If you want to send us your comments, please do so. Thanks
More on comments
Check disks and filesystems
e2fsck general
A swap partition can not be tested
The /tmp partition test will complain about the omission of the lost+found directory. Do not have it created
Check for bad blocks
This also works on a fully wiped hard disk without any filesystem. Like a disk filled with 0x00's
If there are partitions on the drive you need to test them one by one. e2fsck -c /dev/sd* does not work
When a bad block is found cancel (CTRL-c) e2fsck or mkfs.ext4 and use an other tool like Spinrite to try to recover the data
When testing a SSD only use one -c since a double -c -c (read and write test) will wear the drive. Use -c -c only if you really want to test the write ability of the SSD
n: device letter (a,b,c,…)
x: partition number (1,2,3,…)
e2fsck -c -c -v -f /dev/sdnx mkfs.ext4 -c -c -v -f /dev/sdxn
Check filesystem
Use e2fsck to check and repair a Linux filesystem like ext2, ext3, ext4
Make sure the filesystem is unmounted
Option | Explanation |
---|---|
-c | Check for bad blocks, read only |
-cc | Check for bad blocks, read write |
-C | Display completion/progress bars for those filesystem checkers (currently only for ext[234]) which support them |
-f | Force checking even if the file system seems clean |
-n | Open the filesystem read-only. For non interactive use. -p and -y options are not permitted |
-p | Automatically repair. -n and -y options are not permitted |
-t | Print timing statistics |
-tt | Print timing statistics on a pass by pass base |
-v | Verbose |
-y | Assume an answer of `yes' to all questions. This allows e2fsck to be used non-interactively like with cron. It is forbidden to use this option at the same time as the -n or -p options |
Examples
e2fsck -v -t /dev/sda1
In cron use (make sure the filesystem is unmounted)
e2fsck -n -v -t /dev/sda1
Obsolete
Use fsck to check and repair a Linux filesystem like ext2, ext3, ext4. Example
fsck -C -l -r -V -t ext4 /dev/sda1
Errors
Command: e2fsck /dev/sda
e2fsck /dev/sda e2fsck 1.46.2 (28-Feb-2021) ext2fs_open2: Bad magic number in super-block
Solution: Do not check the device (sda) but the partition (sda1): e2fsck /dev/sda1
DOS
Use dosfsck = fsck.msdos = fsck.vfat to check and repair MS-DOS filesystems like vfat
Option | Explanation | |
---|---|---|
-a | Automatically repair the filesystem. No user intervention is necessary. Whenever there is more than one method to solve a problem, the least destructive approach is used | |
-b | Make read-only boot sector check | |
-f | Salvage unused cluster chains to files. By default, unused clusters are added to the free disk space except in auto mode (-a) | |
-l | List path names of files being processed | |
-r | Interactively repair the filesystem. The user is asked for advice whenever there is more than one approach to fix an inconsistency. This is the default mode and the option is only retained for backwards compatibility | |
-t | Mark unreadable clusters as bad | |
-v | Verbose mode. Generates slightly more output | |
-V | Perform a verification pass. The filesystem check is repeated after the first run. The second pass should never report any fixable errors. It may take considerably longer than the first pass, because the first pass may have generated long list of modifications that have to be scanned for each disk read. | |
-w | Write changes to disk immediately | |
-y | Same as -a (automatically repair filesystem) for compatibility with other fsck tools |
[device] is something like sde
dosfsck -bflrtv /dev/[device] dosfsck /dev/[device]
Second command example:
An unreadable diskette. Sector 0 is not readable.
The diskette is beyond repair. It can not be formatted with a command like mkdosfs -F 12 -n LABEL -v /dev/sdb
The output of the following command:
$ dosfsck /dev/sdb fsck.fat 4.2 (2021-01-31) Got 0 bytes instead of 512 at 0
A normal functioning diskette
$ dosfsck /dev/sdb fsck.fat 4.2 (2021-01-31) /dev/sdb: 9 files, 458/2847 clusters
Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy
RSS
Disclaimer
Privacy statement
Bugs statement
Cookies
Copyright © : 2014 - 2024 Webevaluation.nl and the authors
Changes reserved.