What a virtual machine is and why you might create one

A virtual machine is a software copy of a computer that runs inside your existing computer. It behaves like a separate device with its own operating system, programs, and files — but it exists only as data on your hard drive. You can start it, shut it down, and delete it without touching your physical hardware.

People create virtual machines for several practical reasons. You might want to test new software without installing it on your main system, run an older operating system to use legacy programs, or isolate work projects from personal files. System administrators use them to run multiple servers on one physical machine, reducing electricity costs and physical space.

The process involves three main steps: choosing virtualization software, allocating disk space and memory, and installing an operating system inside the virtual environment. The whole setup typically takes 30 minutes to two hours depending on your internet speed and which operating system you choose.

Key Takeaways

  • You need virtualization software like VirtualBox, VMware, or Hyper-V installed on your computer before you can create a virtual machine.
  • Allocate at least 20 to 50 gigabytes of disk space and 2 to 4 gigabytes of RAM to the virtual machine, depending on what you plan to run inside it.
  • You will need an installation file or disc image for the operating system you want to install — Windows, Linux, or macOS — which you can download from the publisher's website.
  • The virtual machine runs as a window on your desktop and uses your computer's processor and memory while it is active, so performance will slow if you run demanding tasks on both simultaneously.

Choosing virtualization software

The software that creates and runs virtual machines is called a hypervisor. Your choice depends on your operating system and budget. VirtualBox is free, works on Windows, macOS, and Linux, and is the most common choice for learning. VMware Workstation Pro costs money but offers more advanced features and better performance. Hyper-V comes built into Windows Pro and Enterprise editions at no extra cost, though it is not available in Windows Home.

For most people starting out, VirtualBox is the practical choice. Download it from virtualbox.org, run the installer, and follow the on-screen prompts. The installation takes a few minutes and requires a restart. After that, you will see VirtualBox in your applications menu.

If you use macOS and want to run Windows or Linux, you have additional options. Parallels Desktop is paid software optimized for Mac. UTM is free and works on Apple Silicon Macs. These are alternatives to VirtualBox, not additions to it — you choose one hypervisor, not multiple.

Creating a new virtual machine and allocating resources

Open your hypervisor software and look for a button labeled "New" or "Create Virtual Machine." You will be asked to name the machine, choose an operating system type, and set how much of your computer's resources it can use.

For disk space, allocate at least 20 gigabytes for a Linux system and 50 gigabytes for Windows. The hypervisor creates a file on your hard drive that acts as the virtual machine's hard drive. You can set it to grow as needed (dynamic allocation) or claim the full amount immediately (fixed allocation). Dynamic is slower but saves disk space if you do not fill it.

For memory (RAM), assign 2 to 4 gigabytes if you are running a basic operating system with light tasks. Assign 4 to 8 gigabytes if you plan to run office software or development tools. Do not assign more than half your computer's total RAM — if your computer has 8 gigabytes, give the virtual machine no more than 4. Your host operating system needs memory to run too.

For processor cores, assign 2 to 4 cores depending on what you plan to do. The hypervisor will warn you if you assign too many. You can change these settings later if the machine runs slowly.

Obtaining an operating system installation file

A virtual machine needs an operating system just like a physical computer does. You need an ISO file — a single file that contains everything needed to install the operating system. This is not the same as buying a license; the ISO is the installation media.

For Windows: Go to microsoft.com/software-download/windows and download the Windows 10 or Windows 11 ISO. You will need a valid Windows license key to activate it after installation, though you can install and use it for 30 days without one.

For Linux: Visit ubuntu.com or the website of your chosen distribution and download the ISO. Ubuntu is the most beginner-friendly option. Linux is free and does not require a license key.

For macOS: If you own a Mac, you can download macOS from the App Store. The file is large — several gigabytes — so use a wired internet connection if possible.

Save the ISO file somewhere you can find it, like your Downloads folder. You will point the hypervisor to this file in the next step.

Installing the operating system inside the virtual machine

Start the virtual machine you just created. The hypervisor will ask you to select an installation disc or ISO file. Navigate to the ISO file you downloaded and open it. The virtual machine will boot from that file, just as if you had inserted a physical installation disc.

Follow the operating system's installation wizard. You will be asked where to install the system (choose the virtual hard drive), what language to use, and whether to customize settings. For a first virtual machine, accept the default options. The installation process takes 15 to 45 minutes depending on your internet speed and the operating system.

When installation finishes, the virtual machine will restart and boot into the new operating system. Remove the ISO file from the virtual drive (the hypervisor usually does this automatically) so the machine boots from its virtual hard drive instead.

Install the guest additions or VMware tools — software that improves performance and lets you move your mouse between the virtual machine and your main desktop smoothly. In VirtualBox, this is under the Devices menu. In VMware, it is under VM. This step is optional but strongly recommended.

Managing the virtual machine after creation

Your virtual machine now runs like any other program on your computer. Click its window to use it, click outside to return to your main desktop. You can minimize it, resize it, or run it full-screen.

To shut down the virtual machine, use the operating system's shutdown command inside it — do not force-quit it. This prevents data loss, just as with a physical computer. You can also pause it (freezing its state) or save a snapshot (a backup of the entire machine at one moment in time).

If the machine runs slowly, you can increase its allocated RAM or processor cores. Open the settings in your hypervisor, but do this only when the machine is powered off. If you run out of disk space, most hypervisors let you expand the virtual hard drive file.

To delete the virtual machine entirely, right-click it in your hypervisor and choose delete or remove. This erases the virtual hard drive file and frees up disk space. You can create a new one anytime.

Common problems and how to fix them

The virtual machine is very slow. You likely assigned too little RAM or too few processor cores. Power it off, increase these in the settings, and restart. If your main computer is also slow, close other programs before running the virtual machine.

The installation hangs or fails. The ISO file may be corrupted. Download it again from the official source. If you are using an older hypervisor, update it to the latest version — compatibility issues are common with older software.

The mouse or keyboard does not respond correctly. Install the guest additions (VirtualBox) or VMware tools (VMware). If that does not help, click inside the virtual machine window to give it focus, then try again.

You cannot connect to the internet inside the virtual machine. Check your hypervisor's network settings. By default, most virtual machines use NAT (Network Address Translation), which shares your computer's internet connection. If that is not working, try switching to Bridged mode in the network settings, though this requires restarting the machine.

Frequently Asked Questions

Do I need a license key to install Windows in a virtual machine?

You can install Windows without a key and use it for 30 days. After that, Windows will ask you to activate. If you have a valid Windows license from your computer, you can use the same key in the virtual machine, though Microsoft's terms vary by license type. Check your license documentation or contact Microsoft support to confirm.

Can I run a virtual machine on a computer with 4 gigabytes of RAM?

Yes, but it will be slow. Assign no more than 2 gigabytes to the virtual machine, leaving 2 for your main operating system. For better performance, upgrade your RAM or use a lightweight Linux distribution instead of Windows.

What happens if I close the virtual machine window without shutting down?

The hypervisor will ask whether to save the state or shut down. If you save the state, the machine freezes exactly as it was and resumes from that point when you restart it. If you shut down, it closes like a normal computer. Saving state is faster but uses more disk space.

Can I move a virtual machine to a different computer?

Yes. Virtual machines are stored as files on your hard drive. Copy the entire virtual machine folder to an external drive, then copy it to another computer that has the same hypervisor installed. Open it there and it will run. This is one reason virtual machines are useful for system administrators.

Is running a virtual machine safe if I want to test untrusted software?

A virtual machine isolates software from your main system, so malware inside it cannot directly infect your main operating system. However, it can still spread to other computers on your network. Treat a virtual machine as a separate computer — do not assume it is completely safe just because it is virtual.