2021/02/08 Update: The article lost its images during the migration process.
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's 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 doesn't have independent SATA channels, but instead uses a controller similar to RAID. I encountered the following problem during installation:
Initially, 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 it up. However, it didn't seem to work.
Afterwards, I found an ESXi installation package with RAID drivers made by a great person online, but the problem persisted.
I tried this for a whole day, and finally, after adjusting the SATA operation mode from AHCI to Intel RST Premium in the BIOS, I was able to install it using the first method mentioned above and use it normally. Here's 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 directly create storage space 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 following command to view the hard 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: 234441648
. This number is unique to 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 subtracting 48
from the number obtained in the previous steps.
Afterwards, use the following 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 didn't want to readjust the compilation parameters, I used 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 was 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.
But later, I found that virtual network cards can also achieve gigabit network speeds, so I canceled the pass-through of all network cards and used virtual network cards directly.