Script to automatically create VirtualBox VM, booting from iso with custom kickstart and simple install. VirtualBox 4.3.0 cannot do ipxe boot on host having Core Duo cpu, so here's simple workaround - boot from iso and automatically use custom kickstart:
#!/bin/sh name=${1} port=`VBoxManage list -l vms | grep -E 'VRDE property: TCP/Ports' | awk '{ print $5; }' | tr -d '"' | sort -n | tail -1` port=$(( $port + 1 )) mkdir ~/VirtualBox\ VMs/${name} VBoxManage createhd --filename ~/VirtualBox\ VMs/${name}/${name}.vdi --size 16384 VBoxManage createvm --name ${name} --ostype RedHat_64 --register VBoxManage storagectl ${name} --name satactl1 --add sata --controller IntelAHCI --bootable on VBoxManage storageattach ${name} --storagectl satactl1 --port 0 --type hdd --medium ~/VirtualBox\ VMs/${name}/${name}.vdi VBoxManage storagectl ${name} --name idectrl1 --add ide --controller ICH6 --bootable on VBoxManage storageattach ${name} --storagectl idectrl1 --device 0 --port 0 --type dvddrive --medium ~/Downloads/CentOS-6.4-x86_64-bootonly.iso VBoxManage modifyvm ${name} --memory 1024 --cpus 1 --cpuexecutioncap 50 --pae off VBoxManage modifyvm ${name} --nic1 hostonly --nictype1 82545EM --hostonlyadapter1 vboxnet0 VBoxManage modifyvm ${name} --audio none --usb off VBoxManage modifyvm ${name} --vrde on --vrdeport ${port} --vrdeauthtype null --vrdemulticon on echo "${name} RDP port is ${port}"
Create iso from netinstall, copying isolinux/ dir, modifying isolinux.cfg similar to this:
label linux menu label ^Install basic system menu default kernel vmlinuz append initrd=initrd.img text ks=cdrom:/anaconda-ks.cfg
Create iso for use:
# mkisofs -o ../CentOS-6.4-x86_64-bootonly.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -V "CentOS 6.4 Custom ISO" .