This tutorial explains how to modify a minimal image so that it can be booted from ESXi 7+ or VMWare Workstation
The minimal cloud image enables the GRUB_FORCE_PARTUUID
option
which means system boots from root filesystem only, and the well-known vmw_pvscsi
module is compiled as a kernel module.
Therefore, we need to enable initrd.img to load the vmw_pvscsi
driver before mounting the root filesystem.
We need server and minimal cloud image that can be downloaded from ubuntu offical server.
- Enable module
modprobe nbd
- Connect to ubuntu-24.04-server-cloudimg-amd64.img & mount boot partition and copy
initrd.img-6.8.0-60-generic
to another loactionmkdir -p /mnt/nbd0
qemu-nbd -c /dev/nbd0 ubuntu-24.04-server-cloudimg-amd64.img
mount /dev/nbd0p16 /mnt/nbd0
cp -a /mnt/nbd0/initrd.img-6.8.0-60-generic </path/to/initrd.img-6.8.0-60-generic>
πumount /mnt/nbd0
qemu-nbd -d /dev/nbd0
- Connect to another disk image
qemu-nbd -c /dev/nbd0 ubuntu-24.04-minimal-cloudimg-amd64.img
- Mount partitions and copy initramfs ralted files (ensure /mnt/nbd0/boot/initrd.img-6.8.0-60-generic permission is 600)
mount /dev/nbd0p1 /mnt/nbd0
mount /dev/nbd0p16 /mnt/nbd0/boot
mount /dev/nbd0p15 /mnt/nbd0/boot/efi
mount --bind /dev /mnt/nbd0/dev
mount --bind /proc /mnt/nbd0/proc
mount --bind /sys /mnt/nbd0/sys
cp -a </path/to/initrd.img-6.8.0-60-generic> /mnt/nbd0/boot
πcd /mnt/nbd0/boot
πln -s initrd.img-6.8.0-60-generic initrd.img.old
πln -s initrd.img-6.8.0-60-generic initrd.img
π
- Comment the line starts with
GRUB_FORCE_PARTUUID=
in /mnt/nbd0/etc/default/grub.d/40-force-partuuid.cfg πrm -f /mnt/nbd0/etc/default/grub.d/40-force-partuuid.cfg
(alternative)
- chroot and update GRUB configuration
chroot /mnt/nbd0
update-grub
πexit
umount -R /mnt/nbd0
qemu-img --disconnect /dev/nbd0
Also, hardware version 6 is too old, you should convert it after attached to virtual machine
qemu-img convert -f qcow2 -O vmdk -o adapter_type=lsilogic,subformat=monolithicSparse,compat6 ubuntu-24.04-minimal-cloudimg-amd64.img ubuntu-24.04-minimal-cloudimg-amd64.vmdk
Device Start End Sectors Size Type
/dev/nbd0p1 2099200 7339998 5240799 2.5G Linux filesystem
/dev/nbd0p14 2048 10239 8192 4M BIOS boot
/dev/nbd0p15 10240 227327 217088 106M EFI System
/dev/nbd0p16 227328 2097152 1869825 913M Linux extended boot