Quantcast
Channel: 可丁丹尼 @ 一路往前走2.0
Viewing all articles
Browse latest Browse all 79

ESXi 手動刪除磁區

$
0
0

ESXi 手動刪除磁區

某些時候你將磁碟加入成為DataStore時,可能會出現錯誤:

A specified parameter was not correct.
vm.Host.DiskPartitionInfo.spec
...
...

意指你加入的磁碟可能已經有其他分割無法進行刪除成為DataStore,會有這狀況可能是ESXi使用fdisk指令來管理磁碟,在你的分割是GPT或是fdisk本身無法管理的都會出現類似的錯誤,所以你必需要使用其他指令進行手動刪除。

partedUtil

使用ssh登入ESXi Server時,執行partedUtil不加參數會出現指令的使用方法:

Usage:
 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>


稍後會使用Delete Partition : delete <diskName> <partNum>進行刪除。

尋找磁區

刪除磁區前首先尋找該磁區的磁碟名稱:

ls -l /vmfs/devices/disks

所以與磁碟、磁區有關的都會在disks這目錄內,使用ls -l列出很多資訊

total 4896061644
-rw-------    1 root     root     1978895695872 May 16 15:52 mpx.vmhba1:C0:T0:L0
-rw-------    1 root     root     1978894630400 May 16 15:52 mpx.vmhba1:C0:T0:L0:1
-rw-------    1 root     root     7849115648 May 16 15:52 mpx.vmhba32:C0:T0:L0
-rw-------    1 root     root       4161536 May 16 15:52 mpx.vmhba32:C0:T0:L0:1
-rw-------    1 root     root     262127616 May 16 15:52 mpx.vmhba32:C0:T0:L0:5
-rw-------    1 root     root     262127616 May 16 15:52 mpx.vmhba32:C0:T0:L0:6
-rw-------    1 root     root     115326976 May 16 15:52 mpx.vmhba32:C0:T0:L0:7
-rw-------    1 root     root     299876352 May 16 15:52 mpx.vmhba32:C0:T0:L0:8
-rw-------    1 root     root     107374182400 May 16 15:52 naa.600140501e76a67dcf27d3813d82ded1
-rw-------    1 root     root     107373116928 May 16 15:52 naa.600140501e76a67dcf27d3813d82ded1:1
-rw-------    1 root     root     60022480896 May 16 15:52 t10.ATA_____EZLINK_Seraphim_MLC_60GB________________201203071200279_____
-rw-------    1 root     root     60020490240 May 16 15:52 t10.ATA_____EZLINK_Seraphim_MLC_60GB________________201203071200279_____:1
-rw-------    1 root     root     256060514304 May 16 15:52 t10.ATA_____EZLINK_T34_256GB________________________201410300108________
-rw-------    1 root     root     256051917824 May 16 15:52 t10.ATA_____EZLINK_T34_256GB________________________201410300108________:1
-rw-------    1 root     root     40019582464 May 16 15:52 t10.ATA_____INTEL_SSDSA2M040G2GC____________________CVGB00330014040GGN__
-rw-------    1 root     root       4161536 May 16 15:52 t10.ATA_____INTEL_SSDSA2M040G2GC____________________CVGB00330014040GGN__:1
-rw-------    1 root     root     4293918720 May 16 15:52 t10.ATA_____INTEL_SSDSA2M040G2GC____________________CVGB00330014040GGN__:2
-rw-------    1 root     root     34781265920 May 16 15:52 t10.ATA_____INTEL_SSDSA2M040G2GC____________________CVGB00330014040GGN__:3


t10.開頭的主要是你機器上的磁碟,以例子中要找的是EZLINK T34這個256GB SSD,它先前在windows使用過,所以要進行手動刪除才能成為DataStore,重新執行指令將所有EZLINK T34的都列出來:

ls -l /vmfs/devices/disks/t10.ATA_____EZLINK_T34_256GB*

列出相關的:

-rw-------    1 root     root     256060514304 May 16 15:16 t10.ATA_____EZLINK_T34_256GB________________________201410300108________
-rw-------    1 root     root     367001600 May 16 15:16 t10.ATA_____EZLINK_T34_256GB________________________201410300108________:1
-rw-------    1 root     root     255158087168 May 16 15:16 t10.ATA_____EZLINK_T34_256GB________________________201410300108________:2
-rw-------    1 root     root     532676608 May 16 15:16 t10.ATA_____EZLINK_T34_256GB________________________201410300108________:3
/dev/disks # ls -l t10.ATA_____EZLINK_T34*

其他名稱後面以:冒號與數字組合的名稱為磁區,以這個列表看來總共分割成3個磁區,現在要一一的將三個磁區刪除。

刪除磁區

承上已經列出要刪除磁碟資訊:

t10.ATA_____EZLINK_T34_256GB________________________201410300108________
-rw-------    1 root     root     367001600 May 16 15:16 t10.ATA_____EZLINK_T34_256GB________________________201410300108________:1
-rw-------    1 root     root     255158087168 May 16 15:16 t10.ATA_____EZLINK_T34_256GB________________________201410300108________:2
-rw-------    1 root     root     532676608 May 16 15:16 t10.ATA_____EZLINK_T34_256GB________________________201410300108________:3

此時利用partedUtil的Delete Partition : delete <diskName> <partNum>進行刪除:

cd /vmfs/devices/disks

partedUtil delete "t10.ATA_____EZLINK_T34_256GB________________________201410300108________" 3

partedUtil delete "t10.ATA_____EZLINK_T34_256GB________________________201410300108________" 2

partedUtil delete "t10.ATA_____EZLINK_T34_256GB________________________201410300108________" 1

以上執行正確後,重新再查看一下時,應該會看到只剩磁碟名稱:

ls -l /vmfs/devices/disks/t10.ATA_____EZLINK_T34_256GB*

結果:

-rw-------    1 root     root     256060514304 May 16 16:04 /vmfs/devices/disks/t10.ATA_____EZLINK_T34_256GB________________________201410300108________

確定刪除後就可以利用vSphere Client進行重新加入成為DataStore的動作。

參考資訊

來上電腦課!- PartedUtil VMware ESXi 磁區管理指令

Vim.Host.DiskPartitionInfo.spec – VMware can’t add extra drive.


Viewing all articles
Browse latest Browse all 79

Trending Articles