Kickstart Oracle Linux in VirtualBox

Jan 09, 2012 · kickstart, oracle-linux, virtualbox

[ Note that I am in the process of migrating these blog posts from Wordpress, and as such it may contain incorrect formatting, missing links, etc. My old site is available at http://www-old.perkin.org.uk/ so if you find something obviously broken please let me know. Thanks! ]

In my previous post I configured an Ubuntu laptop as a Kickstart install server for a physical machine I wanted to build.

Now that everything is configured for automated installs, it makes sense to use the same infrastructure to install virtual machines too. Everything can be done from the command line, and new virtual machines can be provisioned very quickly.

Again, I will use Oracle Linux 6.2 as an example.

Create Virtual Machine

These commands create a new virtual machine, including disk, and configures it for network booting. If you don’t already have VirtualBox installed:

$ sudo apt-get install virtualbox

Set the name of the virtual machine as it appears in VirtualBox, this variable is then used throughout:

$ VM="Oracle Linux 6.2"

Create the VM:

$ VBoxManage createvm --name "${VM}" --ostype "Oracle_64" --register

Create the hard disk (32GB expanding) and attach it via SATA. Note that I store my VMs in ${HOME}/VirtualBox rather than the default ${HOME}/VirtualBox VMs.

$ VBoxManage createhd --filename "VirtualBox/${VM}/${VM}.vdi" --size 32768

$ VBoxManage storagectl "${VM}" --name "SATA Controller" --add sata \
    --controller IntelAHCI

$ VBoxManage storageattach "${VM}" --storagectl "SATA Controller" --port 0 \
    --device 0 --type hdd --medium "VirtualBox/${VM}/${VM}.vdi"

Default RAM is 128MB, Oracle Linux installer requires at least 512MB however. Once installed we can drop back down to 256MB or so:

$ VBoxManage modifyvm "${VM}" --memory 512

Configure boot order. Put disk first, as on the first boot there is nothing on it so it falls through to PXE for install, then after the install the disk is bootable.

$ VBoxManage modifyvm "${VM}" --boot1 disk --boot2 net --boot3 none --boot4 none

Change NIC type from the default e1000, as a vanilla VirtualBox install does not include the firmware necessary to network boot from that device – it is available in the “VirtualBox Extension Pack” add-on. Switch to a plain PCNet Fast III which does include PXE firmware.

$ VBoxManage modifyvm "${VM}" --nictype1 Am79C973

VirtualBox does have the ability to serve TFTP directly from the file system by placing files inside ${HOME}/.VirtualBox/TFTP/ but I prefer to just use the network as it’s already configured.

$ VBoxManage modifyvm "${VM}" --nattftpserver1 10.0.2.2
$ VBoxManage modifyvm "${VM}" --nattftpfile1 pxelinux.0

Configure pxelinux/kickstart

We just need a couple of tweaks to the configs from the last blog entry, as the network addresses are different inside VirtualBox, and we also may want a different kickstart configuration.

$ sudo vi /var/lib/tftpboot/pxelinux.cfg/default

I just amended the existing entry to point to 10.0.2.2 which is the address of the machine running VirtualBox, and a different ks-vm.cfg kickstart configuration file, but you could also create a new label if you wanted to regularly switch between different configurations:

LABEL ol6.2
    KERNEL /ol6.2/vmlinuz
    APPEND initrd=/ol6.2/initrd.img ks=http://10.0.2.2/ks-vm.cfg

For virtual machines I use a slightly different configuration compared to previously. I’ve only shown the changes below, not the full file:

$ sudo cp /usr/share/nginx/www/ks.cfg /usr/share/nginx/www/ks-vm.cfg

# Update network configuration for DHCP instead of static
network --bootproto=dhcp
url --url=http://10.0.2.2/ol6.2

# Don't specify disks, just use default layout
bootloader --location=mbr --driveorder=sda
clearpart --all --initlabel

# Just add 'screen' to the default set of @base and @core packages.
%packages
screen
%end

Start Virtual Machine

All that’s left to do is to boot up the VM, and everything else should run automatically.

$ VirtualBox --startvm "${VM}"

All done!


All blog posts

Feb 20, 2012 » New blog design
Jan 11, 2012 » Set up anonymous FTP upload on Oracle Linux
Jan 09, 2012 » Kickstart Oracle Linux in VirtualBox
Jan 09, 2012 » Kickstart Oracle Linux from Ubuntu
Dec 22, 2011 » Last day at MySQL
Dec 15, 2011 » Installing OpenBSD with softraid
Sep 21, 2011 » Create VirtualBox VM from the command line
Sep 14, 2011 » Creating chroots for fun and MySQL testing
Jun 30, 2011 » Graphing memory usage during an MTR run
Jun 29, 2011 » Fix input box keybindings in Firefox
Jun 24, 2011 » How to lose weight
Jun 23, 2011 » How to fix stdio buffering
Jun 13, 2011 » Serving multiple DNS search domains in IOS DHCP
Jun 13, 2011 » Fix Firefox URL double click behaviour
Apr 20, 2011 » SSH via HTTP proxy in OSX
Nov 09, 2010 » How to build MySQL releases
Apr 29, 2010 » 'apt-get' and 5,000 packages for Solaris10/x86
Sep 16, 2009 » ZFS+NFS vs OSX
Sep 12, 2009 » pkgsrc on Solaris
Dec 09, 2008 » Jumpstart from OSX