In the ever-evolving world of cloud computing, VirtualBox emerges as a savior for beginners looking to experiment and conduct Proof of Concepts (POCs) on their local machines. This quick guide provides essential VirtualBox commands to kickstart your virtualization journey.
VirtualBox is free, open-source virtualization software. It enables you to create and run multiple virtual machines on a single physical computer.
$ vboxmanage list ostypes | grep -i fedora
ID: Fedora
Description: Fedora (32-bit)
ID: Fedora_64
Description: Fedora (64-bit)
$ vboxmanage createvm --name "Fedora-38-test" --ostype Fedora_64 --register
Virtual machine 'Fedora-38-test' is created and registered.
UUID: e0f9f117-f999-4c7a-bd77-9d1ce4e3f73a
Settings file: '/Users/Test/VirtualBox VMs/Fedora-38-test/Fedora-38-test.vbox'
$ vboxmanage modifyvm "Fedora-38-test" --cpus 1 --memory 2048 --vram 16
$ vboxmanage modifyvm "Fedora-38-test" --nic1 nat
$ vboxmanage createmedium disk --filename ~/VirtualBox\ VMs/Fedora-38-test/Fedora-38-test-disk001.vmdk --size 5120 --format=VMDK --variant Standard
$ vboxmanage storagectl "Fedora-38-test" --name "SATA Controller" --add sata --bootable on
$ vboxmanage storageattach "Fedora-38-test" --storagectl "SATA Controller" \
--port 0 --device 0 --type hdd \
--medium ~/VirtualBox\ VMs/Fedora-38-test/Fedora-38-test-disk001.vmdk
$ vboxmanage storagectl "Fedora-38-test" --name "IDE Controller" --add ide
$ vboxmanage storageattach "Fedora-38-test" --storagectl "IDE Controller" \
--port 0 --device 0 --type dvddrive \
--medium ~/Documents/ISO/Fedora-Server-dvd-x86_64-38-1.6.iso
$ vboxmanage startvm "Fedora-38-test"
Now follow the steps to install the Fedora, like we do on physical box.
$ vboxmanage modifyvm "Fedora-38-test" --graphicscontroller=vmsvga $ vboxmanage setextradata "Fedora-38-test" GUI/ScaleFactor 1.8
$ vboxmanage modifyvm "Fedora-38-test" --graphicscontroller=vmsvga
$ vboxmanage setextradata "Fedora-38-test" GUI/ScaleFactor 1.8
Note: Above value may varies from system to system based on monitor size/pixels.
$ vboxmanage modifyvm "Fedora-38-test" --vrde on
$ vboxmanage startvm "Fedora-38-test" --type=headless
Note: You can use rdesktop/rdp or any other rdp supported software to connect to remote machine.
$ vboxmanage list vms "Fedora-38-VirtualBox-Original" {553fea69-61b6-4024-b069-15219bf3e9cd} "Fedora-38" {02944e40-6cec-4b9a-b558-8ca74cdfe334}
$ vboxmanage list vms
"Fedora-38-VirtualBox-Original" {553fea69-61b6-4024-b069-15219bf3e9cd}
"Fedora-38" {02944e40-6cec-4b9a-b558-8ca74cdfe334}
$ vboxmanage list runningvms
"Fedora-38-VirtualBox-Original" {553fea69-61b6-4024-b069-15219bf3e9cd}
$ vboxmanage showvminfo "Fedora-38-VirtualBox-Original" Name: Fedora-38-VirtualBox-Original Encryption: disabled Groups: / Guest OS: Fedora (64-bit) UUID: 9a9615f6-0173-4c67-961f-ef9cb0968b15 ...... ......
$ vboxmanage showvminfo "Fedora-38-VirtualBox-Original"
Name: Fedora-38-VirtualBox-Original
Encryption: disabled
Groups: /
Guest OS: Fedora (64-bit)
UUID: 9a9615f6-0173-4c67-961f-ef9cb0968b15
......
......
$ vboxmanage startvm "Fedora-38-VirtualBox-Original"
Waiting for VM "Fedora-38-VirtualBox-Original" to power on...
VM "3cab8256-1ce5-4cd7-b74e-f155b75f6436" has been successfully started.
$ vboxmanage startvm 3cab8256-1ce5-4cd7-b74e-f155b75f6436 --type headless
Waiting for VM "3cab8256-1ce5-4cd7-b74e-f155b75f6436" to power on...
VM "3cab8256-1ce5-4cd7-b74e-f155b75f6436" has been successfully started.
$ vboxmanage controlvm "Fedora-38-VirtualBox-Original" poweroff
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
$ vboxmanage controlvm "Fedora-38-VirtualBox-Original" savestate
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
$ vboxmanage controlvm "Fedora-38-VirtualBox-Original" acpipowerbutton
$ vboxmanage controlvm "Fedora-38-VirtualBox-Original" pause
$ vboxmanage controlvm "Fedora-38-VirtualBox-Original" resume
$ vboxmanage controlvm "Fedora-38-VirtualBox-Original" reset
$ vboxmanage unregistervm "Fedora-38-VirtualBox-Original"
Note: It does not delete the definition and the files associated with the virtual machine.
$ vboxmanage unregistervm "Fedora-38-VirtualBox-Original" --delete-all
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
$ vboxmanage clonevm "Fedora-38-VirtualBox-Original" --name "Clone-Fedora-38" --register
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Machine has been successfully cloned as "Clone-Fedora-38"
$ vboxmanage export "Fedora-38-VirtualBox-Original" -o Fedora-38.ova
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Successfully exported 1 machine(s).
$ vboxmanage import ~/Documents/ISO/Fedora-38-VirtualBox-Original.ova
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting /Users/XXXXX/Documents/ISO/Fedora-38-VirtualBox-Original.ova...
OK.
$ vboxmanage snapshot "Fedora-38-VirtualBox-Original" take fedora-snapshot
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Snapshot taken. UUID: 88f38480-e272-4764-8bd1-0f8bf119208e
$ vboxmanage snapshot Fedora-38-VirtualBox-Original list
Name: fedora-snapshot (UUID: 88f38480-e272-4764-8bd1-0f8bf119208e) *
$ vboxmanage snapshot Fedora-38-VirtualBox-Original restore fedora-snapshot
Restoring snapshot 'fedora-snapshot' (88f38480-e272-4764-8bd1-0f8bf119208e)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
$ vboxmanage snapshot Fedora-38-VirtualBox-Original delete fedora-snapshot
Deleting snapshot 'fedora-snapshot' (290c257d-a881-4359-9577-d9959fff5d98)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%