不重新启动Linux,手工识别在线新增磁盘方法

下文简单介绍一个方法,实现不重新启动linux而可以识别到新增的磁盘.

创新互联建站主要从事做网站、成都做网站、网页设计、企业做网站、公司建网站等业务。立足成都服务荣县,十余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220

环境描述:
OS: Redhat linux 5.4 x86(主机为vmware 虚拟主机)
增加一个50G的lun

方法一:

一. 手工增加磁盘的命令
# echo "scsi add-single-device w x y z" > /proc/scsi/scsi
为使该命令正常运行,必须指定正确的参数值 w、x、y 和 z,如下所示: 
w 是主机适配器标识,第一个适配器为零(0)
x 是主机适配器上的 SCSI 通道,第一个通道为零(0)
y 是设备的 SCSI 标识
z 是 LUN 号,第一个 LUN 为零(0)


二. 执行命令前,检查/proc/scsi/scsi文件,确定新磁盘的id
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: VMware Model: Virtual disk Rev: 1.0 
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 01 Lun: 00
Vendor: VMware Model: Virtual disk Rev: 1.0 
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 02 Lun: 00
Vendor: VMware Model: Virtual disk Rev: 1.0 
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 03 Lun: 00
Vendor: VMware Model: Virtual disk Rev: 1.0 
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 04 Lun: 00
Vendor: VMware Model: Virtual disk Rev: 1.0 
Type: Direct-Access ANSI SCSI revision: 02

可以看到最大的id号为04,新增磁盘的ID应该确定为5.

三. 执行fdisk -l命令,检查当前磁盘的情况
[root@soadb scsi]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2610 20860402+ 8e Linux LVM

......

Disk /dev/sde: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sde doesn't contain a valid partition table


四. 执行命令
#echo "scsi add-single-device 0 0 5 0" >/proc/scsi/scsi


五. 执行fdisk命令,检查结果
[root@soadb scsi]# fdisk -l
......

Disk /dev/sde: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sde doesn't contain a valid partition table

Disk /dev/sdf: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdf doesn't contain a valid partition table

可以看到,新增的50G的磁盘已经在操作系统中识别到,设备名称为/dev/sdf.

此时就可以使用这个设备了.

方法二:

[root@localhost ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM
[root@localhost ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@localhost ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table



原博客地址:http://blog.chinaunix.net/uid-26557245-id-3307138.html
网站栏目:不重新启动Linux,手工识别在线新增磁盘方法
文章出自:http://myzitong.com/article/pepdsp.html