สำหรับผู้ที่ต้องการใช้งานเทมเพลตใหม่ ๆ ที่ไม่มีให้ดาวน์โหลดบน หน้าดาวน์โหลด template เราสามารถสร้าง template เองได้ง่าย ๆ ดังนี้ สำหรับครั้งนี้เรามาลองสร้างเทมเพลต Ubuntu 14.10 Server ตัวใหม่ล่าสุดกัน ก่อนอื่นให้เราดาวน์โหลดและติดตัั้ง Ubuntu 14.10 Server แบบ KVM พร้อม update/upgrade ให้เรียบร้อยก่อน จากนั้นให้ติดตั้ง debootstrap
apt-get install -y debootstrap
จากนั้นใช้ debootstrap ดาวน์โหลดคอนฟิกไฟล์และแพ็คเกจทั้งหมดที่จำเป็นลง directory ที่ต้องการ ในที่นี้จะให้ลงใน /tmp/deb
debootstrap --arch amd64 utopic /tmp/deb ftp://ftp.ubuntu.com/ubuntu
จากนั้นสร้างไฟล์ /tmp/deb/client.sh
vi /tmp/deb/tmp/client.sh
และ copy text ดังนี้ไปใส่ในไฟล์ที่สร้างขึ้น
#!/bin/bash echo "root:password" | chpasswd apt-get update apt-get purge -y console-setup ntpdate whiptail eject ureadahead sudo vim-tiny rsync apt-get install -y vim openssh-server find / -name *ondemand -exec rm -rf {} \; rm -f /etc/init/console* /etc/init/tty* sed -i -e 's/^\$ModLoad imklog/#\$ModLoad imklog/g' /etc/rsyslog.conf sed -i -e 's@\(space:\)\(/var/log/\)@\1-\2@' /etc/rsyslog.d/*.conf sed -i -e 's/^\#cron./cron./g' /etc/rsyslog.d/50-default.conf sed -i -e 's/^\console output/#console output/g' /etc/init/rc.conf sed -i -e 's/^\env INIT_VERBOSE/#env INIT_VERBOSE/g' /etc/init/rc.conf locale-gen en_US.UTF-8 locale-gen en_GB.UTF-8 dpkg-reconfigure locales cp /usr/share/zoneinfo/Asia/Bangkok /etc/localtime cat < /etc/init/tty1.conf # tty1 - getty # # This service maintains a getty on tty1 from the point the system is # started until it is shut down again. start on stopped rc RUNLEVEL=[2345] stop on runlevel [!2345] respawn exec /sbin/getty -8 38400 tty1 EOF rm -f /etc/ssh/ssh_host_* cat << EOF > /etc/init.d/generate_ssh_keys #!/bin/bash ssh-keygen -f /etc/ssh/ssh_host_rsa_key -t rsa -N '' ssh-keygen -f /etc/ssh/ssh_host_dsa_key -t dsa -N '' rm -f \$0 EOF chmod a+x /etc/init.d/generate_ssh_keys update-rc.d generate_ssh_keys defaults apt-get clean find /var/ -name *.log -exec rm -rf {} \; rm -rf /boot /dev /media /opt /run /srv /tmp /root/.bash_history /root/.viminfo /etc/ssh/ssh_host_* mkdir /dev /run /tmp touch /dev/null exit
เปลี่ยนสิทธิ์ของไฟล์ที่สร้างให้สามารถ execute ได้โดยใช้ chmod
chmod +x /tmp/deb/tmp/client.sh
จากนั้นใช้ chroot ในการติดตั้ง template
chroot /tmp/deb /tmp/client.sh
เมื่อเสร็จเรียบร้อยให้เข้าไปยังไดเรคทอรี /tmp/deb และทำการบีบอัด template โดยใช้ tar
cd /tmp/deb
tar -czpf /tmp/ubuntu-14.10-x86_64-initial1.tar.gz .
จากนั้น copy template ที่ได้ ไปไว้ที่ /var/lib/vz/template/cache บนเครื่อง proxmox
ลองสร้าง OpenVZ Template จะเห็น template ที่เราสร้างขึ้นแล้ว