Empowering you to understand your world

How To Check For Bad Sectors On Your Hard Drive (A Useful Health Check)

As always, you should ensure that your data is backed up before proceeding, especially if your hard drive is aging.

Numerous people have been caught by sudden hard drive failures. Considering the fact that you are unlikely to get a warning in time, you need to back up your data on a regular basis.

Before proceeding, scanning for bad sectors only identifies platter faults (faults on the disks inside the drive). Hard drive logic boards, heads, actuators, among other parts can fail as well (even if your platters are in good condition). Whether or not there are bad sectors, your data needs to be backed up.

Check For Bad Sectors In Linux: badblocks

If you’re using Linux (whether it’s Fedora or Ubuntu), you can use a program called badblocks, which is likely to be pre-installed on your Linux machine. badblocks is a command-line utility, however it is easy to use.

The first thing you need to do before checking for bad sectors on your hard drive is find the identifier of your drive (‘What the OS labelled it, for example: ‘/dev/sdb’) by typing:

sudo fdisk -l

The output of that command should look similar to this:

Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: B263CA2E-A87M-4A24-9A5C-B76E21231842

Device    Start     End       Sectors    Size    Type
/dev/sdb1 2048      6143      4096       2M      BIOS boot
/dev/sdb2 6144      268287    262144     128M    EFI System
/dev/sdb3 268288    1316863   1048576    512M    Linux filesystem
/dev/sdb4 1316864   723671039 722354176  344.5G  Linux filesystem
/dev/sdb5 723671040 725768191 2097152    1G      Linux filesystem
/dev/sdb6 725768192 859963391 134195200  64G     Linux filesystem
/dev/sdb7 859963392 871915519 11952128   5.7G    Linux swap
/dev/sdb8 871915520 976773119 104857600  50G     Linux filesystem

Now, on that drive, you’ll need to identify the partition you want to check for bad blocks from that list (if it is just a partition you’re scanning, you can save some time over scanning the whole drive). The partition number would be called something along the lines of ‘/dev/sdb4’ or another number which varies with installation.

I highlighted the partitions with characteristics that suggest they are your main partitions, such as their size (344.5 GB highlighted in magenta),  and type: “Linux Filesystem”, and of course the device identifier which is the information that badblocks needs.

'/dev/sdb' refers to the hard drive, and '/dev/sdb4' refers to a partition on said drive. If you have multiple hard drives installed, you may see '/dev/sda' and '/dev/sdb' as well.

If the drive you want to check (with those precious photos on it, for example) happened to be ‘/dev/sdb8’, you’d run the following command to do a read-only check on it:

badblocks -s /dev/sdb8

Now wait and see if it displays any bad blocks. If it doesn’t, then it didn’t find any. If you run that command without sudo priviledges (unless you’re logged in as root, which is not recommended) then you’ll get the following error: ‘badblocks: Permission denied while trying to determine device size’. The ‘-s‘ option shows you its progress.

If it detects bad blocks, update your backups more frequently to ensure that you’re ready for when it will fail, or just replace the drive.

Things to keep handy to reduce the risk of data loss:

  1. An external hard drive,  which us in good health and you use only to store your backups, not to transfer data or anything else. This significantly reduces the risk of losing your data if you back up to it regularly and keep it somewhere safe.
  2. A cloud storage account from Google Drive or Microsoft OneDrive for the smaller folders with important documents in them (please ensure you use a secure password for these services). These services can keep an up-to-date backup copy ready for you in case of a failure. This is useful because they back up data more frequently than you can manually, even if you forget.
Share this article
Shareable URL
Prev Post

Panasonic Releases An Upgraded Lumix LX100 Camera

Next Post

GMC Introduces The 2019 Sierra Denali Pickup Truck

Leave a Reply

Read next
Subscribe to our newsletter
Get notified when new content is published