search
Homephp教程PHP开发How to detect bad sectors and blocks on your hard drive on Linux

Let’s start with the definition of bad sectors and bad blocks. They are parts of a disk or flash memory that can no longer be read or written, usually due to specific physical damage to the disk surface or failure of the flash memory transistors.

As bad sectors continue to accumulate, they can have unpleasant or damaging effects on your disk or flash memory capacity, and may even cause hardware failure.

At the same time, it is also important to note that the presence of bad blocks is a warning that you should start thinking about buying a new disk, or simply mark the bad blocks as unusable.

So, in this article, we go through a few necessary steps to use a specific disk scanning tool to enable you to determine whether a Linux disk or flash memory has bad sectors.

Here are the steps:

Use the Bad Block Tool to check for bad sectors on Linux

The Bad Block Tool allows users to scan the device to check for bad sectors or blocks. The device can be a disk or external disk and is represented by a file such as /dev/sdc.

First, execute the fdisk command with superuser privileges to display the information of all your disks or flash drives and their partition information:

$ sudo fdisk -l

How to detect bad sectors and blocks on your hard drive on Linux

List Linux file system partitions


Then check you with the following command Bad sectors/bad blocks on the Linux hard disk:

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

How to detect bad sectors and blocks on your hard drive on Linux

Scan the hard disk for bad sectors on Linux


In the above command, badblocks scans the device /dev/sda10 (remember to specify your actual device), The -v option causes it to display details of the operation. In addition, output redirection is used here to redirect the operation results to the file badsectors.txt.

If you find any bad sectors on your disk, unmount the disk and tell the system not to write data to the reported sectors as below.

You need to execute the e2fsck (for ext2/ext3/ext4 file system) or fsck command. The badsectors.txt file and device file are also required in the command.

The -l option tells the command to add the sector numbers listed in the specified file badsectors.txt to the bad block list.

------------ 针对 for ext2/ext3/ext4 文件系统 ------------  
$ sudo e2fsck -l badsectors.txt /dev/sda10  
或  
------------ 针对其它文件系统 ------------  
$ sudo fsck -l badsectors.txt /dev/sda10

Use Smartmontools tool to scan for bad sectors on Linux

This method is suitable for modern disks (ATA/SATA and SCSI/SAS hard drives with S.M.A.R.T (Self-Monitoring, Analysis and Reporting Technology) system) and solid-state drives) are more reliable and efficient. S.M.A.R.T systems can help detect, report, and possibly record their health so you can identify any possible hardware failures.

You can install smartmontools using the following command:

------------ 在基于 Debian/Ubuntu 的系统上 ------------
$ sudo apt-get install smartmontools
------------ 在基于 RHEL/CentOS 的系统上 ------------
$ sudo yum install smartmontools

After the installation is complete, use smartctl to control the disk-integrated S.M.A.R.T system. You can view its manual or help like this:

$ man smartctl$ smartctl -h

Then execute the smartctrl command and specify your device as a parameter in the command. The following command includes the parameter -H or --health to display the SMART overall health self-assessment test results.

$ sudo smartctl -H /dev/sda10

How to detect bad sectors and blocks on your hard drive on Linux

Check Linux hard drive health


The above results indicate that your hard drive is healthy and hardware failure is unlikely to occur in the near future.

To get an overview of disk information, use the -a or --all option to display all SMART information about the disk, and -x or --xall to display all SMART information about the disk as well as non-SMART information.


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.