Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Create and Manage Virtual Machines with VirtualBox on Windows

VirtualBox is a powerful open-source virtualization software developed by Oracle. It allows users to run multiple operating systems simultaneously on a single physical machine. This capability is particularly useful for developers, testers, and IT professionals who need to create isolated environments for testing software, running different OS versions, or setting up a sandbox environment. In this article, we'll explore how to install VirtualBox on a Windows machine, create a virtual machine (VM), and manage it using both the graphical user interface (GUI) and command-line interface (CLI).


Examples:


Installing VirtualBox on Windows


1. Download VirtualBox:



2. Install VirtualBox:



  • Run the installer and follow the on-screen instructions.

  • Accept the default settings unless you have specific requirements.


Creating a Virtual Machine via GUI


1. Open VirtualBox:



  • Launch VirtualBox from the Start menu.


2. Create a New VM:



  • Click on the "New" button.

  • Enter a name for your VM, select the type (e.g., Linux, Windows), and choose the version.

  • Allocate memory (RAM) to the VM.

  • Create a virtual hard disk by selecting "Create a virtual hard disk now" and follow the prompts to set the size and type.


3. Configure the VM:



  • Select the newly created VM and click on "Settings."

  • Adjust settings such as system, display, storage, and network according to your needs.


4. Start the VM:



  • With the VM selected, click on "Start" to boot it up.

  • Follow the installation process for the operating system you are installing.


Managing VMs via Command Line (VBoxManage)


VirtualBox includes a command-line tool called VBoxManage that allows you to manage VMs without using the GUI. This can be particularly useful for automation and scripting.


1. Open Command Prompt:



  • Press Win + R, type cmd, and press Enter.


2. Navigate to VirtualBox Directory:




  •  cd "C:\Program Files\Oracle\VirtualBox"



3. Create a New VM:




  •  VBoxManage createvm --name "MyVM" --register



4. Modify VM Settings:



  • Allocate memory:
     VBoxManage modifyvm "MyVM" --memory 2048

  • Set the OS type:
     VBoxManage modifyvm "MyVM" --ostype "Windows10_64"

  • Add a virtual hard disk:
     VBoxManage createhd --filename "C:\Users\YourUser\VirtualBox VMs\MyVM\MyVM.vdi" --size 20000

  • Attach the hard disk to the VM:
     VBoxManage storagectl "MyVM" --name "SATA Controller" --add sata --controller IntelAhci
    VBoxManage storageattach "MyVM" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "C:\Users\YourUser\VirtualBox VMs\MyVM\MyVM.vdi"


5. Start the VM:




  •  VBoxManage startvm "MyVM"



Additional Tips




  • Snapshots: Use snapshots to save the state of a VM at a particular point in time.


    VBoxManage snapshot "MyVM" take "InitialState"



  • Networking: Configure network settings to connect VMs to the internet or a host-only network.


    VBoxManage modifyvm "MyVM" --nic1 nat



To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.