linux 硬盘无法识别怎么办
linux硬盘无法识别的解决办法:1、查看硬盘;2、查看当前系统的host目录;3、往host目录里面的文件scan追加“- - -”;4、一键执行shell脚本即可。
本文操作环境:linux5.9.8系统、DELL G3电脑
Linux 添加新硬盘无法识别[无需重启]的解决方法
1、查看硬盘
[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、查看当前系统有多少个host目录
[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、有多少个host就往多少个host目录里面文件scan追加"- - -"
[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、再次检查硬盘是否已经识别到
[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、一键执行的shell脚本
#!/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
推荐学习:《linux视频教程》