Sam Trenholme's webpage

Tiny OpenVZ template

Please do not confuse this OpenVZ template with RamHost’s TinyVZ low cost hosting

April 3, 2013

Update

I have added a “DNS toaster” template: TinyVZ-0.7.02Deadwood.tar.gz (sig) Warning This is an OpenVZ template and it will create a number of folders and files in the directory it is extracted to. If extracting this by hand, be sure to do so in an empty directory. Since this is a template, it will need files included with TinyVZ-0.7.02.tar.gz to function, as well as OpenVZ.

Instructions for setting up the DNS toaster are included in the template file.

Other services can be set up to start at container start time by being added by hand to /etc/sysinit.sh.

About

One issue I have had with OpenVZ is that there is not a small template based on Busybox out there. So, in the spirit of open source, I solved this problem by making my own tiny OpenVZ template based on Busybox and uClibc.

TinyVZ is a tiny OpenVZ template. This allows OpenVZ users to have a container that uses far fewer resources than a container built from a traditional Linux distribution. The goals are to have a system that uses less memory and disk space than other OpenVZ templates.

This is a self-hosting template with all source code; it is possible to compile the entire system inside of the template. Look in the build/ directory (inside the template) for source code.

The system includes the following packages:

  • Bash
  • binutils
  • Bison
  • busybox
  • gcc
  • m4
  • make
  • maradns
  • uClibc
This Linux distribution is based on some work I did back in 2007 making a miniature Linux system that fits on a business card CD. Since this is based on work from a few years ago, the programs and libraries are older releases (this is also why a lot of files refer to this system as "Moam CD"). Updating the system's toolchain is left as an exercise to the reader. Yes, I did check, and there does not appear to be any glaring security holes with this setup (there is a minor security issue with the example scripts included with Bash's source, but this does not merit an update since none of those scripts are installed in TinyVZ). Yes, the version of uClibc is recent enough to support the changes made to daylight savings time in 2005.

The system is for hard core UNIX/Linux gurus: The only editor is a miniature version of vi included with Busybox (actually, I also compiled in Busybox's version of the "ed" editor, for those who feel vi pampers the user too much); all configuration is done by editing text files.

It is now possible to use the relevant vzctl commands to set the IP, username/password, hostname, and DNS nameservers used. Note that vzctl 3.0.28 or higher is required to run this template.

The only unpaid support I supply for TinyVZ at this time is to fix security problems with a CVE vulnerability number that affect compiled programs outside of the /build tree. CVE 2010-0001 has been patched; other CVE issues have not been patched because they do not appear to be serious security issues that affect TinyVZ. Details are in the file build/CVE inside of the container.

It can be downloaded here:

http://samiam.org/TinyVZ/TinyVZ-0.7.02.tar.gz GPG sig

Errata

I discovered a bug in the script /sbin/add_ip.sh (inside of the container) causing the same IP to be added multiple times to /etc/iplist. This bug is not serious enough to merit a new release of TinyVZ (Note This bug has been fixed in the TinyVZ-0.7.02Deadwood template); people who wish to not have this bug can use the following revised add_ip.sh file (changes to fix bug are in bold):
#!/bin/sh

# Copyright 2011 Sam Trenholme.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

# POSIX-compatible script for adding an IP to the TinyVZ container

for ip in $IP_ADDR ; do
	if ! grep $ip /etc/iplist > /dev/null ; then
		echo IPLIST=\$IPLIST\" $ip\" >> /etc/iplist
	fi
done

# Reset all IPs
ifconfig venet0 down

. /etc/iplist

NUMBER=0
for IP in $IPLIST ; do
	if [ $NUMBER -gt 0 ] ; then
		ifconfig venet0:$NUMBER $IP
	else
		ifconfig venet0 $IP
	fi
	NUMBER=$( expr $NUMBER + 1 )
done

route add -net 0.0.0.0 dev venet0