Vagrant Boxes / VMWare Fusion / CentOS 7

Use one found here: you can use one of those to build upon or you can create one.

These steps are if you want to to create a fresh box.
Grab the latest CentOS image here:

I use the minimal image

First you need to create a VM using Fusion.

  1. Select “Install from disc or image” >> Continue
  2. “Use another disc or disc image” >> Find your iso >> Continue
  3. Uncheck “Use Easy Install” make sure “Make your home folder accessible to the virtual machine is unchecked. >> Continue
  4. Click “Customize Settings” >> Rename your vm and place it somewhere safe.

Settings for new VM:

Make sure sharing is disabled.

Processor & Memory

Screen Shot 2014-12-16 at 1.17.56 PM
Select 1 Processor and 512 MB Memory, this is minimal because not everyone has a system with 16 cores and 64gb of memory.

Make sure everything here is unchecked, Accelerated 3d and Retina Display not needed.

Network Adapter
Make sure “Share with my Mac” is selected.
Screen Shot 2014-12-16 at 1.18.31 PM

Hard Disk
Uncheck “Split into multiple files”
Screen Shot 2014-12-16 at 1.18.49 PM

Sound Card
Click “Remove Sound Card”

USB & Bluetooth
Click “Advance USB options” >> Click “Remove USB Controller”

Click “Remove Printer Port”

Click “Advanced options” >> I use hardware version7, but you can use whatever you feel is necessary. It is the compatibility you are looking for, if you and everyone you are suppling the box is using Fusion 7 leave it alone. If by chance you don’t know who is going to use your box you’ll want to be as compatible as you can.
Screen Shot 2014-12-16 at 1.20.17 PM

Uncheck “Enable Drag and Drop” and “Enable Copy and Paste”
Screen Shot 2014-12-16 at 1.20.28 PM

Installing CentOS:

Select Language.

Installation Destination. Click “Done” >> Begin Installation

Root Password >> Set it to vagrant >> Click “Done” twice.

Click “Reboot”

Install complete.

Configure CentOS:

Login as root password is vagrant.

My ethernet didn’t work so I had to regenerate a MAC address in network settings under the “Network Adapter” pane in Fusion.
Screen Shot 2014-12-16 at 3.31.50 PM

# update yum
yum update
yum groupinstall "Development Tools"
yum install kernel-devel

# vmware tools for guest

curl -O
curl -O

rpm --import
rpm --import

vi /etc/yum.repos.d/vmware-tools.repo

# insert this into file
name = VMware Tools
baseurl =
enabled = 1
gpgcheck = 1

# install
yum install open-vm-tools-deploypkg

# if having problems click install VMWare Tools
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
cp /mnt/cdrom/VMwareTools-9.9.0-2304977.tar.gz /tmp
cd /tmp
tar -C /tmp -zxvf VMwareTools-9.9.0-2304977.tar.gz
cd vmware-tools-distrib

# pay close attention to install process.

# restart
systemctl restart vmtoolsd

# check ssh service should be active
service sshd status

# check firewall service
service firewalld status

# Set SELinux to permissive mode
# Permissive: In Permissive mode, SELinux is enabled but will not enforce the security policy, only warn and log actions. Permissive mode is useful for troubleshooting SELinux issues
sed -i -e 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config

# add vagrant user
useradd vagrant

# switch to vagrant user
su - vagrant

# make ssh directory
mkdir -m 0700 -p /home/vagrant/.ssh

# grab vagrant authorized_keys
curl >> /home/vagrant/.ssh/authorized_keys

# make sure permissions are correct for file
chmod 600 /home/vagrant/.ssh/authorized_keys

# switch back to root

# important step modifying sudoers comment out requiretty
# allows ssh to run sudo commands
sed -i 's/^\(Defaults.*requiretty\)/#\1/' /etc/sudoers

# allows vagrant to use sudo without password entry
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

# clean up
yum clean all
rm -rf /tmp/* /var/log/wtmp /var/log/btmp
history -c

shutdown -h now

Post Configure:

Remove CD/DVD Drive
Screen Shot 2014-12-16 at 6.07.54 PM
Click on “Remove CD/DVD Drive”

Creating a Vagrant Box

cd to where your vmware vm is stored usually its ~/Documents/Virtual\ Machines/

My example

cd /Volumes/VMs/Vagrant\ CentOS 64-bit\ Minimal.vmwarevm

Defrag & Shrink virtual disk.

/Applications/VMware\ -d Virtual\ Disk.vmdk

/Applications/VMware\ -k Virtual\ Disk.vmdk
# add metadata file
vi metadata.json

# add this
    "provider": "vmware_fusion"

# remove log files
rm -f vmware*.log

# finally time to create the box file
tar cvzf ./*

# once done remove metadata.json file
rm -f metadata.json

Adding Vagrant Box

vagrant box add centos-7.0-x86_64-minimal /Volumes/VMs/Vagrant\ CentOS 64-bit\ Minimal.vmwarevm/

A lof of this is from Thornelabs.


Leave a Reply

Your email address will not be published. Required fields are marked *