User Tools

Site Tools


check_disks_and_filesystems

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

OptionExplanation
-cCheck for bad blocks, read only
-ccCheck for bad blocks, read write
-CDisplay completion/progress bars for those filesystem checkers (currently only for ext[234]) which support them
-fForce checking even if the file system seems clean
-nOpen the filesystem read-only. For non interactive use. -p and -y options are not permitted
-pAutomatically repair. -n and -y options are not permitted
-tPrint timing statistics
-ttPrint timing statistics on a pass by pass base
-vVerbose
-yAssume 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

OptionExplanation
-aAutomatically 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
-bMake read-only boot sector check
-fSalvage unused cluster chains to files. By default, unused clusters are added to the free disk space except in auto mode (-a)
-lList path names of files being processed
-rInteractively 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
-tMark unreadable clusters as bad
-vVerbose mode. Generates slightly more output
-VPerform 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.
-wWrite changes to disk immediately
-ySame 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.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
check_disks_and_filesystems.txt · Last modified: 14-02-2024 19:21 by wim