github.hscsec.cn/u-root/u-root@v7.0.0+incompatible/cmds/exp/esxiboot/README.md (about)

     1  # Running ESXi with u-root and QEMU/KVM
     2  
     3  This is a simple set of commands to get ESXi in QEMU/kvm up and running.
     4  
     5  To run ESXi in QEMU you'll need:
     6  
     7  -   QEMU/KVM
     8  -   Upstream u-root
     9  -   VMware installer image
    10  -   Linux kernel
    11  
    12  Linux kernel should support:
    13  
    14  -   kexec system call
    15  -   Sysfs
    16  -   Vfat
    17  -   AHCI
    18  -   ATA
    19  -   CDROM (iso9660, SCSI)
    20  
    21  Sample kernel config can be found
    22  [here](https://github.com/u-root/u-root/blob/14104d15a19773171441f5667ed5d2dce7a7da07/.circleci/images/integration/config_linux4.17_amd64.txt).
    23  
    24  Also add the following to your Kconfig:
    25  
    26  ```
    27  # qemu -hda support
    28  CONFIG_BLOCK=y
    29  CONFIG_ATA=y
    30  CONFIG_ATA_PIIX=y
    31  
    32  # qemu -cdrom support
    33  CONFIG_SCSI=y
    34  CONFIG_BLK_DEV_SD=y
    35  CONFIG_BLK_DEV_SR=y
    36  CONFIG_ISO9660_FS=y
    37  ```
    38  
    39  `VMware-VMvisor-Installer-6.7.0-8169922.x86_64.iso` was used to write this
    40  manual.
    41  
    42  ```shell
    43  $ qemu-system-x86_64 --version
    44  QEMU emulator version 2.11.93 (Debian 1:2.12~rc3+dfsg-1)
    45  Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
    46  
    47  $ cat /etc/modprobe.d/kvm-intel.conf
    48  options kvm-intel nested=y
    49  
    50  $ uname -r
    51  4.18.10-1rodete2-amd64
    52  ```
    53  
    54  ## Preparing the VM
    55  
    56  ```shell
    57  $ mkdir $HOME/esxi
    58  $ cd $HOME/esxi
    59  
    60  $ cp <VMware installer image> ./vmware.iso
    61  $ cp <bzImage> ./
    62  
    63  # Create QEMU disk image.
    64  $ qemu-img create -f qcow2 -o nocow=on esxi.qcow2 16G
    65  
    66  # Download and install u-root.
    67  $ go get -u github.com/u-root/u-root
    68  
    69  # Create initramfs.
    70  $ u-root -o ./initramfs.linux_amd64.cpio --build=bb all github.com/u-root/u-root/cmds/exp/esxiboot
    71  ```
    72  
    73  ## Installing ESXi
    74  
    75  ```shell
    76  # Run QEMU (8G RAM is required minimum, 2 CPUs minimum).
    77  $ qemu-system-x86_64 -cpu host -smp 2 -m 8192 -enable-kvm -kernel ./bzImage \
    78      -initrd ./initramfs.linux_amd64.cpio -hda esxi.qcow2 \
    79      -cdrom vmware.iso
    80  ```
    81  
    82  Now you are inside the QEMU VM.
    83  
    84  ```shell
    85  # Kexec ESXi installer.
    86  $ esxiboot -r /dev/sr0
    87  ```
    88  
    89  Follow GUI installer instructions. Shutdown QEMU after ESXi is installed.
    90  
    91  ## Running ESXi
    92  
    93  Run ESXi without the `-cdrom` boot disk:
    94  
    95  ```shell
    96  $ qemu-system-x86_64 -cpu host -smp 2 -m 8192 -enable-kvm -kernel ./bzImage \
    97      -initrd ./initramfs.linux_amd64.cpio -hda esxi.qcow2
    98  ```
    99  
   100  Now you are inside the QEMU VM.
   101  
   102  ```shell
   103  # Kexec ESXi. ESXi is normally installed to partition 5.
   104  $ esxiboot -d /dev/sda -p 5
   105  ```
   106  
   107  In QEMU console (Ctrl+Alt+2):
   108  
   109  ```shell
   110  hostfwd_add tcp::4443-:443
   111  ```
   112  
   113  In browser go to [https://localhost:4443](https://localhost:4443).
   114  
   115  You're all set.