Comments on: How to Check Hard Drive for Bad Sectors or Blocks in Linux https://www.linuxtechi.com/check-hard-drive-for-bad-sector-linux/ Wed, 04 Oct 2023 15:33:07 +0000 hourly 1 By: K T https://www.linuxtechi.com/check-hard-drive-for-bad-sector-linux/#comment-59650 Wed, 04 Oct 2023 15:33:07 +0000 http://www.linuxtechi.com/?p=2378#comment-59650 In reply to Виктор.

This is Linux, not Windows.

]]>
By: Kevin Smith https://www.linuxtechi.com/check-hard-drive-for-bad-sector-linux/#comment-20276 Mon, 18 May 2020 20:12:51 +0000 http://www.linuxtechi.com/?p=2378#comment-20276 Most filesystems these days use 4096 byte blocks.

Using the commands as directed here will make a hash of your filesystem.

As advised in the current man page for badblocks
“Important note: If the output of badblocks is going to be fed to the
e2fsck or mke2fs programs, it is important that the block size is prop‐
erly specified, since the block numbers which are generated are very
dependent on the block size in use by the filesystem. For this reason,
it is strongly recommended that users not run badblocks directly, but
rather use the -c option of the e2fsck and mke2fs programs”

Following the example on this page the command would be: es2fsck -c /dev/sdb

]]>
By: techhead https://www.linuxtechi.com/check-hard-drive-for-bad-sector-linux/#comment-3545 Thu, 01 Mar 2018 13:17:00 +0000 http://www.linuxtechi.com/?p=2378#comment-3545 What command just to report sectors or drive health.
Using an old pata drive that has not been used in some time to run Linux
peppermint 64x.
From my experience with windows os’s and smart, one bad sector can trash
a program or even the entire drive.

]]>
By: Stoat https://www.linuxtechi.com/check-hard-drive-for-bad-sector-linux/#comment-141 Mon, 28 Nov 2016 13:17:40 +0000 http://www.linuxtechi.com/?p=2378#comment-141 DO NOT DO THIS!

The ONLY reason you should ever create a bad blocks table is to send commands to the drivbe to tell it to repair the sectors

ATA and scsi drives are supposed to map out bad blocks. You can force the issue by wirting 0x00 to the sector (or use hdparm–repair-sector)

Take note of smartctl -A /dev/drive returns – in particular the bad sector (mapped out sectors) and pending sectors (probably bad but not mapped out) values – if the bad sector normalised value (not the raw value) is below the threshold then you need to replace the drive – NOW.

If you have large numbers of pending bad sectors then you’ll need to identify them and write zeros to them to allow the drive to fix or map them out (perfectly sectors can get marked as pending due to vibration issues, amongst other things).

Badblocks -svn will do this (unmount the partition first!), or if the partition is trashable/part of a raidset, hdparm –repair-sector and then rescan/reformat afterwards.

If bad sectors are not being mapped out then the drive needs to be replaced immediately. It’s probably out of spares (you’ll see this with smartctl -A) or about to fail.

]]>
By: cipher https://www.linuxtechi.com/check-hard-drive-for-bad-sector-linux/#comment-140 Mon, 07 Dec 2015 16:24:46 +0000 http://www.linuxtechi.com/?p=2378#comment-140 You don’t need to run badblocks first. That’s a waste of time. Just use the e2fsck executable to run it for you with the -c option…

# sudo e2fsck -c /dev/sdb

This lets you avoid creating an unnecessary file, especially when you’re booting to an optical drive and don’t want to write to the hard drive you’re testing.

]]>
By: deco https://www.linuxtechi.com/check-hard-drive-for-bad-sector-linux/#comment-139 Fri, 30 Oct 2015 19:14:18 +0000 http://www.linuxtechi.com/?p=2378#comment-139 This has given me an idea of creating this script

#!/bin/sh
minsize=0
target=”/tmp/bad-blocks.txt”
for disc in `fdisk -l | grep ‘^/’ | awk ‘{ print $1 }’`; do
badblocks -v $disc > “$target”
tam=$(du -k “$target” | cut -f 1)
if [ $tam -eq $minsize ]; then
echo “no badblocks on $disc”
else
echo “badblock(s) found(s) on $disc”
fi
done

]]>
By: Виктор https://www.linuxtechi.com/check-hard-drive-for-bad-sector-linux/#comment-138 Thu, 03 Sep 2015 18:29:07 +0000 http://www.linuxtechi.com/?p=2378#comment-138 From time to time, it is a good practice to check your hard drive for errors using Windows CHKDSK or Check Disk.

]]>
By: Bernardo Verda https://www.linuxtechi.com/check-hard-drive-for-bad-sector-linux/#comment-137 Fri, 15 Aug 2014 06:56:03 +0000 http://www.linuxtechi.com/?p=2378#comment-137 Don’t modern harddrives already have all this already — as built in functionality?

(access via smartctl)

$ apropos smartctl
smartctl (8) – Control and Monitor Utility for SMART Disks

]]>
By: David Wood https://www.linuxtechi.com/check-hard-drive-for-bad-sector-linux/#comment-136 Thu, 14 Aug 2014 02:51:33 +0000 http://www.linuxtechi.com/?p=2378#comment-136 don’t you need to make sure the blocks are not allocated to a file or swap etc?

]]>