linux修复磁盘坏扇区,如何找出Linux硬盘上的坏扇区

Badblocks是一个Linux实用程序,用于评估磁盘电源上不正常的扇区。它创建了可以与其他应用程序(例如mkfs)一起使用的那些扇区的列表,因此它们在某些时候不会被使用,因此不会破坏数据。本文介绍-–如何找出不良部门。Linux硬盘上的坏块。

要获取有关计算机上的块设备的信息,请使用以下命令–$ lsblk

检查坏扇区

有很多复杂的方法可以找到坏块。最常用的方法如下所示-

要获取有关坏块状态的信息,请在Ubuntu上安装以下软件包,如下所示–$ sudo apt-get install smartmontools

样本输出应该像这样-Reading package lists... Done

Building dependency tree

Reading state information... Done

The following additional packages will be installed:

s-nail

Suggested packages:

exim4 | mail-transport-agent gsmartcontrol smart-notifier

The following NEW packages will be installed:

s-nail smartmontools

0 upgraded, 2 newly installed, 0 to remove and 284 not upgraded.

Need to get 795 kB of archives.

After this operation, 2,398 kB of additional disk space will be used.

Do you want to continue? [Y/n] y

Get:1 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 s-nail amd64 14.8.6-1 [353 kB]

Get:2 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 smartmontools amd64 6.4+svn4214-1 [442 kB]

Fetched 795 kB in 1s (541 kB/s)

Selecting previously unselected package s-nail.

(Reading database ... 174772 files and directories currently installed.)

Preparing to unpack .../s-nail_14.8.6-1_amd64.deb ...

Unpacking s-nail (14.8.6-1) ...

.............................................................................................

要获取有关smartctl的更多信息,请使用以下命令–$ smartctl -h

样本输出应如下所示–smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-31-generic] (local build)

Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

Usage: smartctl [options] device

============================================ SHOW INFORMATION OPTIONS =====

-h, --help, --usage

Display this help and exit

-V, --version, --copyright, --license

Print license, copyright, and version information and exit

-i, --info

Show identity information for device

--identify[=[w][nvb]]

Show words and bits from IDENTIFY DEVICE data (ATA)

-g NAME, --get=NAME

Get device setting: all, aam, apm, lookahead, security, wcache, rcache, wcreorder

-a, --all

Show all SMART information for device

-x, --xall

Show all information for device

--scan

Scan for devices

--scan-open

Scan for devices and try to open each device

================================== SMARTCTL RUN-TIME BEHAVIOR OPTIONS =====

-q TYPE, --quietmode=TYPE (ATA)

Set smartctl quiet mode to one of: errorsonly, silent, noserial

-d TYPE, --device=TYPE

Specify device type to one of: ata, scsi, sat[,auto][,N][+TYPE], usbcypress[,X], usbjmicron[,p][,x][,N],    usbsunplus, marvell, areca,N/E, 3ware,N, hpt,L/M/N, megaraid,N, aacraid,H,L,ID, cciss,N, auto, test

-T TYPE, --tolerance=TYPE (ATA)

Tolerance: normal, conservative, permissive, verypermissive

-b TYPE, --badsum=TYPE (ATA)

Set action on bad checksum to one of: warn, exit, ignore

-r TYPE, --report=TYPE

Report transactions (see man page)

-n MODE, --nocheck=MODE (ATA)

No check if: never, sleep, standby, idle (see man page)

.........................................................................................

验证硬盘运行状况

要验证硬盘的运行状况,请使用以下命令–$ sudo smartctl -H /dev/sda

样本输出应该像这样-smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-31-generic] (local build)

Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===

SMART overall-health self-assessment test result: PASSED

如果以上结果提供了故障信息,请使用以下命令扫描损坏的块。$ sudo badblocks -v /dev/sdb

检查硬盘需要几分钟。就我而言,它给出了以下结果-Checking blocks 0 to 3595263

Checking for bad blocks (read-only test): done

Pass completed, 0 bad blocks found. (0/0/0 errors)

恭喜你!现在,您知道“如何找出不良部门,即。Linux硬盘上的坏块?”。在我们的下一篇Linux文章中,我们将详细了解这些类型的命令。继续阅读!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值