Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

Creating a template cache : Slackware or HostGIS Linux

160 bytes added, 10:55, 19 October 2009
ā†’ā€ŽZipping it up into a cache image: use --numeric-owner option for tar
== Creating a new Host Template Cache for HostGIS Linux 4.x or Slackware 11.x/12.x == This process uses VMWare VMware to install the OS into a VM, then to trim down the VM's contents to only those items suitable for a VPS/[[VE ]] environment, then to save a snapshot of the system as a host template cache for use in OpenVZ.
This document focuses on HostGIS Linux (a Slackware derivative) but aside from the specifics about installation settings, it should be 99% applicable to Slackware as well.
=== Create the VM in VMWare =VMware ==
Technically, you could probably do this on a hardware PC without VMWareVMware, but VMWare VMware does make it more convenient.
Start by creating a new VM in VMWareVMware.
* The disk and RAM stats can be minimal, as the system will never see live use.
* There is no need to create the entire disk at once during the setup.
* Do set the timezone properly. The internal clock does not use UTC/GMT.
* Select the default mouse, but do NOT enable GPM at startup.
* Hostname: template * Domain: internal.lan* IP config: as appropriate for your LAN
* Nameserver: no
Reboot into your new HGL install, and log in.
 
== Delete unnecessary stuff ==
A lot of packages aren't relevant to a VPS VŠ• setting, e.g. floppy disk utilities and kernel modules, even getty listening on the console.
<code>
rm -rf /lib/modules /boot /dev/.udev /usr/doc /usr/info /media
# packages not applicable to a VPS settingVE
cd /var/log/packages
for pkg in \
mv /etc/ssl/openssl.cnf /tmp ; rm -r /etc/ssl/* ; mv /tmp/openssl.cnf /etc/ssl
# fix file permissionsset an ownership on any unowned files
find / -mount -nouser -exec chown root {} \; &
find / -mount -nogroup -exec chgrp root {} \; &
 
# remove the setuid bit from programs which nobody else should use
# you may want to review this list first, as some folks want their users
# able to edit cronjobs and to change their own passwords, etc.
for i in \
/bin/ping /bin/mount /bin/ping6 /bin/umount /usr/bin/chfn \
do chmod u-s $i ; done
</code> 
== Changes to rc scripts ==
OpenVZ emulates rebooting with an external cronjob called vpsreboot and a dummy file called /reboot within the VPSVE, and emulates the /etc/mtab file by pointing it to /proc/mounts So, some small changes are necessary to the rc scripts.
<code>
# somewhere in rc.6 add this command: touch /reboot vi /etc/rc.d/rc.6
# somewhere in rc.M, add this command: rm -f /etc/mtab ; ln -s /proc/mounts /etc/mtab vi /etc/rc.d/rc.M
</code>
 
== Blanking settings ==
== Zipping it up into a cache image ==
A VE CT cache is just a tar.gz file of the entire filesystem, excluding some very dynamic stuff which gets populated by the OS at runtime anyway: <code>
tar --numeric-owner -zcvf /tmp/HostGIS_Linux_4.2_64bit.tar.gz --exclude='/sys/*' --exclude='/proc/*' --exclude='/tmp/*' /
</code>[[Category: Templates]]