Skip to content

Instantly share code, notes, and snippets.

@garrydzeng
Last active July 18, 2025 06:54
Show Gist options
  • Save garrydzeng/683683f79716a5664bb544be4bbe0168 to your computer and use it in GitHub Desktop.
Save garrydzeng/683683f79716a5664bb544be4bbe0168 to your computer and use it in GitHub Desktop.
How to support vmw_pvscsi controller

This tutorial explains how to modify a minimal image so that it can be booted from ESXi 7+ or VMWare Workstation

REASON

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.

HOW TO TUTORIAL

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 loaction
    • mkdir -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

CONVERT TO VMWARE'S FORAMT

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

LAYOUT

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment