mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-30 02:40:11 +08:00
Merge pull request #1480 from Vic020/master
Translated :Check Hard drive for bad sectors or bad blocks in linux
This commit is contained in:
commit
33fc882bde
@ -1,46 +0,0 @@
|
|||||||
Vic020
|
|
||||||
|
|
||||||
Check Hard drive for bad sectors or bad blocks in linux
|
|
||||||
================================================================================
|
|
||||||
**badblocks** is the command or utility in linux like operating system which can **scan** or test our **hard disk** and **external drive** for **bad sectors**. Bad sectors or **bad blocks** is the space of the disk which can't be used due to the **permanent damage** or OS is unable to access it.
|
|
||||||
|
|
||||||
Badblocks command will detect all **bad blocks(bad sectors)** on our hard disk and save them in a text file so that we can use it with **e2fsck** to configure Operating System(OS) to not store our data on these damaged sectors.
|
|
||||||
|
|
||||||
### Step:1 Use fdisk command to identify your hard drive info ###
|
|
||||||
|
|
||||||
# sudo fdisk -l
|
|
||||||
|
|
||||||
### Step:2 Scan your hard drive for Bad Sectors or Bad Blocks ###
|
|
||||||
|
|
||||||
# sudo badblocks -v /dev/sdb > /tmp/bad-blocks.txt
|
|
||||||
|
|
||||||
Just replace “/dev/sdb” with your own hard disk / partition. When we execute above command a text file “bad-blocks” will be created under /tmp , which will contains all bad blocks.
|
|
||||||
|
|
||||||
Example :
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### Step:3 Inform OS not to use bad blocks for storing data ###
|
|
||||||
|
|
||||||
Once the scanning is completed , if the bad sectors are reported , then use file “bad-blocks.txt” with e2fsck command and force OS not to use these bad blocks for storing data.
|
|
||||||
|
|
||||||
# sudo e2fsck -l /tmp/bad-blocks.txt /dev/sdb
|
|
||||||
|
|
||||||
Note : Before running e2fsck command , you just make sure the drive is not mounted.
|
|
||||||
|
|
||||||
For any futher help on badblocks & e2fsck command , read their man pages
|
|
||||||
|
|
||||||
# man badblocks
|
|
||||||
# man e2fsck
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: http://www.linuxtechi.com/check-hard-drive-for-bad-sector-linux/
|
|
||||||
|
|
||||||
作者:[Pradeep Kumar][a]
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]:http://www.linuxtechi.com/author/pradeep/
|
|
@ -0,0 +1,44 @@
|
|||||||
|
检查linux中的损坏的扇区和区块
|
||||||
|
================================================================================
|
||||||
|
**badblocks**是linux及其类似的操作系统中,扫描检查硬盘和外部设备损坏扇区的命令工具。损坏的扇区或者损坏的区块是硬盘中因为永久损坏或者是操作系统不能读取的空间。
|
||||||
|
|
||||||
|
Badblocks命令可以探测硬盘中所有损坏的扇区或者区块并将结果保存在一个文本文档中,这样,我们就可以使用**e2fsck**命令来配置操作系统不在这些损坏的扇区中存储。
|
||||||
|
|
||||||
|
### 步骤:1 使用fdisk识别硬盘信息 ###
|
||||||
|
|
||||||
|
# sudo fdisk -l
|
||||||
|
|
||||||
|
### 步骤:2 扫描硬盘的损坏扇区或区块 ###
|
||||||
|
|
||||||
|
# sudo badblocks -v /dev/sdb > /tmp/bad-blocks.txt
|
||||||
|
|
||||||
|
只需将“/dev/sdb”替换为自己机器的/分区。执行完成上述命令后,一个名为“bad-blocks”文本文档将会在/tmp下创建,它将包含所有的损坏区块。
|
||||||
|
|
||||||
|
例如:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### 步骤:3 告诉操作系统不要使用损坏区块存储 ###
|
||||||
|
|
||||||
|
扫描完成后,如果损坏区块被发现了,然后通过e2fsck命令使用“bad-blocks.txt”,强迫操作系统不使用这些损坏的区块存储数据。
|
||||||
|
|
||||||
|
# sudo e2fsck -l /tmp/bad-blocks.txt /dev/sdb
|
||||||
|
|
||||||
|
注意:在运行e2fsck命令前,请保证设备没有被挂载。
|
||||||
|
|
||||||
|
关于badblocks和e2fsck命令的更多帮助,请参考下列man页面
|
||||||
|
|
||||||
|
# man badblocks
|
||||||
|
# man e2fsck
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: http://www.linuxtechi.com/check-hard-drive-for-bad-sector-linux/
|
||||||
|
|
||||||
|
作者:[Pradeep Kumar][a]
|
||||||
|
译者:[Vic___](http://www.vicyu.net)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]:http://www.linuxtechi.com/author/pradeep/
|
Loading…
Reference in New Issue
Block a user