Virtual Machines from CLI














































Virtual Machines from CLI



Virtualization has been one of the most popular technology in past few decades, due to this very reason many open source solutions like virtualbox came into existence.
As much as i like Virtualbox GUI i always wanted to have a CLI version of that, now that we have a CLI version lets see how to use it 

Creating a VM
here we are creating a debian 64bit VM 

to create a new VM you can use 
sudo VBoxManage createvm --name test --ostype Debian_64 --register



Updating VM
now that we have created the VM we will have to update it in order to make it usable by adding Memory,networking,Hard-disk,iso file

Networking
You can add network by using following commands

sudo VBoxManage modifyvm test --bridgeadapter1 vmnet1
VBoxManage modifyvm test --nic1 bridged



Hard-disk
To add hardisk you would need to first create a  new hard-disk using following command

sudo VBoxManage createhd --filename ~/test.vdi --size 10000 --format VDI



now that you have created new hard-disk you can attach by creating a SATA controller and attaching to it

sudo VBoxManage storagectl test --name "SATA Controller" --add sata --controller IntelAhci
sudo VBoxManage storageattach test --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium ~/test.vdi



Memory
Here i am adding 4Gb of memory feel free to modify the amount

sudo VBoxManage modifyvm test --memory 4096



Add iso file 
Now we need to attach iso file and install OS from it , to do that first we need to create a IDE controller

sudo VBoxManage storagectl test --name "IDE Controller" --add ide --controller PIIX4
sudo VBoxManage storageattach test --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium /media/home/SOFTWARE/LINUX/Parrot-security-4.7_x64\(1\).iso 




Now after all this you can see your new Vm appear in GUI



Start VM 
you can start a VM by using 
VBoxManage startvm test

Delete VM
now that you have completed your work you can delete your VM by using

VBoxManage unregistervm test --delete 

note it will delete all your files also

Comments