linux下不重启添加硬盘

linux下热加载磁盘

临时给虚拟机加了一块硬盘,增加后懒得重启,于是看了看热加载

[root@centos5 ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
#注意红色字体这行,我们主要依据这行做热加载

scsi0   为x <- 是硬盘或者磁带机所在SCSI控制器号
Channel  为y   <-是硬盘或者磁带机所在SCSI通道的编号
id     为z   <-是硬盘或者磁带机的SCSI ID号
lun     为u <-是硬盘或者磁带机的lun号默认情况都是0

热增加一个磁盘很简单:
echo "scsi add-single-device x y z u"> /proc/scsi/scsi
这里,我们是单机,显然,x y u都是固定的,只有scsi id是不同的
所以只需要
echo "scsi add-single-device 0 0 1 0"> /proc/scsi/scsi
就可以增加磁盘
下面来测试一下:

[root@centos5 ~]# fdisk -l
Disk /dev/sda: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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 535 4192965 82 Linux swap / Solaris
/dev/sda3 536 13054 100558867+ 83 Linux
只看到一个磁盘

执行命令看看:

[root@centos5 ~]# echo "scsi add-single-device 0 0 1 0"> /proc/scsi/scsi
[root@centos5 ~]# fdisk -l

Disk /dev/sda: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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 535 4192965 82 Linux swap / Solaris
/dev/sda3 536 13054 100558867+ 83 Linux

Disk /dev/sdb: 128.8 GB, 128849018880 bytes
255 heads, 63 sectors/track, 15665 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table
[root@centos5 ~]#
ok,磁盘增加成功

posted @ 2015-05-04 17:20  侠客书生  阅读(542)  评论(0编辑  收藏  举报