After getting my own dedicated server, I found myself repeating certain tasks on the container every time, like setting my locale, timezone, adding aliases to .bashrc, updating and upgrading packages. I thought it was time I had a go at customizing my own Debian minimal template.
Here’s how to go about modifying an openvz template.
First, create a container in proxmox, let its container id be 100.
Set the IP and other details in the Proxmox panel, inclluding choosing which template it is to be based on.
Start the container:
vzctl start 100
Check that network is ok:
vzctl exec 100 ping -n -c 1 google.com
Enter the container:
vzctl enter 100
Now do all that you have to do on the container, including modifying the apt sources list, setting timezone, installing any additional programs or removing existing ones, adding any public keys etc.
Remove logs like .bash_history.
Once you’re done, exit the container.
exit
Stop the container and remove its IP:
vzctl stop 100 vzctl set 100 --ipdel all --save
Now create the new template file:
cd /vz/private/100 tar --numeric-owner -czf /vz/template/cache/debian-7.0-x86_64_India.tar.gz .
Clean up:
vzctl destroy 100 rm -f /etc/vz/conf/100.conf.destroyed
Reference:
OpenVZ Wiki
Changing password for a container:
vzctl set 101 –userpasswd root:test
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
He is a full stack developer, whose favorite languages are currently Python and Vue.js. He is also fluent in Javascript, Flutter/Dart, Perl, PHP, SQL, C and bash shell scripting. He loves Linux, and can often be found tinkering with linux kernel code, and source code for GNU applications. He used to be an active developer on XDA forums, and his tinkered ROMS used to be very popular in the early 2000s.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.