How to change the properties of VirtualBox virtual machines - gHacks Tech News

How to change the properties of VirtualBox virtual machines

It is quite easy to set up virtual machines using VirtualBox and other virtualization programs. You configure a few parameters such as disk size or memory, select an ISO image of an operating system, and wait for the program to create the virtual machine and install the operating system on it.

Virtual machines are useful for many different tasks. You can use them to test updates or new software programs, to browse the Internet, and to chain VPN connections.

VirtualBox users may change some properties of a virtual machine using the graphic user interface and others only from the command line. This guide looks at both options.

Here is a list of situations where you may need to change the properties:

  • The disk size of the virtual machine image is not large enough or is too large.
  • You want to enable or disable clipboard sharing or drag and drop.
  • You want to increase or decrease the memory of the virtual machine.
  • You need to increase or decrease video memory.

VirtualBox Settings

virtualbox settings

You open the Settings of any virtual machine image in Virtualbox by right-clicking on it and selecting settings from the context menu.

  • General > Advanced: Shared Clipboard and Drag and Drop.
  • System > Motherboard: Change base memory and boot order.
  • System > Processor: Change number of processors.
  • Display > Screen: Change video memory, monitor count, and scale factor. Enable 2D and 3D acceleration.
  • Display > Remote Display: enable server mode.
  • Storage: Add or remove storage attachments.
  • Audio: Enable or disable audio, and configure it.
  • Network > Adapter: add network adapters.
  • Serial Ports: Add serial ports.
  • USB: Change the USB controller and add device filters.
  • Shared Folders: Manage shared folders.

And a lot more. You may have noticed already that you cannot change some virtual machine properties using the GUI. It is for instance not possible to change the size of the virtual hard drive; that's reserved to the command line.

VirtualBox command line

resize virtual machine virtualbox

VirtualBox supports many different command line options to change the properties of a virtual machine image.

These commands use VBoxManage modifyvm ImagePath as the base command followed by the actual command.

The following instructions are for Windows. Linux and Mac users should not have issues figuring this out for their devices though.

VBoxManage.exe is a file in the root directory of the VirtualBox installation on Windows. You find it under C:\Program Files\Oracle\VirtualBox by default.

Start by opening a new command prompt window and navigating to the VirtualBox folder.

Tip: if you use the command regularly, consider adding it as a system path so that you can run the commands from anywhere.

  1. Make sure the virtual machine that you want to modify is shut down.
  2. Tap on the Windows-key, type cmd.exe, and hit the Enter-key to start a command prompt window.
  3. Type cd C:\Program Files\Oracle\VirtualBox to switch to the VirtualBox root directory.

Here is a short list of important commands:

Resize virtual machine (VDI and VHD)

  • Command: VBoxManage modifyhd "PathTOVDIImage" −−resize <megabytes>
  • Example: VBoxManage modifyhd "C:\Users\Martin\VirtualBox VMs\windows 7\windows 7.vdi" −−resize 40000
  • Explanation: This changes the size of the virtual hard drive to 40000 MB

Move virtual machine image

  • Command: VBoxManage modifymedium "PathTOVDIImage" −−move <Path>
  • Example: VBoxManage modifymedium "C:\Users\Martin\VirtualBox VMs\windows 7\windows 7.vdi" −−move "C:\virtual"
  • Explanation: This moves the virtual machine image to the new location.

Cap Virtual CPUs

  • Command: VBoxManage modifyvm "PathTOVDIImage" −−cpuexecutioncap <1-100>
  • Example: VBoxManage modifyvm "C:\Users\Martin\VirtualBox VMs\windows 7\windows 7.vdi" −−cpuexecutioncap 50
  • Explanation: Caps the CPU use to 50%.

Change memory allocation

  • Command: VBoxManage modifyvm "PathTOVDIImage" −−memory <memorysize>
  • Example: VBoxManage modifyvm "C:\Users\Martin\VirtualBox VMs\windows 7\windows 7.vdi" −−memory 2048
  • Explanation: Sets the memory to 2048 MB.
Summary
How to change the properties of VirtualBox virtual machines
Article Name
How to change the properties of VirtualBox virtual machines
Description
VirtualBox users may change some properties of a virtual machine using the graphic user interface and others only from the command line. This guide looks at both options.
Author
Publisher
Ghacks Technology News
Logo




  • We need your help

    Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

    We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats (video ads) or subscription fees.

    If you like our content, and would like to help, please consider making a contribution:

    Comments

    1. Sophie said on January 2, 2018 at 6:02 pm
      Reply

      I use VirtualBox and I must say that its so stable, where others have reported issues or BSODs, that I feel I would have to have a very good reason to tinker with it. I’ve Win7 on it, and the whole Virtual Disk Image is only just over 5GB, with loads of stuff on it. Memory allocation seems to be working well, and I rather leave it just as it is. Just treating it rather tenderly, and with caution due to relative inexperience I guess!

      I keep up to 8 snapshots, and periodically delete the oldest ones. Its way way ahead of any kind of Windows System Restore, and I use it for all testing. I also chain VPN on it, thanks to Martin’s earlier article some time ago. I do find my CPU heats a little (its a fanless) while in use, but only into the 60s degrees or so.

      Truly, VM was a great discovery, and very happy with it even if I’d rather now leave it. Also, I have the benefit of having Win7 installed on it with NO updates whatsoever….straight out of the original 2009 box. Being a VM, I don’t fear for its integrity, as I can just roll back. It also means that Win7 is unadulterated, untouched by Microsoft, and even though it has no patches, I’ve yet to find a single thing wrong with it since 8 months now.

      Thanks for the tips though Martin, should I ever wish to return to its’ settings.

      1. Martin Brinkmann said on January 2, 2018 at 6:27 pm
        Reply

        Sophie, you are welcome. VirtualBox runs stable on my end as well.

      2. wb said on January 2, 2018 at 11:43 pm
        Reply

        i have the win7 updated, with almost nothing installed but chrome and couple other relatively small programs, and it’s about 15 GB after optimization 0_o
        not that big deal if you have just a couple installations like me, but if you need several it might add up. Windows 10 takes off a few GB (~13), tough the constant updating gets annoying fast if you have that enabled. Windows 8 could be a good middle ground. If you can still get by with XP, an updated one take about 7-8 Gb.
        Very happy with Virtualbox, was using Vmware before, but it had this constant cpu usage spikes on the host that i couldn’t get rid of.

    2. Belga said on January 2, 2018 at 8:27 pm
      Reply

      This is telepathy!
      I was just looking on the net way to increase the RAM of one of my virtual machines.
      For my part, I never had a problem until last version : one machine did not started properly anymore.
      I returned meanwhile to the previous version and will see what happens with the following version.
      For the rest, same as Sophie here.
      Thanks Martin & Happy New Year.

      1. Belga said on January 3, 2018 at 12:44 pm
        Reply

        I tried today the command for “Change memory allocation” but it does not work for me :

        C:\WIND0WS\system32> cd C:\Program Files\Oracle\VirtualBox
        C:\Program Files\Oracle\VirtualBox>VBoxManage modifyhd “C:\Users\Jean\VirtualBox VMs\Win 7\Win 7.vdi” –memory 2048
        Oracle UM VirtualBox Command Line Management Interface Version 5.2.2
        2005-2017 Oracle Corporation
        All rights reserved.
        Usage:
        VBoxManage modifymedium [disk|dvd|Floppy]
        [—type normal|writethrough|immutable|shareable|
        readonly|multiattach]
        [—autoreset on|off]
        [—property ]
        [—compact ]
        [—resize |—resizebyte ]
        [—move <path]
        [—description ]
        Syntax error: unknown option: –memory
        c:\Program Files\Oracle\VirtualBox>

      2. STech said on January 4, 2018 at 4:30 pm
        Reply

        Hi Belga

        change ‘modifyhd’ in ‘modifyvm’ and all will work fine.

        Martin,
        the memory syntax command is OK but the example must be corrected;
        also for resizing the disk, the example is OK but the command syntax is not.

        1. Martin Brinkmann said on January 4, 2018 at 4:44 pm
          Reply

          Thanks, I totally blanked on this. Checked all commands and fixed those that needed fixing.

        2. Belga said on January 4, 2018 at 9:57 pm
          Reply

          Thanks STech, but even like that (and after reinstallation of the program)…

          C:\Program Files\Oracle\VirtualBox
          VBoxManage modifyvm “C:\Users\JEAN\VirtualBox VMs\windows 7\windows 7.vdi” -memory 2048
          VBoxManage.exe: error: Could not find a registered machine named ‘C:\Users\JEAN\VirtualBox VMs\windows 7\windows 7.vdi’
          VBoxManage.exe: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualB
          ox, callee IUnknown
          VBoxManage.exe: error: Context: ”FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())” at line 512 of file VBoxMana
          geModifyVM.cpp
          C:\Program Files\Oracle\VirtualBox

    3. dwarf_t0ssn said on January 2, 2018 at 11:18 pm
      Reply

      Virtualbox is pretty great. Infinitely useful for testing out linux distros or NT-lite’d Windows 7. One can even grab a pre-fab networking appliance like GNS3 and learn useful skills on a shoestring budget. Not bad for being 100% free.

    4. A different Martin said on January 11, 2018 at 3:06 am
      Reply

      Hi, Martin. Thanks for this. It came at the right time, as I wanted to increase the size of my Linux Mint guest and start using Timeshift to get familiar with it before ultimately going to a bare-metal install.

      Just one suggestion for improvement: when you’re entering sample command-line text (or running a spelling/formatting check on copy that includes command-line text), take care that your word processor’s autocorrect/autoformat function doesn’t inappropriately do stuff like change straight quotes into left/right curly quotes or convert two hyphens into an em dash. (Could a special style for command-line text help?) I don’t think Windows 7’s command processor stumbled over the curly double quotes in your –resize sample, but the inadvertently substituted em dash was a showstopper.

      Now I guess I have to learn how to use gparted to increase the size of a partition or two from within Linux Mint. I’m glad I have a backup copy of my virtual machine!

    Leave a Reply