Linux在VMware下擴展磁盤解決方法

        Linux系統中,如果要擴展磁盤容量,可以新建虛擬磁盤空間。新建虛擬磁盤重啟後就能生效瞭,當然如果你有什麼重要的在執行的任務,而不想重啟,也是有辦法的。本文就來介紹一下Linux如何在VMware下擴展磁盤。

  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

 

Linux如何在VMware下擴展磁盤

 

  方法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

 

Linux如何在VMware下擴展磁盤

 

  方法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

  以上就是Linux如何在VMware下擴展磁盤的介紹瞭,使用上面的兩個步驟擴展磁盤,不需要重啟系統,虛擬磁盤就能立即被系統識別,想瞭解更多內容可以對GuideAH進行關註!

 

閱讀更多: