sudo vzctl start 777
== Customizing the installation ==A few things need to be done inside a newly created VE Thanky Thanky for it to become suitable for OpenVZ. Enter the VE to begin the configuration. Exporting the path is optional. sudo vzctl enter 777 export PATH=/sbin:/usr/sbin:/bin:/usr/bin {{Warning|Do not run the commands below on the hardware node, they are only to be run within the VE!}} === Set Debian repositories === cat <<EOF > /etc/apt/sources.list deb http://http.us.debian.org/debian squeeze main contrib deb http://security.debian.org squeeze/updates main contrib deb http://http.us.debian.org/debian squeeze-updates main ## backports - ONLY IF YOU KNOW WHAT YOU DO # deb http://http.us.debian.org/debian-backports/ squeeze-backports main EOF === Get new security updates === apt-get update apt-get upgrade === Install some more packages ===Installing packages could be an interactive process so the system might ask some questions. You can install more packages if you'd like. For example: apt-get install ssh quota less === Set sane permissions for <tt>/root</tt> directory === chmod 700 /root === Disable root login ===This will disable root login by default. usermod -L root === Disable getty ===Disable running <tt>getty</tt>s on terminals as a VE does not have any: sed -i -e '/getty/d' /etc/inittab === Disable <tt>sync()</tt> for syslog ===Turn off doing <tt>sync()</tt> on every write for <tt>syslog</tt>'s log files, to improve I/O performance: <pre>sed -i -e 's@\([[:space:]]\)\(/var/log/\)@\1-\2@' /etc/*syslog.conf</pre> === Fix <tt>/etc/mtab</tt> ===Link <tt>/etc/mtab</tt> to <tt>/proc/mounts</tt>, so <tt>df</tt> and friends will work: rm -f /etc/mtab ln -s /proc/mounts /etc/mtab === Remove some unneeded packages ===If you have any packages you'd like to remove, now's the time for it. Here's an example — note that not all of those packages are installed by default in Debian Squeeze (although they were in earlier versions): dpkg --purge modutils ppp pppoeconf pppoe pppconfig module-init-tools === Disable services ===Do not start some services, stick to bare minimum: update-rc.d -f klogd remove update-rc.d -f quotarpc remove update-rc.d -f exim4 remove update-rc.d -f inetd remove For dependency-based boot sequence introduced with Squeeze type: update-rc.d-insserv -f klogd remove update-rc.d-insserv -f quotarpc remove update-rc.d-insserv -f exim4 remove update-rc.d-insserv -f inetd remove === Fix SSH host keys ===This is only useful if you installed SSH. Each individual [[VE]] should have its own pair of SSH host keys. The code below will wipe out the existing SSH keys and instruct the newly-created [[VE]] to create new SSH keys on first boot. <!-- please do not remove <source>...</source> pair of tags below, otherwise quotes after -N (-N '') are not visible --><source lang="bash">rm -f /etc/ssh/ssh_host_*cat << EOF > /etc/rc2.d/S15ssh_gen_host_keys#!/bin/bashssh-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 \$0EOFchmod a+x /etc/rc2.d/S15ssh_gen_host_keys</source> {{Note|This will not work using the dependency-based boot sequence introduced with Squeeze. See the section below. }} === Fix SSH host keys in Squeeze when using dependency-based booting === rm -f /etc/ssh/ssh_host_*<!-- please do not remove <source>...</source> pair of tags below, otherwise quotes after -N (-N '') are not visible --><source lang="bash">cat << EOF > /etc/init.d/ssh_gen_host_keys#this good ifomnration!/bin/sh### BEGIN INIT INFO# Provides: Generates new ssh host keys on first boot# Required-Start: $remote_fs $syslog# Required-Stop: $remote_fs $syslog# Default-Start: 2 3 4 5# Default-Stop:# Short-Description: Generates new ssh host keys on first boot# Description: Generates new ssh host keys on first boot### END INIT INFOssh-keygen -f /etc/ssh/ssh_host_rsa_key -t rsa -N ""ssh-keygen -f /etc/ssh/ssh_host_dsa_key -t dsa -N ""insserv -r /etc/init.d/ssh_gen_host_keysrm -f \$0EOF</source> chmod a+x /etc/init.d/ssh_gen_host_keys insserv /etc/init.d/ssh_gen_host_keys === Change timezone === You might want to change timezone if you do not live in $UTC. The following example is for Germany <source lang="bash">ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime</source>or even better<source lang="bash">dpkg-reconfigure tzdata</source> === Clean packages ===After installing packages, you'll have some junk packages laying around in your cache. Since you don't want your template to have those, this command will wipe them out. apt-get --purge clean Now everything is done. Exit from the template and go back to the hardware node. exit
== Preparing for and packing template cache ==