4

My NAS HDD has failed to boot. So I decided to check and mark badblocks HDD via following commands attaching to Ubuntu.

sudo badblocks -sv /dev/sdb > /tmp/bads.txt

sudo e2fsck -l /tmp/bads.txt /dev/sdb

Unfortunately, I receive the following error. Would you please inform how I can mark the bad blocks discovered by badblocks command.

e2fsck 1.44.1 (24-Mar-2018)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/sdb

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
 or
        e2fsck -b 32768 <device>

Found a gpt partition table in /dev/sdb

1 Answer 1

4

You ran e2fsck on the whole drive not on the partition where the filesystem lies.

Also you should note that you should use the same blocksize with badblock than the fs uses.

So to achieve what you want in a much simpler way, you can simply run:

sudo fsck -vck /dev/sdbx

This will run a filesystem check but also check for badblocks and add them to the filesystem.

You can double the c to run sudo fsck -vcck /dev/sdbx instead to force a non-desctructive read-write badblock test.

Don't forget to change the x to the number of your partition. And the b to something else if the drive is attached with a different name.

Assuming your filesystem is ext4 (or ext3 or ext2 ...)

2
  • 2
    Should your first sentence be the opposite? "You run e2fsck on the whole drive not on the partition ..." But then your example runs fsck on a partition (sdbx) not the drive (sdb). Perhaps the first sentence is meant to read "You ran ..."? May 2, 2021 at 17:07
  • I tried this with the read-write test, took many hours and after finishing I started copying big files to the new filesystem and still got errors. Not sure if it's a problem of the command or the disk, but anyway in my case it was better to throw the disk away
    – golimar
    Jan 16, 2023 at 10:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .