首頁 > 軟體

VMware擴充套件磁碟如何不需重新啟動系統

2020-06-16 17:53:25

在虛擬機器VMware中我們有時候需要新增新的虛擬磁碟或給已有虛擬磁碟擴容(expand),在新增磁碟或磁碟擴容後,Linux系統並不能馬上識別到。也就是說你看不到磁碟空間變化(使用fdisk -l檢視),這時我們可以通過重新啟動系統(reboot)解決這個問題,但是很多時候,我們並不想在儲存擴容時重新啟動系統,因為這樣會影響到現有的業務系統。那麼為什麼新增磁碟或磁碟擴容後,Linux系統識別不到呢?這個是因為連線儲存裝置的SCSI匯流排需要重新掃描,才能識別到這些新的儲存裝置。下面測試一下在新增新的虛擬磁碟或給已有虛擬磁碟擴容如何操作才能不用重新啟動系統

1:VMware虛擬磁碟擴容

如下所示,VMware虛擬磁碟擴容後,使用fdisk -l看不到任何變化

[root@localhost ~]# 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:echo 1 > /sys/class/scsi_device/device/rescan

[root@localhost ~]# cd /sys/class/scsi_disk/
[root@localhost scsi_disk]# ls
0:0:0:0
[root@localhost scsi_disk]# cd 0:0:0:0/
[root@localhost 0:0:0:0]# echo '1' > device/rescan
[root@localhost 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:重新掃描特定的 SCSI Device

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

[root@localhost ~]# echo 1 > /sys/block/sda/device/rescan

2:VMware新增虛擬磁碟

首先找到您的主機匯流排編號

[root@localhost ~]# grep mpt /sys/class/scsi_host/host?/proc_name
 
/sys/class/scsi_host/host0/proc_name:mptspi

使用下面命令掃描SCSI匯流排

[root@localhost ~]# echo "- - -" > /sys/class/scsi_host/host0/scan

本文永久更新連結地址http://www.linuxidc.com/Linux/2015-09/122924.htm


IT145.com E-mail:sddin#qq.com