เมื่อทำการ add datastore เข้าไปยัง VMware ESX/ESXi ด้วย Add Storage wizard แล้วเกิด error ดังข้างล่าง

An error occurred during host configuration. Call “HostDatastoreSystem.QueryVmfsDatastoreCreateOptions” for object “ha-datastoresystem” on ESXi “xxx.xxx.xxx.xx″ failed. An internal error occurred in the vsphere client.

VMware datastore

ปัญหานี้อาจเกิดจาก

  1. ขนาดของของ LUN มีขนาดใหญ่กว่า 2TB – 512 bytes (vSphere 4)
  2. LUN นี้เคยถูกใช้แบบ RDM (Raw Device Mapping)
  3. LUN มี GPT partition ที่ไม่สามารถลบออกได้

ปัญหาโดยส่วนใหญ่เกิดจากการนำ LUN กลับมาใช้ใหม่ (ข้อ 2-3) แล้วภายในมีการ set type ของ partition เป็น bsd, dvh, gpt, loop, mac, pc98 หรือ sun จึงทำให้ไม่สามารถ create datastore ได้ แต่ถ้าเป็น type ของ partition เป็น msdos หรือไม่มี partition เลยจะสามารถสร้างได้ ดังนั้นถ้าหากเกิดปัญหานี้ขึ้นจึงจำเป้นต้องลบ partition table ของ LUN ที่มีปัญหานั้นทิ้ง

วิธีการแก้ไข

ให้ตรวจสอบ device ทั้งหมดที่มีว่า device ชื่ออะไรบ้างเพื่อนำไปตรวจสอบว่าเป็น device ที่มีปัญหาหรือไม่

[shell]ls /vmfs/devices/disks/

WD2DWCAT25376266 vml.0100000000202020202057442d574341543235333736323636574443205744
WD2DWCAT25376266:1 vml.0100000000202020202057442d574341543235333736323636574443205744:1
WD2DWCAT25376266:2 vml.0100000000202020202057442d574341543235333736323636574443205744:2
WD2DWCAT25376266:5 vml.0100000000202020202057442d574341543235333736323636574443205744:5
WD2DWCAT25376475 vml.0100000000202020202057442d574341543235333736343735574443205744
WD2DWCAT25376475:1 vml.0100000000202020202057442d574341543235333736343735574443205744:1
WD2DWCAT25376475:2 vml.0100000000202020202057442d574341543235333736343735574443205744:2
WD2DWCAT25376475:3 vml.0100000000202020202057442d574341543235333736343735574443205744:3
WD2DWCAT25376475:5 vml.0100000000202020202057442d574341543235333736343735574443205744:5
WD2DWCAT25376475:6 vml.0100000000202020202057442d574341543235333736343735574443205744:6
WD2DWCAT25376475:7 vml.0100000000202020202057442d574341543235333736343735574443205744:7
WD2DWCAT25376475:8 vml.0100000000202020202057442d574341543235333736343735574443205744:8

[/shell]

ให้ใช้คำสั่ง fdisk เพื่อตรวจสอบหาว่า device ไหนที่มีปัญหา โดยใช้คำสั่ง

[shell]fdisk -l "/vmfs/devices/disks/DISK_NAME"[/shell]

เมื่อ DISK_NAME คือ ชื่อของ disk device
ตัวอย่างเช่น
[shell]~ # fdisk -l "/vmfs/devices/disks/WDCCAT25376266"
Disk /dev/disks/WDCCAT25376266: 160.0 GB, 160000000000 bytes
255 heads, 63 sectors/track, 19452 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/disks/WDCCAT25376266p1 * 1 18237 146483200 fd Linux raid autodetect
/dev/disks/WDCCAT25376266p2 18237 19453 9763841 5 Extended
/dev/disks/WDCCAT25376266p5 18237 19453 9763840 fd Linux raid autodetect
Found valid GPT with protective MBR; using GPT

fdisk: Sorry, can’t handle GPT partitions, use partedUtil[/shell]

จากตัวอย่างจะเห็นว่า device นี้มี GPT partitions อยู่ซึ่ง VMware ไม่สามารถนำ device นี้มาเป็น datastore ได้ ดังนั้นเราจึงต้องทำการลบ partition table ทิ้ง ด้วยคำสั่งด้านล่าง เพื่อให้ VMware คิดว่าเป็น disk เปล่า

[shell]~ # dd if=/dev/zero of="/vmfs/devices/disks/DISK_NAME" bs=512 count=34 conv=notrunc[/shell]

ตัวอย่างเช่น
[shell]~ # dd if=/dev/zero of="/vmfs/devices/disks/WDCCAT25376266" bs=512 count=34 conv=notrunc
34+0 records in
34+0 records out[/shell]

สำหรับ GPT partitions จะมี backup partition table อยู่ที่ 34 sectors ท้ายสุดของ disk ด้วยดังนั้นจะต้องลบออกด้วยคำสั่งคล้ายด้านบนแต่จะต้องหา จุดเริ่มต้นของ 34 sector ท้ายสุดของ disk ก่อน ด้วยวิธีคำนวนดังนี้

(SizeInBytes / 512) – 34 = SeekOffset

จากนั้นจะได้ จุดเริ่มต้นของ 34 sector ท้ายสุดของ disk ก็ให้มาแทนค่าด้วย SeekOffset ในคำสั่งด้านล่าง

[shell]# dd if=/dev/zero of="/vmfs/devices/disks/DISK_NAME" bs=512 count=34 seek=SeekOffset conv=notrunc[/shell]

จากตัวอย่างด้านบนจะเห็นว่า Disk นี้มีขนาด 8225280 bytes ดังนั้นจะคำนวนหา SeekOffset ได้ดังนี้

(8225280 / 512) – 34 = 16031

คำสั่งลบ backup partition table ของ GPT partitions
[shell]~ # dd if=/dev/zero of="/vmfs/devices/disks/WDCCAT25376266" bs=512 count=34 seek=16031 conv=notrunc[/shell]