How To Check For Bad Blocks On A Linux Pc Hard Drive (and Why You Shouldn't Wait To Do It)

Trending 1 month ago
Microsoft Surface Laptop successful Sapphire
Kyle Kucharski/ZDNET

I've had it hap before. Back erstwhile drives consisted of spinning, magnetic platters, that dreaded "tick" was a judge motion a difficult thrust was failing. Once upon a nightmare scenario, I waited excessively precocious and coiled up losing everything connected my drive. Sure, I could person recovered that data, but astatine a beautiful precocious monetary cost.

Also: The first 5 Linux commands each caller personification should learn

Since then, I've ever been vigilant astir checking for bad blocks and sectors connected hard drives.

What is simply a bad block?

Simply put, a bad artifact is 1 that cannot beryllium publication aliases written to. This tin hap because of beingness harm to nan thrust aliases failing transistors connected flash representation (think SSDs). When a artifact goes bad, it's not usable. Too galore bad blocks, and nan thrust will fail.

You don't want that.

Also: Thinking astir switching to Linux? 10 things you request to know

Before nan bad blocks return you down, you should cheque for them. If you don't, you could suffer out. Let's check.

How to cheque for bad blocks connected an older thrust

What you'll need: The only things you'll request for this are a moving lawsuit of Linux and a personification pinch sudo privileges.

The first point to do is find nan sanction of your thrust and partition. To do that, you'll request to usage nan fdisk inferior pinch nan command:

Show more

sudo fdisk -l

From nan output of that, you should spot nan sanction of nan thrust you request to scan. The sanction will astir apt beryllium successful nan shape of /dev/sda1.

Now it's clip to scan for those blocks. The instrumentality you'll usage for this is aptly named badblocks and is installed connected astir Linux distributions (so you don't person to instal anything). Let's opportunity your thrust sanction is /dev/sda1. To scan for bad blocks, nan bid would be:

Show more

sudo badblocks -v /dev/sda1 > badblocks.txt

The supra bid outputs nan results of nan bid to nan record badblocks.txt. You'll besides spot nan output of nan bid successful nan terminal window.

Also: There's a caller coolest Linux distribution fresh to wow you

If badblocks study that location are, successful fact, bad blocks connected your drive, you'll want to people them arsenic unusable. If your OS attempts to usage a bad artifact aliases sector, it could origin problems, and this avoids that.

Also: The champion Linux distros for beginners

To do that, we'll employment nan record created by badblocks and usage nan e2fsck command. This only useful connected nan ext2, ext3, and ext4 filesystem types. The bid utilized for this (sticking pinch nan illustration sanction we've been using) would be:

Show more

sudo e2fsck -l badblocks.txt /dev/sda1

If your record strategy is of a different type, you'll usage nan fsck bid for illustration so:

sudo fsck -l badblocks.txt /dev/sda1

How to cheque for bad blocks connected a modern thrust

The bully news is that you don't person to people bad blocks connected an SSD, but it's bully to regularly cheque nan wellness of nan drive.

If your strategy uses an SSD, you'll request to usage a instrumentality called smartmontools. Chances are that this exertion isn't installed connected your system.

1. Install smartmontools

To instal smartmontools connected a Debian/Ubuntu-based distribution, rumor nan command:

sudo apt-get instal smartmontools -y

Also: 6 reasons why I've stuck pinch Ubuntu-based Linux distros for nan past 20 years

On Fedora-based distributions, that bid would be:

sudo dnf instal smartmontools -y

2. Run a wellness cheque

Now that smartmontools has been installed, tally a wellness cheque pinch nan command:

sudo smartctl -H /dev/sda1

And location you go. You now person either marked those blocks arsenic bad, aliases you cognize nan wide wellness of your SSD.

Also: 10 Linux apps I instal connected each caller instrumentality (and why you should, too)

Get nan morning's apical stories successful your inbox each time pinch our Tech Today newsletter.

More