J'aime pas les piles

My lost place

Creating Vagrant Base Boxes

| Comments

Create a VM inside VirtualBox

  • No usb
  • No audio
  • One dynamic disk (10GiB)
  • 512 MiB of RAM
  • One vcpu
  • One network card in NAT mode

Install the base system, as minimal as possible

Scientific Linux 5

  • Retrieve ISOs CD 1 and 2
1
wget http://ftp1.scientificlinux.org/linux/scientific/5x/iso/x86_64/cd/SL.510.110513.CD.x86_64.disc{1,2}.iso
  • Boot CD
  • Use basic video driver installation
  • Use default configuration
    • except:
      • DHCP for ipv6
      • Deselct every packages sets
  • Use vagrant as root password

Scientific Linux 6

  • Retrieve netinstall ISO CD
1
wget http://ftp.scientificlinux.org/linux/scientific/6x/x86_64/iso/SL-64-x86_64-2013-03-18-boot.iso
  • Boot CD
  • Use network install URL:
  • Use default configuration
  • Use vagrant as root password

Debian 7: retrieve netinstall ISO CD

1
wget http://cdimage.debian.org/debian-cd/7.3.0/amd64/iso-cd/debian-7.3.0-amd64-netinst.iso

System configuration

Scientific Linux 5/6

  • Update system and reboot if kernel was updated
1
2
yum clean all && yum update -y
reboot
  • Add a vagrant user with vagrant as password
1
2
adduser vagrant
passd vagrant
  • Configure password-less sudo for vagrant user
1
2
3
visudo
Default:vagrant !requiretty
vagrant ALL=(ALL) NOPASSWD: ALL
  • Configure ssh server
1
sed -i 's/^#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
  • Configure ssh authorized_keys for vagrant user
1
2
3
4
5
6
mkdir ~vagrant/.ssh
curl -o ~/vagrant/.ssh/authorized_keys \
  https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub
chmod 0700 ~vagrant/.ssh
chmod 0600 ~vagrant/.ssh/authorized_keys
chown -R vagrant:vagrant ~vagrant/.ssh

Scientific Linux 6

Minimal SL6 install does not install acpid nor perl

1
2
yum install -y acpid perl
service acpid start

VirtualBox Additions installation

Scientific Linux 5/6

  • Insert Guest additions CD image using VirtualBox device menu
  • Install required software for build the VirtualBox additions
1
yum install -y gcc make kernel-devel
  • Build and install VirtualBox additions

Error about OpenGL or Window System drivers are “normal”.

1
2
3
mount /dev/cdrom /mnt
sh /mnt/VBoxLinuxAdditions.run
umount /mnt

Cleaning image

Scientific Linux 5/6

1
2
3
4
5
yum clean all
: > /var/log/messages
: > /var/log/secure
: > ~/.bash_history
kill -9 $$

ACPI shutdown VM using VirtualBox Machine menu.

Packing the boxes

Scientific Linux 5

1
2
vagrant package --output sl5-64-VB436-nocm.box --base scientificlinux5
vagrant package --output sl6-64-VB436-nocm.box --base scientificlinux6

Testing the boxes

1
2
vagrant box add sl5-64-nocm sl5-64-VB436-nocm.box
vagrant box add sl6-64-nocm sl6-64-VB436-nocm.box
1
2
3
4
5
6
7
8
9
10
11
mkdir ~/sl5-64-nocm-tests && cd $_
vagrant init sl5-64-nocm
vagrant up
vagrant ssh
ping -c 3 gnu.org
sudo -s
exit
exit
vagrant destroy -f
cd ..
rm -rf ~/sl5-64-nocm-tests
1
2
3
4
5
6
7
8
9
10
11
mkdir ~/sl6-64-nocm-tests && cd $_
vagrant init sl6-64-nocm
vagrant up
vagrant ssh
ping -c 3 gnu.org
sudo -s
exit
exit
vagrant destroy -f
cd ..
rm -rf ~/sl6-64-nocm-tests

Comments