ESXi Notes
Having previously worked with Oracle VirtualBox I thought this this would be an easy transition – but no way.
ESXi feel much more like a enterprise ready product, with complexities at that level as well.
Most of the things in here will be related to the CLI interface of ESXi version 6.5.
It is work in progress so there will be errors and things I have misunderstood below as it is for my own use.
Storage
Storage is provisioned in 3 layers starting from lowest level:
- Physical Disks (or raid/nas/san drives)
- Datastores: collection of physical disks making a logical disk
- Virtual Disks: VM storage placed in datastores as vmdk files
Simplified diagram:
Physical Disks (devices)
Physical disks are located in directory:
/vmfs/devices/disks
Physical hard disks maps to files in /vmfs/devices/disks like this:
t10.SanDisk00Ultra_Fit000000000000004C531001491102119083
Partitions maps to the above filename but ending with “:” and number like this:
t10.SanDisk00Ultra_Fit000000000000004C531001491102119083:1
Listing disks only:
ls -lh /vmfs/devices/disks | grep -v “:[0-9]$” | grep -v “vml\.” | grep -v “total”
Datastores
Datastores are located in directory:
/vmfs/volumes
Datastores are having names like this:
587949b5-46baef34-fb63-1866da2041ef
When a datastore is created and names then it gets a link from the name to the file above like:
SSD -> 587949b5-46baef34-fb63-1866da2041ef
Within the datastore you will find the virtual disks.
Virtual Disks
Virtual disks are located in directory:
/vmfs/volumes/{datastorename}/{vmname}
Together with other VM related files.
Main virtual disk names:
- {diskname}.vmdk: disk configuration file
- {diskname}-flat.vmdk: thin provisioned file (full file)
- {diskname}-rdmp.vmdk: raw provisioned file (link only)
Raw Device Mapping (RDM)
A physical disk can be mapped directly to a VM by creating a link.
Use this command:
vmkfstools -z /vmfs/devices/disks/{physical disk} /vmfs/volumes/SSD/{vmname}/{vmdkname}.vmdk
For example:
vmkfstools -z /vmfs/devices/disks/t10.SanDisk00Ultra_Fit000000000000004C531001491102119083 /vmfs/volumes/SSD/windows/hdd1.vmdk
Creates the following files:
- {diskname}.vmdk: disk configuration file
- {diskname}-rdmp.vmdk: raw provisioned file (link only)
Equally to remove the links to a VM do the following:
rm /vmfs/volumes/SSD/windows/hdd1.vmdk
rm /vmfs/volumes/SSD/windows/hdd1-rdmp.vmdk
Virtual Disk Backup
It is easy to do a “cold” backup when the VM is shut down.
Using the command to clone the original disk:
vmkfstools –i /vmfs/volumes/{datastorename}/{vmname}/{vmdkname}.vmdk {backupdest}/{vmdkname}.vmdk -d thin
This command should only be used with thin provisioned disks.
VM Upgrade
When importing a VM from other sources you will find the VM version is older.
I had this problem where I got a warning about the Linux version was not correct.
I could only pick Debian 6 where I was using Debian 8.
This is caused by the VM version is older.
To upgrade the VM version run the following command:
vim-cmd vmsvc/upgrade {vmid} vmx-13
The {vmid} can be obtained by running this command:
vim-cmd vmsvc/getallvms
Extending Virtual Disk
Well you don’t really extend but add another one instead.
Click on the VM details:
Click Add hard disk – New hard disk:
Adjust disk size:
Reboot the VM
List the disk:
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
|-sda1 8:1 0 428M 0 part /boot
|-sda2 8:2 0 18.2G 0 part
| |-turnkey-root 254:0 0 99G 0 lvm /
| `-turnkey-swap_1 254:1 0 512M 0 lvm [SWAP]
`-sda3 8:3 0 81.4G 0 part
`-turnkey-root 254:0 0 99G 0 lvm /
sdb 8:16 0 100G 0 disk
So new hard disk is: sdb
Initialise the physical volume:
# pvcreate /dev/sdb
Physical volume “/dev/sdb” successfully created
Extend volume group in LVM:
# vgextend turnkey /dev/sdb
Volume group “turnkey” successfully extended
Extend size of logical volume – first try failed as slightly less than 100GB available so just use extents option instead:
# lvextend -L+100G /dev/turnkey/root
Insufficient free space: 25600 extents needed, but only 25599 available
# lvextend -l 25599 /dev/turnkey/root
Size of logical volume turnkey/root changed from 99.02 GiB (25348 extents) to 100.00 GiB (25599 extents).
Logical volume root successfully resized
Resize the file system:
# resize2fs /dev/turnkey/root
resize2fs 1.42.12 (29-Aug-2014)
Filesystem at /dev/turnkey/root is mounted on /; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 7
The filesystem on /dev/turnkey/root is now 26213376 (4k) blocks long.
Another way to resize, which I used on Ubuntu:
growpart /dev/sda 2
resize2fs /dev/sda2
Where the 2 is the partition 2 in /dev/sda so /dev/sda2
All done:
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
|-sda1 8:1 0 428M 0 part /boot
|-sda2 8:2 0 18.2G 0 part
| |-turnkey-root 254:0 0 100G 0 lvm /
| `-turnkey-swap_1 254:1 0 512M 0 lvm [SWAP]
`-sda3 8:3 0 81.4G 0 part
`-turnkey-root 254:0 0 100G 0 lvm /
sdb 8:16 0 100G 0 disk
`-turnkey-root 254:0 0 100G 0 lvm /