kotoyuuko

CORE

昨日より、明日より、笑える今が一番大好き。
github
telegram
email

VMware ESXi Tinkering Log

2021/02/08 Update: This article lost the images during the migration.

A while ago, in order to experience studying abroad, I switched to using a software router with the combination of Proxmox VE + OpenWrt. Overall, it works pretty well, but the only downside is that if the network card is not passed through, the speed can only reach around 40MB/s. It is said that ESXi performs better, so I wanted to give it a try.

Installation#

There is not much to say about the installation process. Just prepare a USB drive and follow the steps to install. However, because the SATA on my software router is a bit special, it is not an independent SATA channel, but rather goes through a controller similar to RAID. I encountered the following problem during the installation:

At first, following the instructions online, I used an mSATA to USB adapter to install the system on the hard drive, then started the system, disabled the new version of the AHCI driver, and plugged the hard drive back into the machine to start. However, it seems that the result is not working.

Later, I found a great guy online who made an ESXi installation package with RAID drivers, but the problem still persisted.

I tried this for a whole day, and finally, in the BIOS, I adjusted the SATA operation mode from AHCI to Intel RST Premium. Then, I installed it using the first method mentioned above, and it worked normally. Here is the command to disable the AHCI driver:

esxcli system module set --enabled=false --module=vmw_ahci

Storage#

By default, ESXi requires separate hard disk storage for images and virtual machines. Here, you can use a command to create storage space directly in the free space of the system disk.

First, check the identifier of the hard disk in the ESXi backend.

The string in parentheses is the identifier of the hard disk.

Then use the command to view the disk partitions:

partedUtil getptbl /vmfs/devices/disks/硬盘标识

You will get the following output:

gpt
14593 255 63 234441648
1 64 8191 C12A7328F81F11D2BA4B00A0C93EC93B systemPartition 128
5 8224 520191 EBD0A0A2B9E5443387C068B6B72699C7 linuxNative 0
6 520224 1032191 EBD0A0A2B9E5443387C068B6B72699C7 linuxNative 0
7 1032224 1257471 9D27538040AD11DBBF97000C2911D1B8 vmkDiagnostic 0
8 1257504 1843199 EBD0A0A2B9E5443387C068B6B72699C7 linuxNative 0
9 1843200 7086079 9D27538040AD11DBBF97000C2911D1B8 vmkDiagnostic 0

Here, remember the fourth number in the second line of the output: 234441648. This number is different for each person.

Then execute the following command to repartition:

partedUtil setptbl /vmfs/devices/disks/硬盘标识 gpt \
"1 64 8191 C12A7328F81F11D2BA4B00A0C93EC93B 128" \
"5 8224 520191 EBD0A0A2B9E5443387C068B6B72699C7 0" \
"6 520224 1032191 EBD0A0A2B9E5443387C068B6B72699C7 0" \
"7 1032224 1257471 9D27538040AD11DBBF97000C2911D1B8 0" \
"8 1257504 1843199 EBD0A0A2B9E5443387C068B6B72699C7 0" \
"9 1843200 7086079 9D27538040AD11DBBF97000C2911D1B8 0" \
"2 7086080 15472639 EBD0A0A2B9E5443387C068B6B72699C7 0" \
"3 15472640 X AA31E02A400F11DB9590000C2911D1B8 0"

Replace the X in the last line with the result of the previous step minus 48.

After that, use the command to create the storage:

vmkfstools -C vmfs6 -b 1m -S 存储名称 /vmfs/devices/disks/硬盘标识

Image Conversion#

Because the firmware configuration I compiled myself did not generate a vmdk file, and I don't want to adjust the compilation parameters again, I use qemu-img to convert the img file to a vmdk file:

qemu-img convert -f raw -O vmdk openwrt.img openwrt.vmdk

Modify Hostname#

The default hostname of ESXi is localhost.localdomain, which is not good-looking or easy to remember. Let's change it directly:

esxcfg-advcfg -s 新主机名 /Misc/hostname

Licensing#

The default trial license needs to be renewed every 60 days, which is quite troublesome. Let's use a code found online directly:

0U0QJ-FR1EP-KZQN9-J1C74-23P5R

Issues#

Because of an abnormal power outage, I encountered this error when opening the virtual machine again: "Object type needs managed I/O".

The reason seems to be that the image file is damaged due to the abnormal power outage, but it can be fixed.

First, execute:

vmkfstools -x check /path/to/your/machine.vmdk

If it prompts "Disk needs repair.", execute the following command to repair:

vmkfstools -x repair /path/to/your/machine.vmdk

It has been tested that converting the disk to thin format can directly solve the problem:

vmkfstools -i source.vmdk destination.vmdk -d thin

About Pass-through#

At first, I passed through all the network cards except for the management port to OpenWrt.

Until later, I found that the virtual network card can also achieve gigabit network speed, so I canceled the pass-through of all network cards and used virtual network cards directly.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.