VMware扩展磁盘如何不需重启系统

在编造机VMware中我们有的时候供给增多新的设想磁盘或给已有虚拟磁盘扩大体积(expand),在增加产量磁盘或磁盘扩大容积后,Linux系统并不可能及时识别到。也正是说你看不到磁盘空间变化(使用fdisk
-l查看),那时大家得以经过重启系统(reboot)化解这么些难点,可是过多时候,我们并不想在蕴藏扩大容积时重启系统,因为这么会影响到存活的事情类别。那么为啥新添磁盘或磁盘扩大体量后,Linux系统识别不到吧?那些是因为老是存款和储蓄设备的SCSI总线需求重新扫描,技能鉴定识别到那几个新的存款和储蓄设备。下边测量试验一下在累加新的虚拟磁盘或给已有设想磁盘扩大体量怎么着操作工夫不用重启系统

1:VMware设想磁盘扩大容积

正如所示,VMware设想磁盘扩大容积后,使用fdisk -l看不到另外变化

[[email protected]
~]# fdisk -l
 
Disk /dev/sda: 171.7 GB, 171798691840 bytes
255 heads, 63 sectors/track, 20886 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      15665  125724690  8e  Linux LVM
/dev/sda3          15666      15795    1044225  83  Linux
/dev/sda4          15796      20886    40893457+  83  Linux
 
Disk /dev/dm-0: 126.6 GB, 126600871936 bytes
255 heads, 63 sectors/track, 15391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Disk /dev/dm-0 doesn’t contain a valid partition table
 
Disk /dev/dm-1: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Disk /dev/dm-1 doesn’t contain a valid partition table

图片 1

方法1:echo 1 > /sys/class/scsi_device/device/rescan

[[email protected]
~]# cd /sys/class/scsi_disk/
[[email protected]
scsi_disk]# ls
0:0:0:0
[[email protected]
scsi_disk]# cd 0\:0\:0\:0/
[[email protected]
0:0:0:0]# echo ‘1’ > device/rescan
[[email protected]
0:0:0:0]# fdisk -l
 
Disk /dev/sda: 173.9 GB, 173946175488 bytes
255 heads, 63 sectors/track, 21147 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      15665  125724690  8e  Linux LVM
/dev/sda3          15666      15795    1044225  83  Linux
/dev/sda4          15796      20886    40893457+  83  Linux
 
Disk /dev/dm-0: 126.6 GB, 126600871936 bytes
255 heads, 63 sectors/track, 15391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Disk /dev/dm-0 doesn’t contain a valid partition table
 
Disk /dev/dm-1: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Disk /dev/dm-1 doesn’t contain a valid partition table

图片 2

措施2:重新扫描特定的 SCSI Device

echo 1 > /sys/block/$DEVICE/device/rescan 用sda, sdb,
sdc等替换$DEVICE

[[email protected]
~]# echo 1 > /sys/block/sda/device/rescan

2:VMware新扩大设想磁盘

率先找到您的主机总线编号

[[email protected]
~]# grep mpt /sys/class/scsi_host/host?/proc_name
 
/sys/class/scsi_host/host0/proc_name:mptspi

使用上边发号施令扫描SCSI总线

[[email protected]
~]# echo “- – -” > /sys/class/scsi_host/host0/scan

本文恒久更新链接地址:

在设想机VMware中我们临时要求增添新的杜撰磁盘或给已有设想磁盘扩容(expand),在新添磁盘或磁盘扩大体量…

物理连接磁盘:
[root@ www.linuxidc.com ~]# fdisk /dev/sdbc

linux下热加载磁盘

Unable to open /dev/sdbc
[root@ www.linuxidc.com ~]# more /proc/scsi/scsi
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

一时半刻给虚构机加了一块硬盘,扩展后懒得重启,于是看了看热加载

[root@ www.linuxidc.com proc]# cd scsi
[root@ www.linuxidc.com scsi]# ls
device_info  mptspi  scsi  sg
[root@ www.linuxidc.com scsi]# more device_info
‘Aashima’ ‘IMAGERY 2400SP’ 0x1
‘CHINON’ ‘CD-ROM CDS-431’ 0x1
‘CHINON’ ‘CD-ROM CDS-535’ 0x1
‘DENON’ ‘DRD-25X’ 0x1
‘HITACHI’ ‘DK312C’ 0x1
‘HITACHI’ ‘DK314C’ 0x1
‘IBM’ ‘2104-DU3’ 0x1
‘IBM’ ‘2104-TU3’ 0x1
‘IMS’ ‘CDD521/10’ 0x1
‘MAXTOR’ ‘XT-3280’ 0x1
‘MAXTOR’ ‘XT-4380S’ 0x1
‘MAXTOR’ ‘MXT-1240S’ 0x1
‘MAXTOR’ ‘XT-4170S’ 0x1
‘MAXTOR’ ‘XT-8760S’ 0x1
‘MEDIAVIS’ ‘RENO CD-ROMX2A’ 0x1
‘MICROTEK’ ‘ScanMakerIII’ 0x1
‘NEC’ ‘CD-ROM DRIVE:841’ 0x1
‘PHILIPS’ ‘PCA80SC’ 0x1
‘RODIME’ ‘RO3000S’ 0x1
‘SUN’ ‘SENA’ 0x1
‘SANYO’ ‘CRD-250S’ 0x1
‘SEAGATE’ ‘ST157N’ 0x1
‘SEAGATE’ ‘ST296’ 0x1
[root@ www.linuxidc.com scsi]# ls
device_info  mptspi  scsi  sg
[root@ www.linuxidc.com scsi]# more scsi
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
 注:使用那个命令扩充磁盘:
 echo “scsi add-single-device w x y z” > /proc/scsi/scsi

[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
#瞩目浅青字体那行,大家第一基于那行做热加载

点名的参数值 w、x、y 和 z,如下所示:
w 是主机适配器标志,第二个适配器为零(0)
x 是主机适配器上的 SCSI 通道,第三个通道为零(0)
y 是道具的 SCSI 标志
z 是 LUN 号,第一个 LUN 为零(0)
注:可接纳这么些命令删除磁盘:echo “scsi remove-single-device w x y z”
> /proc/scsi/scsi
[root@ www.linuxidc.com scsi]# echo “scsi add-single-device 0 00 02
00”> /proc/scsi/scsi[root@ www.linuxidc.com scsi]# more scsi
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
[root@ www.linuxidc.com scsi]# fdisk -l

scsi0   为x <- 是硬盘大概磁带机所在SCSI调节器号
Channel  为y   <-是硬盘也许磁带机所在SCSI通道的编号
id     为z   <-是硬盘也许磁带机的SCSI ID号
lun     为u <-是硬盘大概磁带机的lun号私下认可意况都以0

Disk /dev/sda: 38.6 GB, 38654705664 bytes
255 heads, 63 sectors/track, 4699 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

热扩张叁个磁盘很简短:
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
就足以追加磁盘
上边来测量试验一下:

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

[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

Author

发表评论

电子邮件地址不会被公开。 必填项已用*标注