Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1556885
  • 博文数量: 157
  • 博客积分: 1776
  • 博客等级: 上尉
  • 技术积分: 1786
  • 用 户 组: 普通用户
  • 注册时间: 2011-12-19 10:49
文章分类

全部博文(157)

文章存档

2018年(1)

2017年(12)

2015年(6)

2014年(17)

2013年(51)

2012年(65)

2011年(5)

分类: LINUX

2012-08-09 16:39:08

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

环境描述:
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.

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

阅读(15570) | 评论(3) | 转发(4) |
给主人留下些什么吧!~~

技术宅2012-08-30 19:46:39

Aquester: 这里有一些API,可供程序中使用:
http://code.google.com/p/mooon/source/browse/trunk/common_library/include/sys/fs_util.h.....
谢谢

Aquester2012-08-12 21:14:13

这里有一些API,可供程序中使用:
http://code.google.com/p/mooon/source/browse/trunk/common_library/include/sys/fs_util.h

Bean_lee2012-08-10 12:31:19

lsscsi 命令也是这个命令系列的。
不过cat /proc/scsi/scsi 支持的更好一些
你说的这些,应该是热插拔吧