最近新装了虚拟化平台esxi8.0b,在创建routeros虚拟机时遇到了一系列问题:
1,esxi8.0b默认创建的ESXi 8.0(虚拟硬件版本20)版本虚拟机使用了新的api,默认以uefi引导系统,在创建完成后不能修改为bios,报错“ACPI motherboard layout requires EFI”。
2,RouterOS的CHR版磁盘镜像默认以bios引导。使用x86的iso可以正常安装使用uefi引导虚拟机,但是系统显示的是x86架构,通过升降级不能切换架构,x86架构不启用open-vm-tools服务,这个服务不启动,在esxi控制面板看不到hostname和IP地址等信息。此外x86架构和chr架构的授权和有些功能也不相同。
3,RouterOS的CHR版磁盘镜像有两个分区,第一个是efi分区,文件系统是ext2,而非uefi标准的fat。
4,RouterOS的CHR版磁盘镜像有独立的mbr和gpt分区表,既不是gpt也不是Hybrid MBR。
5,RouterOS的CHR版uefi启动不支持Secureboot。

以下是让routeros v7.8在ESXi8.0上以UEFI方式引导启动的方法,此方式只在routeros v7.8chr版测试通过,不确定后续版本升级是否可用。
1,创建没有硬盘的虚拟机,关闭secureboot。
2,下载routeros的vmdk虚拟机硬盘文件,解压上传到esxi。
3,ssh登录到esxi,转换routeros的vmdk磁盘格式,并扩展磁盘空间。

vmkfstools -i chr-7.8.vmdk routeros.vmdk -d thin
vmkfstools -X 20G routeros.vmdk

4,修改虚拟机配置,添加刚才生成的vmdk磁盘。
5,虚拟机挂载ubuntu的live-cd或其他有gdisk命令的系统iso到虚拟机。
6,开机进入ubuntu桌面,备份RouterOS Boot分区的全部文件
7,取消挂载,并使用fat格式化第一个分区

mkfs -t fat /dev/sda1

8,恢复步骤6中备份的文件到第一个分区后取消挂载routeros的两个磁盘
9,使用gdisk创建Hybrid MBR分区表,过程如下:

root@ubuntu:/home/ubuntu# gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.8

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: present

Found valid MBR and GPT. Which do you want to use?
 1 - MBR
 2 - GPT
 3 - Create blank GPT

Your answer: 2
Using GPT and creating fresh protective MBR.

Command (? for help): t
Partition number (1-2): 1
Current type is EF00 (EFI system partition)
Hex code or GUID (L to show codes, Enter = EF00): 8300
Changed type of partition to 'Linux filesystem'

Command (? for help): r

Recovery/transformation command (? for help): h

WARNING! Hybrid MBRs are flaky and dangerous! If you decide not to use one,
just hit the Enter key at the below prompt and your MBR partition table will
be untouched.

Type from one to three GPT partition numbers, separated by spaces, to be
added to the hybrid MBR, in sequence: 1 2
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): n

Creating entry for GPT partition #1 (MBR partition #1)
Enter an MBR hex code (default 83): 
Set the bootable flag? (Y/N): y

Creating entry for GPT partition #2 (MBR partition #2)
Enter an MBR hex code (default 83): 
Set the bootable flag? (Y/N): n

Unused partition space(s) found. Use one to protect more partitions? (Y/N): n

Recovery/transformation command (? for help): w
Warning! Secondary header is placed too early on the disk! Do you want to
correct this problem? (Y/N): y
Have moved second header and partition table to correct location.

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.

10,重启系统即可以UEFI方式启动RouterOS CHR

附:
初始vmdk的mbr分区表:

root@ubuntu:/home/ubuntu# gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.8

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: present

Found valid MBR and GPT. Which do you want to use?
 1 - MBR
 2 - GPT
 3 - Create blank GPT

Your answer: 1

Command (? for help): p
Disk /dev/sda: 262144 sectors, 128.0 MiB
Model: VMware Virtual I
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): F1C07EE3-729F-4E5F-8C77-AEC9BC697BD3
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 262110
Partitions will be aligned on 2-sector boundaries
Total free space is 4063 sectors (2.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34           65569   32.0 MiB    8300  Linux filesystem
   2           65570          258047   94.0 MiB    8300  Linux filesystem

Command (? for help): q

初始vmdk的gpt分区表:

root@ubuntu:/home/ubuntu# gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.8

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: present

Found valid MBR and GPT. Which do you want to use?
 1 - MBR
 2 - GPT
 3 - Create blank GPT

Your answer: 2
Using GPT and creating fresh protective MBR.

Command (? for help): r

Recovery/transformation command (? for help): p
Disk /dev/sda: 262144 sectors, 128.0 MiB
Model: VMware Virtual I
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 197E76F1-9677-0D46-9C33-F00032DDDBB1
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 258047
Partitions will be aligned on 2-sector boundaries
Total free space is 0 sectors (0 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34           65569   32.0 MiB    EF00  RouterOS Boot
   2           65570          258047   94.0 MiB    8300  RouterOS

Recovery/transformation command (? for help): q

创建hybrid mbr后的vmdk的gpt分区表:

Recovery/transformation command (? for help): p
Disk /dev/sda: 262144 sectors, 128.0 MiB
Model: VMware Virtual I
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 197E76F1-9677-0D46-9C33-F00032DDDBB1
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 258047
Partitions will be aligned on 2-sector boundaries
Total free space is 0 sectors (0 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34           65569   32.0 MiB    8300  RouterOS Boot
   2           65570          258047   94.0 MiB    8300  RouterOS

Recovery/transformation command (? for help): o

Disk size is 262144 sectors (128.0 MiB)
MBR disk identifier: 0x00000000
MBR partitions:

Number  Boot  Start Sector   End Sector   Status      Code
   1      *             34        65569   primary     0x83
   2                 65570       258047   primary     0x83
   3                     1           33   primary     0xEE

参考:
1,Router OS 7 on UEFI
2,Hybrid MBR(MBR 混合分区表)
3,Manual:CHR VMWare installation