Commits

abudden committed d656e6b

Added script to create the virtual machine in the first place.

  • Participants
  • Parent commits 2e8feaf

Comments (0)

Files changed (1)

File make_virtual_machine.sh

+#!/bin/bash
+
+MACHINE_NAME=arch
+OSTYPE=ArchLinux
+MACHINE_DIR=~/virtual_machines/${MACHINE_NAME}
+URL=http://ftp.heanet.ie/mirrors/ftp.archlinux.org/iso/latest/
+ISODIR=/tmp
+
+ISOFILE=${ISODIR}/${MACHINE_NAME}.iso
+
+if [ ! -e ${ISODIR}/${MACHINE_NAME}.iso ]
+then
+	wget -O ${ISOFILE} $(curl ${URL} | grep '\.iso"' | sed 's/.*a href="\([^"]*\)".*/\1/' | sed "s@^@${URL}@")
+fi
+
+mkdir ${MACHINE_DIR}
+cd ${MACHINE_DIR}
+
+VBoxManage createhd --filename ${MACHINE_NAME}_root.vmdk --size 20480 --format VMDK --variant Split2G
+VBoxManage createhd --filename ${MACHINE_NAME}_home.vmdk --size 10248 --format VMDK --variant Split2G
+VBoxManage createvm --name ${MACHINE_NAME} --ostype ${OSTYPE} --register --basefolder ${MACHINE_DIR}
+VBoxManage storagectl ${MACHINE_NAME} --name "IDE Controller" --add ide --controller PIIX4 --hostiocache on --bootable on
+VBoxManage storagectl ${MACHINE_NAME} --name "SATA Controller" --add sata --controller IntelAhci --hostiocache off --sataportcount 4 --bootable on
+VBoxManage storageattach ${MACHINE_NAME} --type dvddrive --storagectl "IDE Controller" --port 0 --device 0 --medium ${ISOFILE}
+VBoxManage storageattach ${MACHINE_NAME} --type hdd --storagectl "SATA Controller" --port 0 --device 0 --medium ${MACHINE_NAME}_root.vmdk
+VBoxManage storageattach ${MACHINE_NAME} --type hdd --storagectl "SATA Controller" --port 1 --device 0 --medium ${MACHINE_NAME}_home.vmdk
+VBoxManage modifyvm ${MACHINE_NAME} --memory 512 --nic1 nat --cableconnected1 on --boot1 dvd --boot2 disk --clipboard bidirectional
+VBoxManage startvm ${MACHINE_NAME} --type gui
+while [ $(VBoxManage list runningvms | grep -c ${MACHINE_NAME}) -eq 1 ]
+do
+	sleep 5
+done
+VBoxManage storageattach ${MACHINE_NAME} --type dvddrive --storagectl "IDE Controller" --port 0 --device 0 --medium none
+VBoxManage closemedium dvd ${ISOFILE} --delete