This project automates the creation of Ubuntu 24.04 Desktop Vagrant boxes using Packer and QEMU/KVM.
- Ubuntu 24.04 LTS with full desktop environment
- Automated installation using cloud-init autoinstall
- Pre-configured with Vagrant SSH keys and credentials
- Optimized for desktop use with SPICE graphics
- Support for libvirt/QEMU provider
Required tools:
- Packer
- QEMU/KVM
- Vagrant with vagrant-libvirt plugin
- xorriso (for ISO creation)
- jq (for JSON processing)
packer build .This will:
- Download Ubuntu 24.04 Server ISO
- Run automated installation with vagrant user
- Install Ubuntu Desktop packages
- Configure SSH and sudo access
- Output a QEMU image to
output/ubuntu24.04
Build time: ~20 minutes
./package-vagrant-box.shThis creates ubuntu-24.04-desktop.box (~1.9GB)
vagrant box add ubuntu-24.04-desktop ubuntu-24.04-desktop.box --provider libvirtmkdir ~/my-ubuntu-vm
cd ~/my-ubuntu-vm
vagrant init ubuntu-24.04-desktop
vagrant up --provider=libvirt
vagrant ssh.
├── auto-desktop.pkr.hcl # Packer configuration
├── http/
│ ├── user-data # Cloud-init autoinstall config
│ └── meta-data # Cloud-init metadata
├── Vagrantfile # Default box configuration
├── metadata.json # Vagrant box metadata
└── package-vagrant-box.sh # Packaging script
- Memory: 4GB
- CPUs: 2
- Disk: 25GB
- Graphics: SPICE with QXL video
- Network: NAT with DHCP
- Username: vagrant
- Password: vagrant
- SSH Key: Vagrant insecure public key (replaced on first
vagrant up)
The http/user-data file contains:
- User creation with proper SSH keys
- Package installation (desktop, development tools)
- SSH server configuration
- Sudo access without password
Edit auto-desktop.pkr.hcl:
memory = 8192 # Change RAM
cpus = 4 # Change CPU cores
disk_size = "50G" # Change disk sizeEdit http/user-data packages section:
packages:
- ubuntu-desktop
- your-package-hereReplace ubuntu-desktop with alternatives:
kubuntu-desktopfor KDExubuntu-desktopfor XFCEubuntu-mate-desktopfor MATE
- Ensure VNC is enabled (
headless = false) to watch installation - Check that autoinstall completes successfully
- Verify user-data syntax is correct
- Increase
ssh_timeoutin Packer config - Check system resources (RAM, CPU)
- Monitor installation via VNC (port 5900)
- Ensure QEMU image exists in
output/ubuntu24.04 - Verify
metadata.jsonandVagrantfileare present - Check disk space for packaging
PACKER_LOG=1 packer build .Connect VNC viewer to localhost:5900 during build
rm -rf output/
vagrant box remove ubuntu-24.04-desktopbox.img- QEMU/KVM disk imagemetadata.json- Provider configurationVagrantfile- Default VM settings
This project uses standard Ubuntu distribution and Vagrant configurations.
Feel free to submit issues and enhancement requests!