Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Setting_Up_Vagrant_VM_with_GUI.pdf

ghemant
June 27, 2016
56

 Setting_Up_Vagrant_VM_with_GUI.pdf

ghemant

June 27, 2016
Tweet

Transcript

  1. How to create a Vagrant Base Box with VirtualBox and

    Ubuntu. Step 1: Create the Virtual Machine with Virtual Box - Install VirtualBox , from the website: https://www.virtualbox.org/ on your host system. - Download Ubuntu 64bit Desktop ISO from here: http://www.ubuntu.com/download/desktop - Load the ISO as part of the VM storage and install the OS. - Set the Username and Password as: vagrant - Once installed unload the ISO and restart the VM. - Install the "Guest Additions" Guest Additions will prepare your guest system to create external kernel modules.
  2. Step2: How to change resolution of the Ubuntu guest on

    VirtualBox Run the following command in the terminal: $ sudo apt-get install virtualbox-guest-utils virtualbox-guest-dkms And then restart the VM OS i.e. Ubuntu.
  3. Step 3: Setup the guest OS i.e. Ubuntu 64bit with

    the minimum necessary. - Use "Software Updater" to get latest updates. - Add the vagrant user to sudoers file: $ sudo su – $ visudo # Add the following line to the end of the file. vagrant ALL=(ALL) NOPASSWD:ALL - Install Vagrant Public Keys: This would enable SSH to the machine without entering the password: $ mkdir -p /home/vagrant/.ssh $ wget --no-check-certificate https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys # Ensure we have the correct permissions set $ chmod 0700 /home/vagrant/.ssh $ chmod 0600 /home/vagrant/.ssh/authorized_keys $ chown -R vagrant /home/vagrant/.ssh
  4. Step 3: Contd… - Install OpenSSH Server $ sudo apt-get

    install -y openssh-server $ sudo vi /etc/ssh/sshd_config Ensure the following configuration is enable i.e. doesn’t contain # at the start of line: Port 22 PubKeyAuthentication yes AuthorizedKeysFile %h/.ssh/authorized_keys PermitEmptyPasswords no And restart the ssh service after saving the sshd_config. $ sudo service ssh restart
  5. Step 4: Package the Box Compact space and shut the

    VM down. Execute the following commands to save space and shut the VM down: $ sudo dd if=/dev/zero of=/EMPTY bs=1M $ sudo rm -f /EMPTY # Shutdown the machine $ sudo shutdown -h now - Create Vagrant Base Box Asuming you have Vagrant installed in the host system already, just run the following command: $ vagrant package –-base <VitualBox VM Name> this will create a file called package.box - Install the box $ vagrant box add {boxname} package.box
  6. Step 5: Vagrant up the packaged Box - Go to

    a different folder to Init a Vagrant Box by referencing the Base box we have created: $ vagrant init {boxname} - Enable GUI by editing the generated Vagrantfile by adding the following lines: config.vm.provider "virtualbox" do |v| v.gui = true end
  7. and you should be able to SSH the machine and

    see the VM running by doing: $ vagrant up