Tuesday, May 8, 2012

Few things to take care while building vagrant boxes

Following are some of the tricks that were useful to me while creating Oracle Enterprise Linux vagrant box.
Create vm using VDI format for easy handling.
Make sure you have removed all the extraneous packages from the installed vm.
You can check out package descriptions at pkgs.org
yum remove X11
yum list installed | grep gnome

Also ensure that yum installs only relevant language support
Edit /etc/rpm/macros.lang and include
%_install_langs en:fr

Shutting/removing certain services
chkconfig --level 0123456 bluetooth off
chkconfig --level 0123456 cups off
chkconfig --level 0123456 gpm off
chkconfig --level 0123456 hidd off
chkconfig --level 0123456 hplip off
chkconfig --level 0123456 isdn off
chkconfig --level 0123456 nfslock off
chkconfig --level 0123456 nfstat off
chkconfig --level 0123456 pcscd off
chkconfig --level 0123456 portmap off
chkconfig --level 0123456 rcpgssd off
chkconfig --level 0123456 restorecond off
chkconfig --level 0123456 rhnsd off
chkconfig --level 0123456 rpcgssd off
chkconfig --level 0123456 rpcidmapd off
chkconfig --level 0123456 sendmail off
chkconfig --level 0123456 xfs off


Some times VirtualBox guest additions will not install due to discrepancy in the header files
Remove the currently installed kernel header files
  rpm -ev --nodeps kernel-uek-headers

Now attach the iso file to virtual cdrom
 mount /dev/cdrom /mnt; cd /mnt/Server
 rpm -ivh kernel-uek-headers.(what is available)
 This should match with (uname -r)
 cd /; umount /mnt; eject

Finally remove languages support that is not required to further squeeze the size of VM.
rm /usr/lib/locale/locale-archive
cd /usr/lib/locale
ls | grep -v ^en | xargs rm -rf
/usr/sbin/build-locale-archive

To reduce the footprint, do the following on the VM.
dd if=/dev/zero of=/bigemptyfile
sudo rm -rf /bigemptyfile
halt

After shutting down the VM, simply resize the VM file with
VBoxManage modifyhd --compact my_hd.vdi

No comments:

Post a Comment