Vmware擴充磁碟如何不需重啟系統,vmware擴充磁碟不需

來源:互聯網
上載者:User

Vmware擴充磁碟如何不需重啟系統,vmware擴充磁碟不需

    在虛擬機器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://thornelabs.net/2012/08/22/linux-rescan-scsi-bus.html

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.