Linux uses the badblocks command to scan hard disk for troubleshooting

Source: Internet
Author: User
Tags erro

Scan your hard disk with Linux operating system commands

In the system "messages" log to see the file system anomalies, the use of Linux operating system commands to check the system partition can quickly locate the hard disk failure.

Precautions

Badblocks command to scan the hard disk will affect the system's IO performance, please do not when the system is busy.

Operation Steps

Log in as the root user.

View system current drive information.

# fdisk-l

For example, the following information is displayed:

disk/dev/sda:298.9 GB, 298999349248 bytes

255 heads, Sectors/track, 36351 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

/DEV/SDA1 1 262 2104483+ for Linux Swap/solaris

/dev/sda2 * 263 32898 262148670 Linux

/dev/sda3 32899 36351 27736222+-up Linux

disk/dev/sdb:42.9 GB, 42949672960 bytes

Heads, Sectors/track, 40960 cylinders

Units = Cylinders of 2048 * 1048576 bytes

Scan the hard disk with commands.

# badblocks-s-v/dev/sdnx

where n represents the hard disk device name and x indicates the partition number of the hard disk. For example, to check for "/dev/sda2", execute the following command:

# badblocks-s-v/dev/sda2

Checking blocks 0 to 30681000

Checking for Bad blocks (read-only test): 306809600674112/306810000000

30680964

30680965

30680966

30680967

30680968

30680969

30680970

30680971

30680972

30680973

...

Done

Pass completed, PNS bad blocks found. Among them, "The PNS blocks found" indicates that there are 37 blocks of hard disk.

Atop viewing system anomalies

bj-xen-pdc04:~ # cd/var/log/atop/(enter atop log path)

Bj-xen-pdc04:/var/log/atop # LL

Total 21832

-rw-r--r--1 root root 5111271 2013-06-30 00:00 atop_20130629

-rw-r--r--1 root root 5161400 2013-07-01 00:00 atop_20130630

-rw-r--r--1 root root 5190512 2013-07-02 00:00 atop_20130701

-rw-r--r--1 root root 4838774 2013-07-03 00:00 atop_20130702

-rw-r--r--1 root root 1989255 2013-07-03 09:29 atop_20130703

-RW-------1 root root 0 2013-07-03 00:00 daily.log

Bj-xen-pdc04:/var/log/atop # atop-r atop_20130703 (Analysis history log file)

bj-xen-pdc04:~ # #atop (System current state)

PRC | SYS 259m06s |                User 16m59s |  |  #proc 131 |  #zombie 2 |               Clones 71138 |  | #exit 0 |

CPU | SYS 0% |  User 0% |  IRQ 0% |  Idle 197% |                Wait 2% |  |  Steal 1% | Guest 0% |

CPU | SYS 0% |  User 0% |  IRQ 0% |  Idle 98% |                cpu000 W 1% |  |  Steal 0% | Guest 0% |

CPU | SYS 0% |  User 0% |  IRQ 0% |  Idle 99% |                cpu001 W 1% |  |  Steal 0% | Guest 0% |

CPL | AVG1 0.00 |  Avg5 0.01 |               AVG15 0.00 |  |  CSW 180094e4 |               Intr 14098e5 |  | NUMCPU 2 |

MEM | Tot 4.0G |  Free 40.0M |  Cache 3.1G |  Dirty 0.0M |  Buff 259.0M |               Slab 214.4M |                | |

SWP | Tot 12.0G |                Free 12.0G |               |                |                |  |  Vmcom 421.5M | Vmlim 14.0G |

PAG |               Scan 4118e4 |  |               Stall 0 |                |  |               Swin 9 |  | Swout 24 |

DSK | SDA |  Busy 2% |  Read 577992 |  Write 1199e4 |  KIB/W 33 |  MBR/S 0.02 |  MBW/S 0.16 | Avio 3.94 ms |

DSK | SDB |  Busy 0% |  Read 66 |  Write 0 |  KIB/W 0 |  MBR/S 0.00 |  MBW/S 0.00 | Avio 2.24 MS |

DSK | SDC |  Busy 0% |  Read 51 |  Write 0 |  KIB/W 0 |  MBR/S 0.00 |  MBW/S 0.00 | Avio 2.27 ms |

NET | Transport |  TCPI 6889896 |  TCPO 1209373 |  udpi 21 |  UDPO 323 |  Tcpao 15 |  Tcppo 44 | Tcprs 773 |

NET | Network |  IPI 63073256 |  IPO 3862948 |  IPFRW 0 |                Deliv 9820e3 |  |  Icmpi 2654e3 | Icmpo 2652e3 |

NET | Eth2 0% |  Pcki 51999e4 |  Pcko 52311e4 |  Si-Kbps |  So 269 Kbps |  Erri 0 |  Erro 0 | Drpo 0 |

NET | Eth5 0% |  Pcki 56148e3 |  Pcko 22 |  Si/Kbps |  So 0 Kbps |  Erri 0 |  Erro 0 | Drpo 0 |

NET | BOND1----|  Pcki 51999e4 |  Pcko 52311e4 |  Si-Kbps |  So 269 Kbps |  Erri 0 |  Erro 0 | Drpo 0 |

NET | BR1----|  Pcki 11815e3 |  Pcko 3871052 |  Si-Kbps |  So-Kbps |  Erri 0 |  Erro 0 | Drpo 0 |

NET | BOND0----|  Pcki 56148e3 |  Pcko 22 |  Si/Kbps |  So 0 Kbps |  Erri 0 |  Erro 0 | Drpo 0 |

NET | BR0----|  Pcki 56121e3 |  Pcko 14 |  Si to Kbps |  So 0 Kbps |  Erri 0 |  Erro 0 | Drpo 0 |

NET | vif7.0----|  Pcki 705258 |  Pcko 699066 |  Si 0 Kbps |  So 0 Kbps |  Erri 0 |  Erro 0 | Drpo 2 |

NET | Lo----|  Pcki 621 |  Pcko 621 |  Si 0 Kbps |  So 0 Kbps |  Erri 0 |  Erro 0 | Drpo 0 |

* * System and process activity since boot * * *

PID ruid euid THR syscpu usrcpu vgrow rgrow rddsk wrdsk ST EXC S cpunr CPU CMD 1/10

7188 root root 1 213m38s 0.02s 0K 0K 0K 0K N-S 0 1% netback/0

7211 root root 9 13m34s 12m47s 291.6M 46128K 52244K 61036K N-S 0 0% Xend

28813 root root 1 8m20s 66.60s 0K 0K 8K 4K N-Z 1 0% Qemu-dm

8 root root 1 6m21s 9.58s 0K 0K 0K 0K N-S 1 0% Ev Ents/1

7 root root 1 6m26s 0.00s 0K 0K 0K 0K N-S 0 0% Ev ents/0

7129 root root 1 3m37s 73.70s 8972K 564K 0K 0K N-S 0 0% Irqbalance

2705 root root 1 71.99s 0.00s 0K 0K 168K 343.8M N-S 0 0% Kjournald

7212 root root 3 50.41s 9.88s 114.5M 7272K 8K 4K N-S 1 0% Blktapctrl

4949 root root 1 42.55s 2.44s 0K 0K 0K 0K N-S 1 0% Bond0

5100 root root 1 43.81s 1.16s 0K 0K 0K 0K N-S 1 0% Bond1

5780 root root 3 32.32s 11.87s 89704K 3760K 1492K 4K N-S 0 0% Qemu-dm

7051 root root 1 35.57s 0.88s 0K 0K 0K 0K N-S 0 0% Hwloghandle

5966 root root 1 0.88s 27.13s 403.1M 117.5M 37344K 178.3M N-S 1 0% Wireshark

Root root 1 26.13s 0.00s 0K 0K 0K 10380K N-S 0 0% K Swapd0

Linux uses the badblocks command to scan hard disk for troubleshooting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.