Useful commands for VirtualBox.

Note: Please check if kernel updates is available from /etc/yum.conf. After install all packages you can disable kernel updates.

Steps for installing VirtualBox on CentOS without GUI.

sudo yum install wget dkms kernel-devel-$(uname -r) kernel-headers-$(uname -r)

# Repo (for Debian please look here https://www.virtualbox.org/wiki/Linux_Downloads )
    cd /etc/yum.repos.d
    wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
# VirtualBox
    sudo yum install VirtualBox-4.3.x86_64
# VirtualBox: Setup
    sudo /etc/init.d/vboxdrv setup
    wget http://download.virtualbox.org/virtualbox/4.3.14/Oracle_VM_VirtualBox_Extension_Pack-4.3.14-95030.vbox-extpack
    sudo VBoxManage extpack install ./Oracle_VM_VirtualBox_Extension_Pack-4.3.14-95030.vbox-extpack
# Add you username to VirtualBox group
    sudo usermod -a -G vboxusers teo
# New VM
    VM="Windows7_x64_VM01"
    VBoxManage createvm --name "${VM}" --register
    VBoxManage modifyvm "${VM}" --cpus 1
    VBoxManage modifyvm "${VM}" --memory 2048 --acpi on
    VBoxManage modifyvm "${VM}" --ostype "Windows7_64"
    VBoxManage modifyvm "${VM}" --nic1 nat
    #VBoxManage modifyvm "${VM}" --nic1 bridged --bridgeadapter1 eth0
# Create HDD
    FILE=~/"VirtualBox VMs"/"${VM}"/"${VM}".vmdk
    VBoxManage createhd --filename "${FILE}" --format VMDK --size 102400
    VBoxManage storagectl "${VM}" --name "IDE Controller" --add ide
    VBoxManage storageattach "${VM}" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium "${FILE}"
# Attach ISO file
    FILE=~/x.iso
    VBoxManage storageattach "${VM}" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium "${FILE}"

# Attach vmdk
    VBoxManage storagectl "${VM}" --name "IDE Controller" --add ide
    VBoxManage storageattach "${VM}" --storagectl sata_1 --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium ./x.vmdk
# Useful
    # List VMs
        VBoxManage list vms
    # Remove a VM
        VBoxManage modifyvm "${VM}" --hda none
        VBoxManage unregistervm "${VM}" --delete
    # PowerON
        VBoxHeadless --startvm "${VM}"
    # PowerOFF
        VBoxManage controlvm "${VM}" poweroff