Home>Article>Operation and Maintenance> What to do if the Linux hard disk cannot be recognized

What to do if the Linux hard disk cannot be recognized

藏色散人
藏色散人 Original
2022-01-27 11:20:36 14058browse

The solution to the problem that the Linux hard disk cannot be recognized: 1. Check the hard disk; 2. Check the host directory of the current system; 3. Add "- - -" to the file scan in the host directory; 4. Execute the shell with one click Just script.

What to do if the Linux hard disk cannot be recognized

The operating environment of this article: linux5.9.8 system, DELL G3 computer

What should I do if the Linux hard disk cannot be recognized?

Linux solution to add a new hard disk that cannot be recognized [no need to restart]

1. Check the hard disk

[root@linux-host1 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 19G 0 part ├─centos-root 253:0 0 17G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sr0 11:0 1 1G 0 rom # 没有检查到sdb的硬盘

2. Check how many host directories there are in the current system

[root@linux-host1 ~]# ls /sys/class/scsi_host/ -l total 0 lrwxrwxrwx. 1 root root 0 Sep 16 12:42 host0 -> ../../devices/pci0000:00/0000:00:10.0/host0/scsi_host/host0 lrwxrwxrwx. 1 root root 0 Sep 16 12:42 host1 -> ../../devices/pci0000:00/0000:00:07.1/ata1/host1/scsi_host/host1 lrwxrwxrwx. 1 root root 0 Sep 16 12:42 host2 -> ../../devices/pci0000:00/0000:00:07.1/ata2/host2/scsi_host/host2

3. Add "- - -" to the file scan in the host directory as many as there are

[root@linux-host1 ~]# echo "- - -"> /sys/class/scsi_host/host0/scan [root@linux-host1 ~]# echo "- - -"> /sys/class/scsi_host/host1/scan [root@linux-host1 ~]# echo "- - -"> /sys/class/scsi_host/host2/scan

4. Check again whether the hard disk has been recognized

[root@linux-host1 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 19G 0 part ├─centos-root 253:0 0 17G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 20G 0 disk <<已经识别成功 sr0 11:0 1 1G 0 rom

5. One-click Executed shell script

#!/bin/bash scsisum=`ls -l /sys/class/scsi_host/host*|wc -l` for ((i=0;i<${scsisum};i++)) do echo "- - -" > /sys/class/scsi_host/host${i}/scan done

Recommended study: "linux video tutorial"

The above is the detailed content of What to do if the Linux hard disk cannot be recognized. For more information, please follow other related articles on the PHP Chinese website!

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
Previous article:How to modify time in linux Next article:How to modify time in linux