At work, I noticed I kept doing the same configuration for VirtualBox everytime I created a new guest. Because I’m lazy, I hate doing the same things over and over, so I researched the CLI interface for VirtualBox. VirtualBox provides wonderful documentation on VBoxManage, be sure to check out the Manual for more indepth detail.
First thing was to create a guest virtual machine:
VBoxManage createvm --name "the name of the guest" --ostype Redhat_64 --basefolder "/the/dir/to/VMs/" --register
If you need a listing of the various ostypes:
VBoxManage list ostypes
At this point, I modified other settings needed for the VM:
VBoxManage modifyvm "the name of the guest" --memory 1024 --nic1 bridged --cableconnected on --bridgeadapter1 eth0 --vram 12
To view the vast number of modifications available:
VBoxManage modifyvm
Next, I created a hard drive:
VBoxManage createhd --filename "/path/to/hd.vdi" --size 40960 --format VDI --variant Standard
Now, create a storage controller for the DVD and Hard drive:
VBoxManage storagectl "the name of the guest" --name "IDE Controller" --add ide --controller PIIX4
VBoxManage storagectl "the name of the guest" --name "SATA Controller" --add sata --controller IntelAHCI
Finally attach the controller, hard drive and VM
VBoxManage storageattach "the name of the guest" --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium "/path/to/os.iso"
VBoxManage storageattach "the name of the guest" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "/path/to/hd.vdi"
Start it up
VBoxManage startvm "the name of the guest"