[CentOS-virt] How to create an OpenVZ OS Template for CentOS 7 Public QA

Scott Dowdle dowdle at montanalinux.org
Tue Jun 17 20:18:06 UTC 2014


Greetings,

First start of by working on a physical system, virtual machine, or container that matches the OS Template you are wanting to build.  I used my CentOS 7 Public QA OS OpenVZ container to build it.

You must of course have a working yum.  Once we are beyond Public QA and there is stuff in /etc/yum.repos.d/ this won't be a problem.  One thing to note is that the --enablerepo= must refer to a repo your build host has and viewable via "yum repolist".  That repo should point to the desired CentOS 7 build tree directory.

A note about the package list.  Yes, listed out every individual packcage is tedious.  Perhaps some package groups could be used but they typically drag in a lot of unwanted additional packages.  Suggestions welcome.

Here is a simple script and please don't nag at me because I'm a scripting novice. I hope email client word wrapping and screen sizes don't butcher it too bad:

- - - - -

# To get a package list without version numbers from a target system
# rpm -qa --qf "%{n} " > packages.txt
# Put contents of packages.txt after "-y install \" line below

mkdir /ostemplate

yum \
--installroot /ostemplate \
--nogpg \
--releasever=7 \
--enablerepo=centos7pubqa \
-y install \
centos-release filesystem ncurses-base mailcap tzdata glibc-common xz-libs \
ncurses-libs pcre libselinux info libdb popt sed libcom_err libuuid expat \
libacl libgpg-error dbus-libs gawk lua libxml2 glib2 shared-mime-info apr cpio \
gmp p11-kit tcp_wrappers-libs perl-parent perl-podlators perl-Text-ParseWords \
perl-Pod-Escapes perl-libs perl-threads perl-constant perl-Filter \
perl-Time-Local perl-threads-shared perl-File-Path perl-Scalar-List-Utils \
perl-Getopt-Long libcap-ng nss-softokn libassuan libunistring diffutils gpm-libs \
libnfnetlink keyutils-libs gettext-libs p11-kit-trust nettle \
gobject-introspection vim-minimal pinentry make libselinux-utils ncurses \
libverto libsemanage krb5-libs openldap cracklib libmount systemd-libs libuser \
pam libblkid util-linux python-libs dhcp-libs libcurl python-urlgrabber rpm-libs \
dhcp-common libselinux-python python-iniparse python-chardet yum-metadata-parser \
python-backports-ssl_match_hostname newt-python pyxattr binutils logrotate \
procps-ng mariadb-libs fipscheck-lib openssh libmnl iptables json-c \
device-mapper cryptsetup-libs dbus iputils cronie-anacron crontabs libestr \
gnupg2 rpm-python pygpgme libnl3 yum-utils man-db dhclient audit openssh-server \
libgudev1 net-tools elinks python-pyudev policycoreutils python-configobj \
pygobject3-base sudo wget file tar which psmisc libpcap libsysfs libdaemon lzo \
libgcc setup basesystem kbd-misc bind-license nss-softokn-freebl glibc libstdc++ \
bash libsepol zlib audit-libs nspr chkconfig bzip2-libs nss-util grep libattr \
libcap elfutils-libelf libgcrypt readline libidn libffi pkgconfig sqlite \
groff-base file-libs libtasn1 slang gdbm perl-HTTP-Tiny perl-Pod-Perldoc \
perl-Encode perl-Pod-Usage perl-macros perl-Storable perl-Carp perl-Exporter \
perl-Socket perl-File-Temp perl-PathTools perl-Pod-Simple perl apr-util libcroco \
cyrus-sasl-lib libgomp kmod-libs libedit hostname js newt ca-certificates less \
dbus-glib acl libdb-utils findutils xz sysvinit-tools ustr nss-tools \
openssl-libs gzip cracklib-dicts nss libpwquality coreutils shadow-utils \
libutempter nss-sysinit python libssh2 python-pycurl curl rpm python-decorator \
python-slip dbus-python python-kitchen python-backports python-setuptools \
pyliblzma centos-logos kmod openssl nss_compat_ossl bind-libs-lite fipscheck \
httpd-tools libnetfilter_conntrack iproute qrencode-libs device-mapper-libs \
systemd systemd-sysv initscripts cronie libpipeline pth rpm-build-libs gpgme yum \
libnl3-cli rsyslog mlocate kbd postfix httpd ebtables openssh-clients authconfig \
python-slip-dbus mc gettext screen passwd gnutls elfutils-libs libss nano snappy \
libndp ethtool hardlink rootfiles 

ln -sf /proc/mounts /ostemplate/etc/mtab

# I want Mountain time to be the default
ln -sf /usr/share/zoneinfo/America/Denver /ostemplate/etc/localtime

# Now compress that sucker
cd /ostemplate ; tar -cvJf /root/centos-7-x86_64-viayum.tar.xz . ; cd
ls -lh /root/centos-7-x86_64-viayum.tar.xz
echo "Done building OS Template.  Now test it."

- - - - - 

TYL,
-- 
Scott Dowdle
704 Church Street
Belgrade, MT 59714
(406)388-0827 [home]
(406)994-3931 [work]


More information about the CentOS-virt mailing list