To create a virtual machine disk:
- Log in to the terminal of the VMware ESX host.
- Navigate to the directory that contains the virtual machine disk with the missing descriptor file using the command:
cd /vmfs/volumes/vmfsvolume/dir
Note:
- If you are using a version of VMware ESXi, you can access and modify files and directories using the VMware vSphere client Datastore Browser or the vifs utility included with the vSphere CLI. For more information, see the section Performing File System Operations in vSphere CLI documentation.
- If you are using VMware Fusion, the default location for the virtual machine files is <home>/Documents/Virtual Machines.localized/<virtual machine>/ folder where <home> is your home folder, and <virtual machine> is the name of the virtual machine.
- Identify the type of SCSI controller the virtual disk is using. You can do this by examining the virtual machine configuration file (.vmx). The controller is identified by the line scsi#.virtualDev, where # is the controller number; there may be more than one controller and controller type attached to the virtual machine. This example uses lsilogic:
scsi0.present = "true"
scsi0.sharedBus = "none"
scsi1.present = "true"
scsi1.sharedBus = "virtual"
scsi1.virtualDev = "lsilogic"
- Identify and record the exact size of the -flat file using a command similar to:
# ls -l mydisk0-flat.vmdk
-rw------- 1 root root 1048576 Oct 11 12:30 mydisk0-flat.vmdk
- Use the vmkfstools command to create a new virtual disk:
# vmkfstools -c 1048576 -a lsilogic -d thin temp.vmdk
This command uses these flags:
-c <size> (This is the size of the virtual disk).
-a <virtual controller> (Whether the virtual disk was configured to work with BusLogic or LSILogic).
-d thin (This creates the disk in a thin-provisioned format).
Note: To save disk space, we create the disk in a thin-provisioned format using the type thin. The resulting flat file then consumes minimal amounts of space (1MB) instead of immediately assuming the capacity specified with the -c switch. The only consequence, however, is the descriptor file contains an extra line that must be removed manually in a later step.
The files temp.vmdk and temp-flat.vmdk are created as a result.
- Delete temp-flat.vmdk, as it is not needed. Run the command:
# rm temp-flat.vmdk
- Rename temp.vmdk to the name that is required to match the orphaned .flat file (or mydisk0.vmdk, in this example):
# mv temp.vmdk mydisk0.vmdk
- Edit the descriptor file with a text editor:
- Under the Extent Description section, change the name of the .flat file to match the orphaned .flat file you have.
- Find and remove the line ddb.thinProvisioned = "1" if the original .vmdk was not a thin disk. If it was, retain this line.
# Disk DescriptorFile
version=1
CID=fb183c20
parentCID=ffffffff
createType="vmfs"
# Extent description
RW 8388608 VMFS "mydisk0-flat.vmdk"
# The Disk Data Base
#DDB
ddb.virtualHWVersion = "4"
ddb.geometry.cylinders = "522"
ddb.geometry.heads = "255"
ddb.geometry.sectors = "63"
ddb.adapterType = "lsilogic"
ddb.thinProvisioned = "1"
The virtual machine is now ready for power on. Verify your changes before starting the virtual machine.
No comments:
Post a Comment