Every time inspiration struck or I saw a blog post with something I wanted to try, it was frustrating and time consuming to get the base operating system set up to the way I like it before proceeding with the project.
Now I just update the template each point release or when I add something substantial to my dotfiles so it's ready to go whenever I need to spin up a fresh container.
It only takes a few minutes to set up or modify and can save lots of time in the long run.
ssh proxmox
sudo pveam list sas-storage
sudo pveam update
sudo pveam available
sudo pveam available --section system
sudo pveam download sas-storage debian-10.0-standard_10.0-1_amd64.tar.gz
man pveam for more details.Now we need to create the container that we will be updating and adding our programs to. Note that you will need to modify the following command to match your system.
sudo pct create 250 sas-storage:vztmpl/debian-10.0-standard_10.0-1_amd64.tar.gz \ --storage sas-lvm --rootfs volume=sas-lvm:16 \ --ostype debian --arch amd64 --password insecure --unprivileged 1 \ --cores 1 --memory 1024 --swap 1024 \ --hostname lxc-template --searchdomain local.lan --nameserver xxx.xxx.xxx.x \ --net0 name=eth0,bridge=vmbrxx,ip=dhcp,gw=xxx.xxx.xx.x,type=veth \ --start true
man pct for more information.Here's where we update/add programs/configure it to our liking.
sudo pct enter 250
apt update && apt upgrade
apt install curl git screen stow unattended-upgrades vim
update-alternatives --set editor /usr/bin/vim.basic
adduser user
su - user
git clone https://path.to/dotfiles ~/.dotfiles
stow dotfiles
~/.ssh directory:mkdir ~/.ssh
~/.ssh/authorized_keys file with your pubkeyIn order to turn the container into a template, we need to delete the network interface then create a backup.
sudo pct set 250 --delete net0
vzdump 250 --mode stop --compress gzip --dumpdir /media/sas/data/template/cache/
/media/sas/data/template/cache
cd /media/sas/data/template/cache
sudo mv new_vz_dump.tar.gz custom_debian_10.4.tar.gz
man vzdump for info.Feel free to delete the container we used to make the template (250).
It's really easy to modify the container when a new version of the OS is released or you want to add something to your templates.
sudo pct create 250 sas-storage:vztmpl/custom_debian_10.4.tar.gz \ --storage sas-lvm --rootfs volume=sas-lvm:16 \ --ostype debian --arch amd64 --password insecure --unprivileged 1 \ --cores 1 --memory 1024 --swap 1024 \ --hostname lxc-template --searchdomain local.lan --nameserver xxx.xxx.xxx.x \ --net0 name=eth0,bridge=vmbrxx,ip=dhcp,gw=xxx.xxx.xxx.x,type=veth \ --start true
sudo pct enter 250
apt update && apt upgrade
exit
sudo pct set 250 --delete net0
vzdump 250 --mode stop --compress gzip --dumpdir /media/sas/data/template/cache/
cd /media/sas/data/template/cache
sudo mv new_vz_dump.tar.gz custom_debian_10.5.tar.gz
Now every time you want to create a lxc container to use, it will be ready to go with things set just the way you like!