virtualbox commands

Einzelne HardDisk clonen

#!/bin/bash 
#
VMDIR='/Users/hed/VirtualBox VMs'
VMNAME="oel31"
DISK00='/Users/hed/VirtualBox VMs/sources/oel00-v66-disk1.vdi'
#
ls -lh "${VMDIR}/${VMNAME}/${VMNAME}-disk1.vdi"
mkdir -vp "${VMDIR}/sources"
vboxmanage clonehd "${VMDIR}/${VMNAME}/${VMNAME}-disk1.vdi" "${DISK00}" 
vboxmanage showhdinfo "${DISK00}"

VM per shell script erstellen

#!/bin/bash 
#
VMDIR='/Users/hed/VirtualBox VMs'
VMNAME="oel32"
DISK00='/Users/hed/VirtualBox VMs/sources/oel00-v66-disk1.vdi'
VMDESC="Oracle Enterprise Linux 6.6 -- $(date)"
#
mkdir -vp "${VMDIR}/${VMNAME}"
vboxmanage createvm --name $VMNAME --register
vboxmanage modifyvm $VMNAME --cpus 4 --memory 4096 --acpi on --ioapic on --boot1 dvd
vboxmanage modifyvm $VMNAME --nic1 hostonly --hostonlyadapter1 vboxnet1 --nictype1 82540EM
vboxmanage modifyvm $VMNAME --nic2 hostonly --hostonlyadapter2 vboxnet2 --nictype2 82540EM
vboxmanage modifyvm $VMNAME --nic3 bridged --bridgeadapter3 'en0: Wi-Fi (AirPort)' --nictype3 82540EM
#vboxmanage modifyvm $VMNAME --macaddress1 080027468F5E --macaddress2 080027C65D9D
vboxmanage modifyvm $VMNAME --macaddress1 auto --macaddress2 auto --macaddress3 auto
vboxmanage modifyvm $VMNAME --ostype Oracle_64 --description "${VMDESC}"
#
vboxmanage storagectl $VMNAME --name "IDE" --add ide --controller PIIX4 \
    --portcount 2
vboxmanage storageattach $VMNAME --storagectl "IDE" --port 0 --device 0 --type dvddrive --medium emptydrive
# vboxmanage storageattach $VMNAME --storagectl "IDE" --port 0 --device 0 --type dvddrive --medium /u01/sw/linux/oel66/V52218-01.iso
#
# vboxmanage createhd --filename "${VMDIR}/${VMNAME}/${VMNAME}-disk1.vdi" \
#   --format vdi --sizebyte 25769803776
if [ -f "${VMDIR}/${VMNAME}/${VMNAME}-disk1.vdi" ]
then
  echo "File existiert:"
  echo "${VMDIR}/${VMNAME}/${VMNAME}-disk1.vdi"
else
  vboxmanage clonehd "${DISK00}" "${VMDIR}/${VMNAME}/${VMNAME}-disk1.vdi"
fi
vboxmanage storagectl $VMNAME --name "SATA" --add sata --controller IntelAHCI --portcount 8
vboxmanage storageattach $VMNAME --storagectl "SATA" --port 1 \
        --device 0 --type hdd --medium "${VMDIR}/${VMNAME}/${VMNAME}-disk1.vdi"
#
vboxmanage sharedfolder add $VMNAME --name sw --hostpath /u01/sw
vboxmanage sharedfolder add $VMNAME --name scripts --hostpath /Users/hed/scripts