Resize Virtual Disk – VMware ESXi 4.1 & CentOS 5.5 x86

  1. 使用vSphere Client登入調整硬體的設定,將硬碟空間增大 (由20G -> 80G)
    20140813

  2. 將VM Guest重開機

  3. 以ssh登入VM Guest

  4. 輸入fdisk -l取得目前磁碟資訊

  1. 根據4回傳的資訊,輸入fdisk /dev/sda

[備註]
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

  1. 輸入 p 取得目前的資訊

  1. 輸入 n 創建新的partition,接著按兩下Enter,以使用最小及最大的數值 (使用完整的free空間)

  1. 輸入 t 更改系統ID,選擇第3個partition,直接輸入8e

  1. 輸入 w 將設定寫入硬碟

  1. 將 VM Guest 重新開機

  2. 輸入 fdisk -l 可以看到剛剛新增的sda3
    </pre lang=”bash”>[root@localhost ~]# fdisk -l

Disk /dev/sda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 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 2610 20860402+ 8e Linux LVM
/dev/sda3 2611 10443 62918572+ 8e Linux LVM

  1. 使用 pvcreate 創建 volume

  1. 使用 vgextend 將 sda3 加入 VolGroup00

  1. 使用 vgdisplay 查詢 VolGroup00 未使用的空間為 60G

  1. 使用 lvextend 增加空間 (從14可以得知為60G)

  1. 使用 resize2fs 修改分割區大小

  1. 輸入 df -h 驗證有沒有成功

參考資訊: Extending a logical volume in a virtual machine running Red Hat or Cent OS (1006371)

This entry was posted in CentOS, VMware. Bookmark the permalink.