Custom Proxmox Templates

Making custom LXC templates in Proxmox

Andrew Cabey - March 14, 2017

Base Container

The first thing you need to do is create a 'base' container where you choose your settings as you please. Because I am most comfortable with Ubuntu, I will be modifying an ubuntu-16.04-standard_16.04-1_amd64 container.

Creating the container

Whatever choices you make for hardware will not affect the template, so just finish making the container.

Enter the container and customize it to your liking. If you haven't seen it already, My First 5 Minutes on a Server is a great read

sudo pct enter < id >

Clean Up

Finish off your base container by installing upgrades then cleaning all specific information

  • sudo -S apt update sudo -S apt upgrade # Install available upgrades
  • sudo -S apt clean # Clean temp data sudo -S apt autoclean sudo -S apt autoremove # Remove unused packages
  • sudo -S rm /etc/resolv.conf # Strip DNS settings sudo -S rm /etc/hostname # Strip hostname
  • exit # Exit user
  • exit # Exit container
  • Return to the Proxmox WebUI and remove the network interfaces from the container

    Creating the container

Backup to Template

  • pct stop < id > # Stop container
  • Again in the WebUI, create a backup of your container

    Creating the container
  • Back in the terminal, find your most recent backup

    The backup archive will be called 'vzdump-lxc-< id >-< date >.tar.gz' in the '/var/lib/vz/dump/' directory

    cd /var/lib/vz/dump/
  • Rename and move this archive

    mv vzdump-lxc-< id >-< date >.tar.gz /var/lib/vz/template/cache/ubuntu-16.04-custom_16.04-1_amd64.tar.gz

When you go to make a new container, verify that your template is displayed as an option.

Creating the container