PartedUtil VMware ESXi 磁區管理指令

Posted by admin on 12 六月, 2014 20:16

VMware ESXi Server 新增儲存空間,安裝全新的硬碟後,在 VMware vSphere Client 裡很容易就可完成設定。可是如果安裝的是其他作業系統使用過的硬碟,部分版本的 VMware vSphere Client 連線到 VMware ESXi 時,受限於只能從「未配置」的磁區,格式化為儲存空間,以致常見無可用空間情形。一般如未先行清空磁區,就得運用磁區管理指令了。還好,這現象在更新 VMware ESXi 5 後有了改善…


▲ ESXi 更新後新增儲存空間將為方便。

即便如此仍想用指令時,需注意舊版 VMware ESXi Server 使用與 Linux 相同的 fdisk 指令,目前的 ESXi 5 受限於 fdisk 指令無法管理 GPT 磁區,已建議改用 partedUtil 指令。現在就以清除 NTFS 磁區為例,練習 partedUtil 指令操作。


▲ ESXi 安裝未清除磁區硬碟,無法新增儲存空間的錯誤訊息。

【作業環境】
VMware ESXi 5.5.0 Build 1746018
VMware vSphere Client 5.5.0 Build 1618071
VMware vSphere Web Client 5.5.0 Build 1588022

【清除磁區前的準備】
使用「ls /vmfs/devices/disks/」指令,查詢 VMware ESXi Server 硬碟安裝情形…
 
~ # ls /vmfs/devices/disks/

t10.ATA_____MB1000ECWCQ_______________Z1W0AXXX____________
t10.ATA_____MB1000ECWCQ_______________Z1W0AXXX____________:1
t10.ATA_____MB1000ECWCQ_______________Z1W0AXXX____________:2
t10.ATA_____MB1000ECWCQ_______________Z1W0AXXX____________:3
t10.ATA_____MB1000ECWCQ_______________Z1W0AXXX____________:5
t10.ATA_____MB1000ECWCQ_______________Z1W0AXXX____________:6
t10.ATA_____MB1000ECWCQ_______________Z1W0AXXX____________:7
t10.ATA_____MB1000ECWCQ_______________Z1W0AXXX____________:8
t10.ATA_____MB1000ECWCQ_______________Z1W0AXXX____________:9
t10.ATA_____ST2000DL0032D9VT166_____________________5YD1ZXXX
t10.ATA_____ST2000DL0032D9VT166_____________________5YD1ZXXX:1
t10.ATA_____ST2000DL0032D9VT166_____________________5YD1ZXXX:2
vml.010000202020202020202020202020355944315a594b3553543230303
vml.010000202020202020202020202020355944315a594b3553543230303:1
vml.010000202020202020202020202020355944315a594b3553543230303:2
vml.0100005a3157304144584e2020202020202020202020204d423130303
vml.0100005a3157304144584e2020202020202020202020204d423130303:1
vml.0100005a3157304144584e2020202020202020202020204d423130303:2
vml.0100005a3157304144584e2020202020202020202020204d423130303:3
vml.0100005a3157304144584e2020202020202020202020204d423130303:5
vml.0100005a3157304144584e2020202020202020202020204d423130303:6
vml.0100005a3157304144584e2020202020202020202020204d423130303:7
vml.0100005a3157304144584e2020202020202020202020204d423130303:8
vml.0100005a3157304144584e2020202020202020202020204d423130303:9

列表顯示安裝兩顆硬碟,從硬碟編號、磁區數量,即可分辨出系統磁碟與另一顆準備刪除磁區的硬碟。

【partedUtil 指令用法】

~ # partedUtil ?

查詢指令用法如下:

 Get Partitions : get <diskName>
 Set Partitions : set <diskName> ["partNum startSector endSector type attr"]*
 Delete Partition : delete <diskName> <partNum>
 Resize Partition : resize <diskName> <partNum> <start> <end>
 Get Partitions : getptbl <diskName>
 Set Partitions : setptbl <diskName> <label> ["partNum startSector endSector type/guid attr"]*
 Fix Partition Table : fix <diskName>
 Create New Label (all existing data will be lost): mklabel <diskName> <label>
 Show commonly used partition type guids : showGuids
 Get usable first and last sectors : getUsableSectors <diskName>
 Fix GPT Table interactively : fixGpt <diskName>

【磁區清除】
清除磁區時使用下列指令及參數:

~ # partedUtil delete "/vmfs/devices/disks/DiskName" Partition Number

例如:
 
~ #  partedUtil delete "/vmfs/devices/disks/ t10.ATA_____ST2000DL0032D9VT166________________5YD1ZXXX" 2
~ #  partedUtil delete "/vmfs/devices/disks/ t10.ATA_____ST2000DL0032D9VT166________________5YD1ZXXX" 1

確認磁區清除狀態…
 
~ # ls /vmfs/devices/disks/

顯示該已清除硬碟磁區規畫…
……
t10.ATA_____ST2000DL0032D9VT166___________________5YD1ZXXX
……

【登入主機新增儲存空間】
執行 VMware vSphere Client …
組態 > 硬體 > 儲存區 > 新增儲存空間 > 儲存空間類型:磁碟 / LUN > 下一步 …
這樣就能將硬碟全部空間格式化為 VMFS 檔案系統了。

【參考文件】
Using the partedUtil command line utility on ESXi and ESX

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.