{"id":236,"date":"2022-06-11T10:50:01","date_gmt":"2022-06-11T07:50:01","guid":{"rendered":"https:\/\/amsd.go.ro\/wordpress\/?p=236"},"modified":"2022-06-11T10:53:06","modified_gmt":"2022-06-11T07:53:06","slug":"common-virtualbox-commands-to-manage-vms","status":"publish","type":"post","link":"https:\/\/amsd.go.ro\/wordpress\/?p=236","title":{"rendered":"Common Virtualbox commands to manage VMs"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Command to Create VirtualBox virtual machine<\/h3>\n\n\n\n<p>Replace the <strong>DEMO<\/strong> with whatever name you want to give your Virtual machine.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">VBoxManage createvm --name DEMO --register<\/pre>\n\n\n\n<p><strong>To Set type Linux and version 64-bit<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">VBoxManage modifyvm DEMO --ostype Linux_64<\/pre>\n\n\n\n<p><strong>Set RAM<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">VBoxManage modifyvm DEMO --memory 1024 --vram 16<\/pre>\n\n\n\n<p><strong>Assign the Number of CPU cores<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">VBoxManage modifyvm DEMO  --cpus 2<\/pre>\n\n\n\n<p><strong>Create Virtual storage and set size for it<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">VBoxManage createhd --filename DEMO.vdi --size 32768<\/pre>\n\n\n\n<p><strong>Add Storage controller and attach hard disk + ISO Image to boot.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">VBoxManage storagectl DEMO--name \"SATA Controller\" --add sata --controller IntelAHCI\n\nVBoxManage storageattach DEMO --storagectl \"SATA Controller\" --port 0 --device 0 --type hdd --medium DEMO.vdi\n\nVBoxManage storageattach DEMO --storagectl \"SATA Controller\" --port 1 --device 0 --type dvddrive --medium \"\/home\/demo\/tails-amd64-4.16.iso\"<\/pre>\n\n\n\n<p><strong>Note<\/strong>: Change the ISO file path in the above command<\/p>\n\n\n\n<p><strong>Set Boot order<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">VBoxManage modifyvm DEMO --boot1 dvd --boot2 disk --boot3 none --boot4 none<\/pre>\n\n\n\n<p><strong>Set Network NAT<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">VBoxManage modifyvm DEMO --nic1 nat --nictype1 82540EM<\/pre>\n\n\n\n<p>For <strong>Bridge<\/strong> Network, use-<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">VBoxManage modifyvm DEMO--nic1 bridged --nictype1 82540EM --bridgeadapter1 wlx000b819609d3<\/pre>\n\n\n\n<p><strong>Turn on Physical Address Extension<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">VBoxManage modifyvm DEMO --pae on<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Command to List Virtual Machines<\/h3>\n\n\n\n<p>To know what is the number of virtual machines created on Virtualbox so far using command terminal, type-<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vboxmanage list vms<\/pre>\n\n\n\n<p><strong>Output<\/strong>: As per the available VMs, the command will show something like below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">how2shout@ubuntu:~$  \n\"CentOS\" {694b1226-4592-49c2-bcd0-ebb79efc8598}\n\"Ubuntu \" {5644b8dd-ab01-46be-9265-404df4325c6b}\n\"WIndows 10\" {abacf56d-60ee-4f88-bc35-b377964758ca}\n\"DEMO\" {70285447-ff88-4f32-801c-8a72190b9a89}\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Start VirtualBox VM via command<\/h3>\n\n\n\n<p>Now, we already have a list of all available virtual machines. So, if we want to start any of them, just type-<\/p>\n\n\n\n<p><code>vboxmanage startvm <em>virtualmachine-name<\/em><\/code><\/p>\n\n\n\n<p>Replace<strong> virtual machine-nam<\/strong>e with the one you want to Power ON.<\/p>\n\n\n\n<p><strong>For example<\/strong>, in our list of all VMs, we have one- DEMO. To start that VM using the above command, it will be like this-<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vboxmanager startvm DEMO<\/pre>\n\n\n\n<p><strong>To run headless-<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">VBoxManage startvm DEMO --type headless<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Stop Virtual machine using command<\/h3>\n\n\n\n<p>To power off some already running VirtualBox VM, we can directly use our command terminal, and to do that run-<\/p>\n\n\n\n<p><code>vboxmanage controlvm VM-name poweroff&nbsp;<\/code><\/p>\n\n\n\n<p>Replace <strong>VM-name<\/strong> with the running machine you want to stop.<\/p>\n\n\n\n<p><strong>For example,<\/strong> if you consider DEMO as the running VM on VirtualBox. Thus, to stop it using the command terminal, we need to type-<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vboxmanage controlvm DEMO poweroff<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">List all running VMs<\/h3>\n\n\n\n<p>In case you are not sure which VMs are running so that you can turn them off using your terminal, issue a command-<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vboxmanage list runningvms<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Remove VM<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">VBoxManage storageattach DEMO--storagectl \"SATA Controller\" --port 0 --device 0 --type hdd --medium none\nVBoxManage closemedium disk DEMO.vdi --delete\nVBoxManage unregistervm DEMO --delete<\/pre>\n\n\n\n<p><strong>Note: <\/strong>Replace <strong>DEMO<\/strong> with the Virtual machine name that you want to remove<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Convert VDI \/ VMDK \/ VHD<\/h3>\n\n\n\n<p>To Convert one virtual hard disk type to another<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># VMDK to VDI\nVBoxManage clonehd \"source.vmdk\" \"cloned.vdi\" --format vdi\n# VHD to VMDK\nVBoxManage clonehd \"source.vhd\" \"cloned.vmdk\" --format vmdk\n# RAW image to vdi\nVBoxManage convertfromraw \"source.hddimg\" \"cloned.vdi\" --format vdi<\/pre>\n\n\n\n<p><strong>Note<\/strong>: Replace <strong>source.xx<\/strong> with fie you want to convert and also can change <strong>cloned.xx<\/strong> with whatever you name you to want to give your converted virtual disk.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Resize virtual disk (resize in MB, here 256 GB)<\/h3>\n\n\n\n<p>Many times after installing OS in the virtual machine we need to expand the size of its virtual hard disk. For that, we can use the below command. Navigate to the folder where you have the virtual hard disk file for your virtual machine and then run the below command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">VBoxManage modifyhd \"HDD.vdi\" --resize 36000<\/pre>\n\n\n\n<p>Replace HDD.vdi with your virtual disk file name that size you want to increase. The size will be in MB, for example, 36000 given in the command, in GB it will be 360GB.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Command to Create VirtualBox virtual machine Replace the DEMO with whatever name you want to give your Virtual machine. VBoxManage createvm &#8211;name DEMO &#8211;register To Set type Linux and version 64-bit VBoxManage modifyvm DEMO &#8211;ostype Linux_64 Set RAM VBoxManage modifyvm [&hellip;]<\/p>\n<div class=\"link-more\"><a href=\"https:\/\/amsd.go.ro\/wordpress\/?p=236#more-236\" class=\"more-link\">Continue reading &#10142; <span class=\"screen-reader-text\">Common Virtualbox commands to manage VMs<\/span><\/a><\/div>","protected":false},"author":6,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11,28],"class_list":["post-236","post","type-post","status-publish","format-standard","hentry","category-technology","tag-ps_57","tag-virtualization"],"_links":{"self":[{"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=236"}],"version-history":[{"count":3,"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/236\/revisions"}],"predecessor-version":[{"id":240,"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/236\/revisions\/240"}],"wp:attachment":[{"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}