Skip to main content

Posts

Showing posts from 2018

Create your own customized vagrant base box

  Below are steps to modify the vagrant image and save it for future use 1. Login to you vagrant machine. Here I am taking example of Ubuntu 16.04 vagrant ssh 2. Remove APT cache sudo apt-get clean For Centos you can use  yum clean all 3. Reduce the size of OS sudo dd if=/dev/zero of=/EMPTY bs=1M sudo rm -f /EMPTY 4. Exit from the VM and create vagrant base box vagrant package --output mynew.box Note: You should run the command in same folder where Vagrantfile is located for customized VM 5. Add the mynew.box to vagrant box repository vagrant box add myubuntu16 mynew.box 6. Verify if box is added vagrant box list 7. Now you can deploy your customized VM vagrant init myubuntu16

Useful vagrant commands

1. Deploy OS image vagrant init bento/ubuntu-16.04 2. Power on the VM vagrant up 3. Login to VM vagrant ssh 4. Power off the VM vagrant halt 5. To reboot the VM and or to apply the changes made in vagrant file vagrant reload 6. To provision the node vagrant provision 7. To remove the node completely vagrant destory -f 8. To check the status of all running VMs vagrant global-status

How to use Vagrant with Virtualbox

  Hope that you have installed vagrant and virtualbox in your computer. Below are steps on how to use vagrant command to run linux os on virtualbox Steps: 1. Open powershell in windows or open git bash command prompt 2. Navigate to your project folder Eg cd c:\vms 3. Run init command to create vagrant file and configuration file vagrant init bento/ubuntu-16.04 Note: I want to install ubuntu-16.04. So i have chose bento/ubuntu-16.04 If you want other linux flavours like centos search in https://app.vagrantup.com and replace appropriately. Eg centos/7 4. Below command will power on the virtual machine. vagrant up Note: For the first time this command downloads the image from Internet. 5. Once VM is on you can ssh the VM using below command vagrant ssh Note: By default, user is vagrant and password is vagrant. You can switch to root user using sudo su -