Skip to content

How to create a DietPi image for VMware

MichaIng edited this page Sep 10, 2020 · 9 revisions

Prerequirement

Download base image

Create and prepare the VM from VMware GUI

  • Create a New Virtual Machine > Installer disc image file (iso) > select the just downloaded mini.iso > Next
  • Guest operating system: Linux > Version: Debian 10.x 64-bit > Next
  • Name: DietPi_VMware-x86_64-Buster > Next
  • Maximum disk size (GB): 8 > Store virtual disk as a single file > Next
  • Customize Hardware:
    • Memory: 1024 MB
    • Processors: Virtualize Intel VT-x/EPT or AMD-V/RVI: [x] check
    • Network Adapters: Bridged > Configure Adapter: select your hosts internet network adapter
    • USB Controller: USB compatibility > USB 3.1, uncheck Share Bluetooth devices with the virtual machine
    • Remove Sound Card and Printer to have a most light VM. Everything can be re-added/changed at any time later.
  • Close > Finish > Play virtual machine

Debian installer

  • NB: The following steps can be automated, however the effort on netboot installers is too high to have any benefit over manually going through the installation for a single VM: https://www.debian.org/releases/stable/amd64/apbs01.html.en#preseed-methods
  • Advanced options > Expert install
  • Choose language > English > United Kingdom > en_GB.UTF-8 > Continue (select NO additional locales)
  • Configure the keyboard > British English
  • Detect network hardware
  • Deselect any Modules to load as we don't require them.
  • Configure the network > Yes (auto-configure) > 3 secon
  • Hostname: DietPi
  • Domain name: <leave empty>
  • APT mirror: Just use one near to your location or deb.debian.org. It will be overwritten anyway by DietPi-PREP, as actually most other settings as well 😉.
  • Debian version to install: buster - stable
  • Download installer components: Deselect everything > Continue
  • Set up users > Enable shadow passwords? Yes > Allow root login? Yes > Root password: dietpi
  • Create a normal user account now? No
  • Configure the clock > Use NTP? Yes > leave default mirror 0.debian.pool.ntp.org > time zone: UTC
  • Detect disks > Deselect any Modules to load > Partition discs > Manual > Select SCSI (sda) VMware (or similar) > Create new empty partition table? Yes > msdos > Select FREE SPACE > Create a new partition > New partition size: max > Primary
  • Verify: Ext4 and mount point / > Done setting up the partition > Finish partitioning > No return due to missing swap partition > Yes write to disk
  • Install the base system
  • Select kernel package: linux-image-amd64
  • Select targeted since no generic driver installation is required for virtual machines.
  • Configure the package manager > No nonfree, contrib and especially No source repository!
  • Select security updates and release updates and skip backported software for now, which will be re-added by DietPi-PREP later.
  • Select and install software > No automatic updates > No virtualbox-guest extension and No survey (user should decide this oneself later)
  • Deselect all additional software
  • Install the GRUB boot loader > Yes to master boot record > to the only available partition (/dev/sda) > Not to the EFI removable media path, actually no idea why it detects EFI, as it was not selected on machine and is definitely not available afterwards...
  • Finish the installation > set to UTC? Yes
  • BEFORE Continue: Unplug the optical drive (Player > Removable Devices > CD/DVD > Disconnect > override lock), to prevent reboot into installer > Continue

DietPi-PREP

  • Login as root:dietpi
  • apt update; apt install -y ca-certificates curl dropbear-run
  • Connect via SSH (IP: ip a) for easier copy&paste etc.
bash -c "$(curl -sSfL https://raw.githubusercontent.com/MichaIng/DietPi/master/PREP_SYSTEM_FOR_DIETPI.sh)"
  • Git branch: master
  • Enter your name to be shown as image creator within DietPi banner credits.
  • Enter Debian mini.iso as this was our base image above.
  • Device: 20 : x86_64 Virtual Machine
  • Deselect WiFi functionality for VMs as they virtualise Ethernet adapters for network only.
  • Distro version: 5: Buster
  • shutdown now

Image export and packaging

  • Mount virtual drive (vmdk) to another VM or machine, use zerofree -v /dev/sdx1 to reduce final image size. In case: apt -y install zerofree
  • Compact the image size e.g. with vmware-vdiskmanager.exe -k /path/to/DietPi_VMware-x86_64-Buster.vmdk, part of VMware Virtual Disk Development Kit (VDDK).
    • Compacting the image from VMware player (Select VM > Edit virtual machine settings > Hard Disk > Defragment > Compact) should do the same but did not work until the most recent VMware version.
  • Remove all files but the .vmdk and .vmx.
  • Edit the .vmx to lower the hardware revision to virtualhw.version = "10" to make it compatible with older VMware/ESXi versions: https://github.com/MichaIng/DietPi/issues/3637
    • Additionally remove local system related info like the path of the mounted installer .iso and such.
  • Create hashes of those two, e.g. using HashMyFiles, saving the report to hash.txt.
  • Download the current README.md: https://raw.githubusercontent.com/MichaIng/DietPi/master/README.md
  • Pack the .vmdk, .vmx + README.md + hash.txt with 7zip for high compression rate.