09 Nov

Vagrant | Advanced

Build a custum Vagrant Box

Install Linux in Virtual Box

Run sudo without password

Create file /etc/sudoers.d/vagrant


Build Package

$ vagrant package --base <NAME_OF_VM> --output <OUTPUT_BOX_NAME>.box

For example:

$ vagrant package --base ubuntu_16.10_32 --output ubuntu_16.10_32.box

Add custom Vagrant Box to local vagrant repository

$ vagrant add box ubuntu_16.10_32 package/ubuntu_16.10_32.box

Build Vagrant Box from mac OS Installation Disk

First, run the following command to create a blank disk image:
hdiutil create -o /tmp/HighSierra.cdr -size 7316m -layout SPUD -fs HFS+J

Next, mount your blank image:

hdiutil attach /tmp/HighSierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build

Now you’re going to restore BaseSystem.dmg from the installer over to the newly mounted image:

asr restore -source /Applications/Install\ macOS\ High\ Sierra.app/Contents/SharedSupport/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase

Note: Name of destination mount point has changed to “OS X Base System/System.”
Unmount the image:

hdiutil detach /Volumes/OS\ X\ Base\ System

And, finally, convert the image you created into an ISO file:

hdiutil convert /tmp/HighSierra.cdr.dmg -format UDTO -o /tmp/HighSierra.iso

Move the ISO to the desktop:

mv /tmp/HighSierra.iso.cdr ~/Desktop/HighSierra.iso

And you’ve got a bootable High Sierra ISO file!


01 Okt

Vagrant | Getting started


Installing VirtualBox

Install VirtualBox on Linux
$ sudo apt-get install virtualbox
Install VirtualBox on Mac OS
$ brew cask install virtualbox

Install Vagrant

Install VirtualBox on Linux
$ sudo apt-get install vagrant
$ sudo apt-get install virtualbox-dkms
Install VirtualBox on Mac OS
$ brew cask install vagrant
$ brew cask install vagrant-manager
$ brew cask install vagrant-completion

First Steps

Getting vagrant machine up

 $ vagrant box add precise32 http://files.vagrantup.com/precise32.box
$ vagrant box add hashicorp/precise64 

Configure Project

$ mkdir vagrant_project 
$ cd vagrant_project


Configure Vagrant environment

Running X Clients

Allow X-Forwarding

Vagrant.configure(2) do |config|
config.ssh.forward_x11 = true

Check ssh config

$ vagrant ssh-config
Host some_site
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
ForwardX11 yes

Run a X client

$ vagrant ssh
vagrant@vagrant: $ sudo apt-get install xclock
vagrant@vagrant: $ exit
$ ssh -X -p 2222 vagrant@localhost xclock

Setup Vagrant box

Setup with on command

$ vagrant init hashicorp/precise64

Setup manuell

$ vagrant init

Edit the Vagrantfile in this directory and replace

config.vm.box = "precise32"

Start Environment

Start Vagrant box

$ vagrant up

Connect using SSH

$ vagrant ssh

Stop working with Vagrant

$ vagrant halt