不重新啓動Linux,手工識別在線新增磁盤方法

下文簡單介紹一個方法,實現不重新啓動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.

此時就可以使用這個設備了.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章