VMware/vSphere/partedUtil
Jump to navigation
Jump to search
partedUtil
NOTE: For ESXi/ESX 4.1 and later, use getptbl/setptbl
This also works:
cd /dev/disks partedUtil get eui.b42c42d3f4bb4ab0002471704404840c
Quick Partition:
cd /dev/disks ls DEVICE=eui.b42c42d3f4bb4ab0002471704404840c echo "Device: $DEVICE" DEVICE_SECTORS=`partedUtil get $DEVICE | head | awk '{print $4}'` echo "Device Sectors: $DEVICE_SECTORS" echo "Clearing Partitions..." PARTITIONS=`partedUtil get $DEVICE | grep -v $DEVICE_SECTORS` echo "$PARTITIONS" | while IFS= read line ; do PARTITION=`echo $line | awk '{print $1}' | grep .` if [ $? -ne 0 ] ; then continue ; fi echo "Deleting partition: $PARTITION" partedUtil delete $DEVICE $PARTITION done NEW_SECTORS=`expr $DEVICE_SECTORS / 1024 \* 1024 - 1` partedUtil setptbl $DEVICE gpt "1 2048 $NEW_SECTORS AA31E02A400F11DB9590000C2911D1B8 0"
# 251 does not appear to work:?? partedUtil setptbl "/vmfs/devices/disks/naa.6b4e0c0dfafafafafafafafafafafafa" gpt "1 2048 800780287 251 0"
Note: for the "800780287", take "floor( 800781251 / 1024 ) * 1024 - 1"
One partition:
# partedUtil get /vmfs/devices/disks/naa.6b4e0c0dfafafafafafafafafafafafa 49846 255 63 800781251 1 2048 800780287 0 0
49846 255 63 800781251 | | | | | | | \----- quantity of sectors (multiply by 512 for actual size) | | \-------- quantity of sectors per track | \------------ quantity of heads \------------------ quantity of cylinders
1 2048 800780287 0 0 | | | | | | | | | \--- attribute | | | \------- type | | \----------------- ending sector | \------------------------- starting sector \--------------------------- partition number
# partedUtil getptbl /vmfs/devices/disks/naa.6b4e0c0dfafafafafafafafafafafafa gpt 49846 255 63 800781251 1 2048 800780287 AA31E02A400F11DB9590000C2911D1B8 vmfs 0
Delete partition:
partedUtil delete /vmfs/devices/disks/naa.6b4e0c0dfafafafafafafafafafafafa 1
Create partition: (Note: VMFS = 0xFB (hex) = 251 (decimal) = AA31E02A400F11DB9590000C2911D1B8 (GUID))
partedUtil setptbl "/vmfs/devices/disks/naa.6b4e0c0dfafafafafafafafafafafafa" gpt "1 2048 800780287 AA31E02A400F11DB9590000C2911D1B8 0"
# 251 does not appear to work:?? partedUtil setptbl "/vmfs/devices/disks/naa.6b4e0c0dfafafafafafafafafafafafa" gpt "1 2048 800780287 251 0"
Note: for the "800780287", take "floor( 800781251 / 1024 ) * 1024 - 1"
Show GUIDs:
# partedUtil showGuids Partition Type GUID vmfs AA31E02A400F11DB9590000C2911D1B8 vmkDiagnostic 9D27538040AD11DBBF97000C2911D1B8 VMware Reserved 9198EFFC31C011DB8F78000C2911D1B8 Basic Data EBD0A0A2B9E5443387C068B6B72699C7 Linux Swap 0657FD6DA4AB43C484E50933C84B4F4F Linux Lvm E6D6D379F50744C2A23C238F2A3DF928 Linux Raid A19D880F05FC4D3BA006743F0F84911E Efi System C12A7328F81F11D2BA4B00A0C93EC93B Microsoft Reserved E3C9E3160B5C4DB8817DF92DF00215AE Unused Entry 00000000000000000000000000000000
To clear the GPT:
partedUtil mklabel /vmfs/devices/disks/naa.6b4e0c0dfafafafafafafafafafafafa msdos
References:
- VMware KB: Using the partedUtil command line utility on ESXi/ESX - http://kb.vmware.com/kb/1036609
- VMware KB: Manually creating a VMFS volume using vmkfstools -C - http://kb.vmware.com/kb/1009829
- Error adding datastores to ESXi resolved using partedUtil | www.vExperienced.co.uk - http://www.vexperienced.co.uk/2012/01/02/error-adding-datastores-to-esxi-resolved-using-partedutil/
- virtuallyGhetto: How to Format and Create VMFS5 Volume using the CLI in ESXi 5 - http://www.virtuallyghetto.com/2011/07/how-to-format-and-create-vmfs-volume.html