-
Notifications
You must be signed in to change notification settings - Fork 2
Creating An openSUSE 11.3 x32 Vagrant Box





























Once the installation is complete, it should reboot and come up running the operating system. Login as the vagrant user and shut it down:
sudo /sbin/shutdown -hP now && exitYou might want to take a sanity snapshot backup at this point in case things go sideways. I've used a snapshot called "First boot". Now, power it back up and login with the vagrant user.
Login as the vagrant user. First let's fix up the sudoers file to remove password prompts:
sudo /usr/sbin/visudoAfter these lines:
# User privilege specification root ALL=(ALL) ALL
Add this:
vagrant ALL=(ALL) NOPASSWD: ALL
Save and exit.
Updating the hostname has 3 steps. First update /etc/HOSTNAME:
sudo bash -c "echo 'vagrant-opensuse-11_3x32' > /etc/HOSTNAME"Then change the last line of /etc/hosts (the one starting with "127.0.0.2") to:
127.0.0.2 vagrant-opensuse-11_3x32.site vagrant-opensuse-11_3x32
Finally use hostname to set it until next reboot:
sudo hostname vagrant-opensuse-11_3x32Now logout and log back in as the vagrant user.
openSUSE uses your device ID by default when it refers to its hard disks. Unfortunetly when VirtualBox clones a new machine these values update and you get a nasty "Waiting for device /dev/disk/by-id/...-part2" error. To fix this, we'll update fstab and menu.lst to reference by classic /dev/sda* device identifiers.
Edit /etc/fstab to replace this:
/dev/disk/by-id/ata-VBOX_HARDDISK_VBxxxx-xxxx...-part1 swap swap defaults 0 0 /dev/disk/by-id/ata-VBOX_HARDDISK_VBxxxx-xxxx...-part2 / ext4 acl,user_xattr 1 1 /dev/disk/by-id/ata-VBOX_HARDDISK_VBxxxx-xxxx...-part3 /home ext4 acl,user_xattr 1 2
with this:
/dev/sda1 swap swap defaults 0 0 /dev/sda2 / ext4 acl,user_xattr 1 1 /dev/sda3 /home ext4 acl,user_xattr 1 2
Similarily, edit /boot/grub/menu.lst to replace this (↵ character shows code continuing on one line but split for display on page):
kernel /boot/vmlinuz-2.6.34.7-0.7-default ↵ root=/dev/disk/by-id/ata-VBOX_HARDDISK_VBxxxx-xxx-part2 ↵ resume=/dev/disk/by-id/ata-VBOX_HARDDISK_VBxxxx-xxx-part1 ↵ splash=silent quiet showopts vga=0x314
with this:
kernel /boot/vmlinuz-2.6.34.7-0.7-default ↵ root=/dev/sda2 resume=/dev/sda1 ↵ splash=silent quiet showopts vga=0x314
The second issue is that openSUSE identifies the network card by its MAC address by default which also gets changed on a clone. To fix, we'll dive into the yast interface:
sudo /sbin/yast- Choose the Network Devices menu
- Choose the Network Settings submenu
- Select the 82540EM Gigabit Ethernet Controller (should be the only device) and choose Edit
- Choose the Hardware tab
- In the Udev rules section choose Change
- Choose BusID from the menu and choose OK
- Choose Next back out in the Network Settings page
- Choose OK
- Choose Quit
Big thanks to Ján Kupec for his blog post which saved me from the agonizing confusion.
Now update the system and reboot.
sudo zypper --non-interactive refresh
sudo zypper --non-interactive up
sudo /sbin/shutdown -r now && exitInstall some pre-requisites needed for the Guest Additions package and remove the system-installed package:
sudo zypper --non-interactive install make gcc
sudo zypper --non-interactive install kernel-default-devel
sudo zypper --non-interactive remove virtualbox-ose-guest-kmp-default \
virtualbox-ose-guest-tools xorg-x11-driver-virtualbox-oseNow mount the Guest Additions from the Devices -> Install Guest Additions VirtualBox menu. Next, mount the iso and install the additions:
sudo mkdir -p /media/cdrom
sudo mount /dev/cdrom /media/cdrom
(cd /media/cdrom && sudo sh VBoxLinuxAdditions.run)
sudo umount /media/cdromNote: The installer will complain about not finding "the X.Org or XFree86 Window System" which is fine and expected.
Remove the disk from the virtual drive by clicking the CD-ROM icon and choosing from the flyout menu.
Install the public key that Vagrant uses when SSHing into the virtual machine:
sudo zypper --non-interactive install curl
mkdir -p ~/.ssh
chmod 0700 ~/.ssh
curl -o ~/.ssh/authorized_keys \
https://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub
chmod 0600 ~/.ssh/authorized_keys Edit the sshd configuration to prevent DNS resolution (speedup logins):
sudo bash -c "echo 'UseDNS no' >> /etc/ssh/sshd_config"Thankfully, openSUSE comes with a decently up to date ruby (1.8.7) and a non-crippled rubygems (currently 1.3.7), so this is straight forward:
sudo zypper --non-interactive install ruby ruby-devel rubygemsInstall the chef and puppet gems so they are ready for the provisioners:
sudo gem install chef --no-ri --no-rdoc
sudo gem install puppet --no-ri --no-rdocModify the message of the day (to match the default Vagrant box):
sudo bash -c "echo 'Welcome to your Vagrant-built virtual machine.' > /etc/motd"Run one last update and cleanup:
sudo zypper --non-interactive refresh
sudo zypper --non-interactive upFinally, shutdown the virtual machine:
sudo /sbin/shutdown -hP now && exitNow is a good time to kill off any temporary snapshots taken on the virtual machine.
Follow the instructions on the Vagrant website to package up the box. From your workstation:
mkdir -p ~/vagrant_box_opensuse11.3x32
(cd ~/vagrant_box_opensuse11.3x32 && vagrant package --base opensuse11.3x32)
mv ~/vagrant_box_opensuse11.3x32/package.box ~/vagrant_box_opensuse11.3x32/opensuse11.3x32.boxNow take ~/vagrant_box_opensuse11.3x32/opensuse11.3x32.box and store on a network drive or share on a web server (whatever your distribution requirements dictate).