Create CentOS 7 image for Vagrant / VMware Fusion

  1. Generate SSH key pair without a passphrase to be used by Vagrant
    • eg.  ssh-keygen -t rsa -C “barrowkwan@yahoo.com” -f ~/.ssh/vagrant_rsa
    • Screen Shot 2015-04-28 at 11.34.10 AM
  2. Create a github repository and upload your public key
  3. Folk my Kickstart script from github and change line 60 in centos7.txt file to point to your raw SSH key on github.
    • Screen Shot 2015-04-28 at 11.34.57 AM
  4. Download CentOS 7 DVD ISO from CentOS site
  5. Create a new Virtual Machine in Fusion and choose “Install from disc or image”
    • Screen Shot 2015-04-28 at 11.41.39 AM
  6. Choose the ISO file you have download from CentOS site
    • Screen Shot 2015-04-28 at 11.42.32 AM
  7. Uncheck “Use Easy Install”
    • Screen Shot 2015-04-28 at 11.44.13 AM
  8. If you want to change the name of your Virtual Machine, click “Customize Settings”.
    • Screen Shot 2015-04-28 at 11.46.38 AM
  9. Remove “Printer Port”, “Sound Card” and “Camera”
  10. Disable “Share Bluetooth devices with Linux”
    • Screen Shot 2015-04-28 at 11.50.07 AM
  11. Under “Isolation”,  disable “Drag and Drop” and “Copy and Paste”
    • Screen Shot 2015-04-28 at 11.51.46 AM
  12. Under “Hard Disk”, uncheck “Split into multiple files” and change the disk size to 40G.  ( Make sure to click “Apply” after these changes )
    • Screen Shot 2015-04-28 at 11.53.15 AM
  13. Change the “Startup Disk” to “CD/DVD”, then click “Restart”
    • Screen Shot 2015-04-28 at 11.55.07 AM
  14. Press “Tab” in the “CentOS 7” screen and add “noverifyssl ks=https://raw.githubusercontent.com/barrowkwan/linux_kickstart_script/master/centos7.txt” at the end of “vmlinuz” line and hit “Enter”.  ( Make sure you change the URL to point to the github repos you forked ).
    • Screen Shot 2015-04-28 at 11.59.08 AM
  15. After the installation is done, the VM will shutdown.  In Settings menu, double click “CD/DVD (IDE)” and uncheck “Connect CD/DVD Drive”
    • Screen Shot 2015-04-28 at 1.16.52 PM
  16. In Settings menu, double click “Startup Disk” and change the device to “Hard Disk (SCSI)” and click “Restart”
    • Screen Shot 2015-04-28 at 1.07.11 PM
  17. After VM boot, login as root ( password is vagrant )
  18. The VM should be up-to-date but just in case, run “yum update”
    • Screen Shot 2015-04-28 at 1.12.24 PM
  19. Go to menu “Virtual Machine” and choose “Install VMware Tools”
    • Screen Shot 2015-04-28 at 1.13.31 PM
  20. Execute “mount /dev/cdrom /mnt” to mount the VMware Tools CD
    • Screen Shot 2015-04-28 at 1.15.28 PM
  21. Exceute “tar zxvf /mnt/VMwareTools-9.9.2-2496486.tar.gz -C /tmp”  ( Depends on the version of your Fusion, VMwareTools might have a different filename )
    • Screen Shot 2015-04-28 at 1.23.46 PM
  22. Change the execution bit of vmware installation script and run the script
    • chmod 755 /tmp/vmware-tools-distrib/vmware-install.pl
    • /tmp/vmware-tools-distrib/vmware-install.pl
    • Screen Shot 2015-04-28 at 1.25.24 PM
  23. Use default for all questions asked by the script except “Would you like to enable VMware automatic kernel modules”, type “yes” for this option.
    • Screen Shot 2015-04-28 at 1.28.02 PM
  24. After the install is done, you will need to run the vmware-config-tools.pl again to compile the HGFS kernel module.   Use default for all questions asked by the config script.
    • Screen Shot 2015-04-28 at 1.31.30 PM
  25. After the script is done, clean up the vm and shut it down.
    • rm -rf /tmp/* /var/log/wtmp /var/log/btmp
    • history -c
    • Screen Shot 2015-04-28 at 1.34.47 PM
  26. Open a terminal on your Mac and go to the directory where your VM is installed. ( eg /Users/barrowkwan/Documents/Virtual Machines.localized/CentOS 7 Vagrant 64-bit.vmwarevm )
  27. Execute the following two commands in order
    • /Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -d Virtual\ Disk.vmdk
    • /Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -k Virtual\ Disk.vmdk
    • Screen Shot 2015-04-28 at 1.38.37 PM
  28. create a file called “metadata.json” with the content below:
    • { “provider” : “vmware_fusion” }
    • Screen Shot 2015-04-28 at 1.41.01 PM
  29. Remove all vmware log and create vagrant image
    1. rm -rf vmware*.log
    2. tar zcvf ../centos7.box ./*
    3. Screen Shot 2015-04-28 at 1.45.24 PM
  30. Add the image to vagrant
    1. vagrant box add centos7-vagrant-x86_64 ../centos7.box
    2. Screen Shot 2015-04-28 at 1.47.59 PM
This entry was posted in CentOS, Vagrant, VMware Fusion and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s