公司使用了虚拟机环境,容量不够的情况下,需要新加硬盘。但添加了新硬盘后,使用fdsik不能看到新硬盘。查找相关资料,有两种思路可以选择。
思路一
[root@node2 ~]# fdisk -l #未识别新硬盘
Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0009f777
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
查看/proc/scsi/scsi/ 下面
[root@node2 ~]# cat /proc/scsi/scsi
Attached devices:# 这个直接存储就是我们正在使用的总线
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi1 Channel: 00 Id: 00 Lun: 00 # 注意类型,为光驱设备
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 05
可使用命令直接进行添加
echo “scsi add-single-device x y z u” >> /proc/scsi/scsi
注:对各个参数的理解:
x是硬盘所在SCSI控制器号(一般机器就一个SCSI控制器,所以就是0);
y是硬盘所在SCSI通道的编号(一般单通道的就是0,多通道的要看是哪个通道了)
单通道SCSI卡最多支持同时接15个盘,卡上只一个通道。
双通道SCSI卡有2个通道,在数量上增加一倍,可以同时并行各接15个,达到30个。
z是硬盘的SCSI ID号(在原有上面加1);
u是硬盘的lun号(默认情况都是0)
所以本次就可以直接使用
[root@node2 ~]# echo "scsi add-single-device 2 0 1 0 " >> /proc/scsi/scsi
[root@node2 ~]# fdisk -l # 已经识别了sdb硬盘
Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0009f777
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
思路二:触发系统的磁盘扫描
[root@node2 ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 05
[root@node2 ~]# ls /sys/class/scsi_host/
host0 host1 host2
此处可以使用暴力方法针对所有的总线进行扫描
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
...
扫描后就会识别所有总线上的硬盘了
网友评论