Skip to content

Instantly share code, notes, and snippets.

@elmariofredo
Created October 17, 2012 15:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elmariofredo/3906044 to your computer and use it in GitHub Desktop.
Save elmariofredo/3906044 to your computer and use it in GitHub Desktop.
CentOS Box for Vagrant

Installing CentOS 6

Based on

Download net install iso:

Create a new VirtualBox machine

  • Name: vagrant-centos
  • Operating System: Linux
  • Version: Red Hat
  • Base Memory Size: 512 MB
  • Create new hard disk
  • Dynamically expanding storage
  • 40 GB
  • Disable Audio
  • Disable USB
  • Make sure network is set to NAT
  • Attach the net install ISO to the CDROM
  • Run it

Run through install procedure

  • (mode: linux text)
  • Disable IPv6, leave IPv4 enabled with DHCP
  • Use text mode
  • Initialize drive and erase data: yes
  • Configure network: yes
    • Set hostname to vagrant-centos
  • Root password: vagrant
  • Customize software installation:
    • Unselect:
      • Dial-up networking
      • Editors
      • Text-based internet
      • Base
  • Remove CDRom media
  • Reboot
  • Disable firewall
  • Run Services:
    • Disable cups

Log in via ssh

VBoxManage modifyvm “VM name” –natpf1 “guestssh,tcp,,2222,,22”

Add stuff

yum update yum install curl ftp rsync sudo time wget which

yum install gcc bzip2 make kernel-devel-`uname -r`

yum install gcc-c++ zlib-devel openssl-devel readline-devel sqlite3-devel

Install ruby

sudo rpm -Uvh http://rbel.frameos.org/rbel6 sudo yum install ruby ruby-devel ruby-ri ruby-rdoc ruby-shadow gcc gcc-c++ automake autoconf make curl dmidecode

Install chef

Disable Services

  • chkconfig iptables off
  • chkconfig ip6tables off
  • chkconfig iscsi off
  • chkconfig auditd off
  • chkconfig iscsid off
  • chkconfig fcoe off
  • chkconfig lldpad off
  • chkconfig netfs off
  • chkconfig nfslock off
  • chkconfig rpcbind off
  • chkconfig rpcidmapd off
  • chkconfig rpcgssd off

Remove stuff

  • yum erase wireless-tools gtk2 libX11 hicolor-icon-theme avahi freetype bitstream-vera-fonts selinux*
  • rm -rf /etc/selinux
  • rm -rf $(ls -1ad /lib/modules/* | grep -v `uname -r`)
  • rm -rf $(ls -1ad /boot/* | grep -v `uname -r`)
  • rm -f /usr/lib/locale/locale-archive
  • rm -rf /usr/share/doc
  • rm -rf /usr/share/info
  • rm -rf /usr/share/man
  • rm -rf /usr/share/wallpapers

VirtualBox Additions

  • Devices -> Install Guest Additions…
  • sudo mount -o ro -t iso9660 /dev/cdrom /mnt
  • sudo sh /mnt/VBoxLinuxAdditions.run
  • Error about Xwindows install - should be okay (?)

vagrant user

  • groupadd admin
  • useradd -G admin vagrant
  • passwd vagrant

-# choose “vagrant” as the password -# set up sudo permissions: visudo -# Add the following lines at the bottom: -# # Vagrant user should be able to sudo -# %admin ALL=NOPASSWD: ALL

-# Comment out the following line: -# Defaults requiretty -# (otherwise ssh <command> doesn’t work)

-# Add the variable “PATH” to the “Defaults env_keep” list. -# (otherwise sudo cleans the path, and loses ruby, which ohai needs) -# (See http://stackoverflow.com/questions/257616)

-# Add the usr/sbin and /sbin to the path: echo ‘export PATH=$PATH:/usr/sbin:/sbin’ >> ~vagrant.bashrc

Log out as root, log in as vagrant

Add Vagrant’s “insecure” public key

Fiddle with MAC addres

  • sudo /sbin/ifconfig
  • write down MAC address of eth0 (eg. 08:00:27:60:AE:41)

sudo yum clean headers packages dbcache expire-cache

  • shut down vm

Export and package

  • vagrant package –base vagrant-centos –vagrantfile CentOS-6.3-x86_64-minimal.box
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment