Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.

com/check-linux-hard-disk-bad-sectors-bad-blocks/

RedHat RHCSA and RHCE Certi�cation Preparation Guide - Get This Book

 Menu

 Menu 

How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux

Aaron Kili Last Updated: October 26, 2016 Linux Commands 31 Comments

Nunca foi tão fácil economizar dinheiro nas


suas viagens. Experimente o inDriver VISITAR SITE
agora.

Let us start by de�ning a bad sector/block, it’s a section on a disk drive or �ash memory that can not be read from or
written to anymore, as a result of a �xed physical damage on the disk surface or failed �ash memory transistors.

As bad sectors continue to accumulate, they can undesirably or destructively affect your disk drive or �ash memory
capacity or even lead to a possible hardware failure.

It is also important to note that the presence of bad blocks should alert you to start thinking of getting a new disk
drive or simply mark the bad blocks as unusable.

Therefore, in this article, we will go through the necessary steps that can enable you determine the presence or
absence of bad sectors on your Linux disk drive or �ash memory using certain disk scanning utilities.

That said, below are the methods:

Check Bad Sectors in Linux Disks Using badblocks Tool

program enables users to scan a device for bad sectors or blocks. The device can be a hard disk or an

1 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

Firstly, use the fdisk command with superuser privileges to display information about all your disk drives or �ash
memory plus their partitions:

$ sudo fdisk -l

List Linux Filesystem Partitions

Then scan your Linux disk drive to check for bad sectors/blocks by typing:

$ sudo badblocks -v /dev/sda10 > badsectors.txt

Scan Hard Disk Bad Sectors in Linux

In the command above, badblocks is scanning device /dev/sda10 (remember to specify your actual device) with the
-v enabling it to display details of the operation. In addition, the results of the operation are stored in the �le
badsectors.txt by means of output redirection.

In case you discover any bad sectors on your disk drive, unmount the disk and instruct the operating system not to
write to the reported sectors as follows.

You will need to employ e2fsck (for ext2/ext3/ext4 �le systems) or fsck command with the badsectors.txt �le and the
device �le as in the command below.

The -l option tells the command to add the block numbers listed in the �le speci�ed by �lename (badsectors.txt

to the list of bad blocks.

2 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

------------ Specifically for ext2/ext3/ext4 file-systems ------------


$ sudo e2fsck -l badsectors.txt /dev/sda10

OR

------------ For other file-systems ------------


$ sudo fsck -l badsectors.txt /dev/sda10

Scan Bad Sectors on Linux Disk Using Smartmontools


This method is more reliable and ef�cient for modern disks (ATA/SATA and SCSI/SAS hard drives and solid-state
drives) which ship in with a S.M.A.R.T (Self-Monitoring, Analysis and Reporting Technology) system that helps
detect, report and possibly log their health status, so that you can �gure out any impending hardware failures.

You can install smartmontools by running the command below:

------------ On Debian/Ubuntu based systems ------------


$ sudo apt-get install smartmontools

------------ On RHEL/CentOS based systems ------------


$ sudo yum install smartmontools

Once the installation is complete, use smartctl which controls the S.M.A.R.T system integrated into a disk. You can
look through its man page or help page as follows:

$ man smartctl
$ smartctl -h

Now execute the smartctrl command and name your speci�c device as an argument as in the following command,
the �ag -H or --health is included to display the SMART overall health self-assessment test result.

$ sudo smartctl -H /dev/sda10

3 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

Check Linux Hard Disk Health

The result above indicates that your hard disk is healthy, and may not experience hardware failures any soon.

For an overview of disk information, use the -a or --all option to print out all SMART information concerning a
disk and -x or --xall which displays all SMART and non-SMART information about a disk.

In this tutorial, we covered a very important topic concerning disk drive health diagnostics, you can reach us via the
feedback section below to share your thoughts or ask any questions and remember to always stay connected to
Tecmint.

 Linux Tricks

 3 Ways to Delete All Files in a Directory Except One Deal: Become a Java Ninja with This 4-Course Novice to
or Few Files with Extensions Expert Java Bundle 

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts?
do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles,
Guides and Books on the web. Millions of people visit TecMint! to search or browse the

thousands of published articles available FREELY to all.

4 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of
appreciation.

We are thankful for your never ending support.

Related Posts

5 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

How to Switch (su) to Another User Account without Password

6 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

How to Force cp Command to Overwrite without Con�rmation

How to Add or Remove a User from a Group in Linux

7 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

Install Linux from USB Device or Boot into Live Mode Using Unetbootin and dd Command

6 Best CLI Tools to Search Plain-Text Data Using Regular Expressions

8 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

How to Install tar in CentOS, RHEL, and Fedora

31 thoughts on “How to Check Bad Sectors or Bad Blocks on Hard


Disk in Linux”
← Older Comments

umibozu
October 1, 2020 at 11:18 pm

Nicely done, thank you.

Reply

breng
September 29, 2020 at 9:07 am

How do you mount Ubuntu ISO in Ram in the grub boot menu?

Reply

Ravi Saive
September 29, 2020 at 10:55 am

@Breng,

Check this article – How to Run Any Linux Distribution Directly from Hard Disk in Ubuntu Using Grub Menu

Reply

Michael Macha
June 26, 2020 at 9:52 pm


I was doing this for a slightly impaired external drive, and it worked �ne up until the actual call to fsck. Using

9 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

your command verbatim,

$ sudo e2fsck -l badsectors.txt /dev/sda1

gave me a message that “fsck: the -l option can be used with one device only — ignore“; apparently
because it was interpreting the text �le as an additional device. However, thinking it over,

# sudo fsck -t ntfs -l < ~/badsectors.txt /dev/sda1

with an opening angle bracket before the �le, in case it gets edited out) worked perfectly. I think you may
have lost a symbol to HTML formatting there.

Reply

Aaron Kili
June 29, 2020 at 10:39 am

@Michael

Okay, many thanks for sharing this. Allow us to check this out.

Reply

J. Zumwalt
June 5, 2020 at 10:00 am

This wont work on large partitions (here is an example).

# df
Device Start End Sectors Size Type
/dev/sda6 614612992 11618643967 11004030976 5.1T Linux �lesystem

# badblocks -v /dev/sda6 > badsectors_sda6.txt

badblocks: Value too large for de�ned data type invalid end block (5502015488): must be 32-bit value

Reply

Aaron Kili

June 5, 2020 at 11:16 am

10 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

@J

Oops, we will investigate this further. Thanks for the useful feedback.

Reply

Antonio
May 12, 2020 at 2:36 am

Very useful information! Help me to recover from an “Emergency mode” on Opensuse. Thanks

Reply

Jonathan
April 29, 2020 at 9:09 pm

Whenever I try to start my pc, it shows like I/O buffer error, logical block error fsck exited with status code 8,
Could this be a zero-length partition? I am completely new to it. So please help me I had some important
documents in there. I don’t wanna format my hard drive as well. I would be really grateful if anyone could
help me

Reply

Aaron Kili
April 30, 2020 at 11:15 am

@Jonathen

With which �le system type was it formatted?

Reply

Jonathan
April 30, 2020 at 2:46 pm

/dev/sda1 I don’t wanna lose any of the data as some are very important. I hadn’t formatted anything
before. So please help me �gure it out.

11 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

Reply

Kyosuke
May 12, 2020 at 7:04 pm

I think what Aaron means is which formatted system have you use for your device /dev/sda1?

You can use this command and look at column Type.

$ df -Th /dev/sda1

Reply

← Older Comments

Got something to say? Join the discussion.


Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all
comments are moderated and your email address will NOT be published.

Name *

Email *

Website

Save my name, email, and website in this browser for the next time I comment.

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Post Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

12 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

Over 3,500,000+ Readers

A Beginners Guide To Learn Linux for Free [with Examples]

Red Hat RHCSA/RHCE 8 Certi�cation Study Guide [eBooks]

Linux Foundation LFCS and LFCE Certi�cation Study Guide [eBooks]

13 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

Learn Linux Commands and Tools

How to Fix “failed to mount /etc/fstab” Error in Linux

How to Generate/Encrypt/Decrypt Random Passwords in Linux

How to Count Word Occurrences in a Text File

How to Delete User Accounts with Home Directory in Linux

Rename – A Command Line Tool For Renaming Multiple Files in Linux

How to Run or Repeat a Linux Command Every X Seconds Forever

14 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

If You Appreciate What We Do Here On TecMint, You Should Consider:

Linux Server Monitoring Tools

Petiti – An Open Source Log Analysis Tool for Linux SysAdmins

How to Monitor MySQL/MariaDB Databases using Netdata on CentOS 7

BpyTop – Resource Monitoring Tool for Linux

Limit CPU Usage of a Process in Linux with CPULimit Tool

iftop – A Real Time Linux Network Bandwidth Monitoring Tool

Hegemon – A Modular System Monitoring Tool for Linux


15 of 16 04/11/2020 09:19
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

Learn Linux Tricks & Tips

How to Force User to Change Password at Next Login in Linux

Bash-it – Bash Framework to Control Your Scripts and Aliases

Learn How to Set Your $PATH Variables Permanently in Linux

How to Show Asterisks While Typing Sudo Password in Linux

How to Enable, Disable and Install Yum Plug-ins

Find Top 10 IP Addresses Accessing Your Apache Web Server

Best Linux Tools

10 Best Clipboard Managers for Linux

5 Best Modern Linux ‘init’ Systems (1992-2015)

8 Best Video Editing Softwares I Discovered for Linux

11 Best Graphical Git Clients and Git Repository Viewers for Linux

10 Best Markdown Editors for Linux

10 Best Media Server Software for Linux in 2019

Donate to TecMint Contact Us Advertise on TecMint Linux Services Copyright Policy Privacy Policy Career

Sponsored Post

Tecmint: Linux Howtos, Tutorials & Guides © 2020. All Rights Reserved.
The material in this site cannot be republished either online or of�ine, without our permission.

Hosting Sponsored by : Linode Cloud Hosting

16 of 16 04/11/2020 09:19

You might also like