Array Setup and Networking

Cloning RHEL VM or Boot Volume

New Member

Cloning RHEL VM or Boot Volume

One great feature of virtual machines and UCS service profiles is the ability to easily set up a golden image or VM, then clone new instances to rapidly provision.  This can make administrative tasks easier, as we do not need to PXE boot or kickstart new images.  Additionally, if done using thin provisioning or zero copy clones, the new instance will take up almost 0 space.

When cloning an instance of RHEL, or converting to a template, it is important to first remove any old log data and make the instance unique.  Also, you will want your network interfaces to actually work when you bring the clone online.  One great resource I have found that lays out many steps necessary comes from The Lone Sysadmin:

Preparing Linux Template VMs – The Lone Sysadmin

I have taken his steps and simplified them into a simple copy paste of plain text here:

/sbin/service rsyslog stop

/sbin/service auditd stop

/bin/package-cleanup --oldkernels --count=1

/usr/bin/yum clean all

/usr/sbin/logrotate -f /etc/logrotate.conf

/bin/rm -f /var/log/*-???????? /var/log/*.gz

/bin/rm -f /var/log/dmesg.old

/bin/rm -rf /var/log/anaconda

/bin/cat /dev/null > /var/log/audit/audit.log

/bin/cat /dev/null > /var/log/wtmp

/bin/cat /dev/null > /var/log/lastlog

/bin/cat /dev/null > /var/log/grubby

/bin/rm -f /etc/udev/rules.d/70*

/bin/sed -i ‘/^(HWADDR|UUID)=/d’ /etc/sysconfig/network-scripts/ifcfg-eth0

/bin/sed -i ‘/^(HWADDR|UUID)=/d’ /etc/sysconfig/network-scripts/ifcfg-eth1

/bin/sed -i ‘/^(HWADDR|UUID)=/d’ /etc/sysconfig/network-scripts/ifcfg-eth2

/bin/rm -rf /tmp/*

/bin/rm -rf /var/tmp/*

/bin/rm -f /etc/ssh/*key*

/bin/rm -f ~root/.bash_history


/bin/rm -rf ~root/.ssh/

/bin/rm -f ~root/anaconda-ks.cfg

Happy Cloning!


Esteemed Contributor

Re: Cloning RHEL VM or Boot Volume

Thanks for the share Mr Bell!