不重新啟動Linux,手工識別線上新增磁碟方法

zhangsharp20發表於2017-01-12

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

此時就可以使用這個裝置了.

方法二:

[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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29802484/viewspace-2132347/,如需轉載,請註明出處,否則將追究法律責任。

相關文章