Linux 新增新硬碟無法識別[無需重啟]的解決方法

CF211發表於2024-05-11

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 

相關文章