让你的 Windows 系统为虚拟机做好准备
虚拟机
![](/data/attachment/album/202309/13/100649idhbxhxehrqb9ahh.jpg)



> 
> 以下是确保 Windows 系统已准备好运行虚拟机的必要条件。
> 
> 
> 


在 VirtualBox 中看到了“<ruby> 无法打开虚拟机会话 <rt>  failed to open a session for the virtual machine </rt></ruby>”错误？


你的系统上可能没有启用虚拟化。


这是在 Windows 系统上创建虚拟机所需执行的几件事之一。


简单来说，你需要了解：


* 在你的 PC 上启用虚拟化支持
* 使用虚拟机程序创建/管理虚拟机
* 确保某些系统资源要求以无缝使用虚拟机


下面是第一件事：


### 在 Windows PC 上启用虚拟化


如果你的系统预装了 Windows 10/11，那么你很可能已经启用了虚拟化。你不需要额外的设置。


但如果你在系统上手动安装了 Windows，那么可能需要检查 BIOS 设置以查看它是否支持虚拟化。如果禁用，虚拟机程序将无法运行并给出错误。


这是使用 VirtualBox 程序时出现的错误：


![](/data/attachment/album/202309/13/100731nih654wuvow561zk.jpg)


你怎么能这么做呢？ 以下是基本步骤：


![](/data/attachment/album/202309/13/100731z7xywxyfrcfl0x73.jpg)


1. 前往 UEFI 固件设置（或 BIOS 菜单）。你通常可以通过按 `Del` 按钮或 `F1`、`F2`、`F10` 或 `F12` 来访问它。
2. 根据主板制造商的不同，用户界面会有所不同。但是，在大多数情况下，你必须进入到其中的“<ruby> 高级 <rt>  Advance </rt></ruby>”选项，并访问“<ruby> CPU 配置 <rt>  CPU Configuration </rt></ruby>”设置。
3. 在 CPU 配置中，你必须启用 “Intel (VMX) Virtualization Technology” 或 “SVM Mode”（适用于 AMD 处理器）。


下一步是什么？ 考虑到你已经启用了虚拟化支持，你需要使用 [虚拟化程序](https://itsfoss.com/virtualization-software-linux) 来帮助你完成工作。


### 使用虚拟化程序


你可以选择第三方应用以方便使用，也可以选择使用 Windows 自带的 Hyper-V。


#### Hyper-V


我们不会详细介绍如何使用 Hyper-V，但为了节省你一些时间，你可以按照以下步骤启用它，然后按照其[文档](https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/about/)使用它。



> 
> ? Hyper-V 不适用于 Windows 10/11 家庭版。
> 
> 
> 


考虑到你的系统上安装了 Windows 专业版/教育版/企业版，可以通过**控制面板**或使用 **PowerShell** 轻松启用它。


![](/data/attachment/album/202309/13/100731edlaadxd98hl90g0.jpg)


我更喜欢控制面板，只需在搜索栏中搜索 “Windows 功能”或通过 “控制面板 → 程序 → 打开或关闭 Windows 功能” 打开。


接下来，单击 “Hyper-V” 并点击 “OK”。就是这样。


![](/data/attachment/album/202309/13/100732sz6t70ckzqllkq8i.jpg)


它将通过获取所需的文件来应用更改。你只需要等待。


完成后，它会要求你**重启系统**以使新功能生效。


![](/data/attachment/album/202309/13/100732doyfs50okzkzo5so.jpg)


#### 第三方虚拟化程序


虽然使用 Hyper-V 可以让虚拟机获得更好的性能，但它使用起来却并不那么简单。


因此，建议终端用户使用第三方虚拟机程序。


最好的选择之一是 [VirtualBox](https://www.virtualbox.org/)。我们还有一个指南可以帮助你使用 [VirtualBox 安装 Linux](https://itsfoss.com/install-linux-in-virtualbox/)。


![](/data/attachment/album/202309/13/100732b7e1qls1706ev0ve.png)


它是一个开源程序，具有一系列功能和用户友好的界面。你也可以在 Windows、Linux 和 macOS 上使用它。


你还可以选择专有（但流行）的选项，例如 [VMware Workstation](https://www.vmware.com/products/workstation-player.html)。


想了解这些程序吗？你可以查看 Linux 下的一些可用选项，了解有哪些解决方案：



> 
> **[9 个最佳虚拟化软件](https://itsfoss.com/virtualization-software-linux/)**
> 
> 
> 


### 检查系统资源和要求


创建和使用虚拟机并不完全是一个非常占用资源的过程。但是，你可能需要注意一些变量。


其中一些包括：


* 确保你的系统至少有 4 GB 内存（越多越好）
* 双核或以上 64 位处理器


如果你不知道，即使虚拟机是孤立的机器，也会占用你系统的资源。大多数最低规格建议 4 GB RAM，但**我建议使用 8 GB**。


如果你想要**运行两个虚拟机**，你可能需要在 Windows 上拥有**超过 8GB 的内存**。


除了内存，你应该有一个**多核**处理器。这样，一些内核可以自由地让你在主机上做其他事情，而另一些内核则用于处理虚拟机。


当确定了处理器和内存，接下来就是**磁盘空间**。


对于虚拟机来说，磁盘通常是动态分配的，也就是说，物理存储驱动器的空间会随着操作系统及其文件的增加而消耗。


在某些类型的虚拟磁盘中，它保留你指定的整个空间。因此，执行此操作时，请在启动之前检查可用磁盘空间。通常最好选择一个未安装 Windows 系统的单独驱动器。


**如果你遵循了上述所有提示，你的 Windows 系统就可以运行和管理虚拟机了。现在，你可以 [在 Windows 的虚拟机中轻松地安装 Linux](https://itsfoss.com/install-linux-in-virtualbox/)**。


? 那么，你喜欢用什么方式来处理虚拟机？请在下面的评论中告诉我们你的想法。


*（题图：MJ/c1690724-a797-442b-8fb5-b6d41ef0c45c）*




---


via: <https://itsfoss.com/windows-enable-virtualization/>


作者：[Ankush Das](https://itsfoss.com/author/ankush/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

Seeing a '**failed to open a session for the virtual machine**' error with VirtualBox?

Chances are that you do not have virtualization enabled on your system.

And that's one of the several things you need to do to create a virtual machine on any of your Windows-powered systems.

To give you an overview, you need to learn about:

**Enabling virtualization support on your PC****Using a virtual machine program to create/manage VMs****Ensuring certain system resource requirements to seamlessly use virtual machines**

Here's the first thing:

## Enabling virtualization on Windows PC

If you have a system with Windows 10/11 pre-installed, chances are, you already have virtualization enabled. So you do not need to fiddle around with unnecessary settings.

But if you installed Windows manually on your system, you might have to check the BIOS settings to see if it supports virtualization. If disabled, the virtual machine program will not work and give you an error.

Here's what the error looks like when using VirtualBox program:

![virtualbox virtualization error](https://itsfoss.com/content/images/2023/07/virtualbox-error.jpg)

How can you do that? Here are the basic steps:

![screenshot of bios settings in asus motherboard](https://itsfoss.com/content/images/2023/07/bios-asus.jpg)

- Head to the UEFI Firmware settings (or BIOS menu). You can usually access it by pressing the "
**Del**" button or**F1, F2, F10, or F12**. - Depending on the motherboard manufacturer, the user interface will differ. However, in most cases, you have to navigate to the "
**Advanced**" options in that, and access "**CPU Configuration**" settings. - In the CPU configuration, you will have to enable "
**Intel (VMX) Virtualization Technology**" or "**SVM Mode**" (for AMD processors).

What's next? Considering you already enabled the virtualization support, you need to use [virtualization programs](https://itsfoss.com/virtualization-software-linux) to help you finish the job.

## Using virtualization programs

You can opt for third-party applications for ease of use, or choose to use Hyper-V that comes baked in with Windows.

### Hyper-V

We will not be detailing how to use Hyper-V, but to save you some time, you can follow the steps below to enable it and then follow its [documentation](https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/about/) to use it.

Considering you have a Windows Pro/Education/Enterprise edition installed on your system, it is easy to enable it from the **control panel** or using the **PowerShell**.

![windows features](https://itsfoss.com/content/images/2023/07/windows-features-on.jpg)

I prefer the control panel, just search for “Windows features” in the search bar or navigate your way through **Control Panel → Programs → Turn Windows features on or off**

Next, click on** “Hyper-V” **and hit** “OK”**.** **That's it.

![hyper v enable](https://itsfoss.com/content/images/2023/07/hyper-v-enable.jpg)

It will apply the changes by fetching the files needed for it. You just have to wait it out.

Once done, it will ask you to **restart the system **to put the new feature in effect.

![hyperv](https://itsfoss.com/content/images/2023/07/hyper-v-restart.jpg)

### Third-party virtualization programs

While using Hyper-V allows you to get better performance for virtual machines, it is not as simple to use.

So, third-party virtual machine programs are recommended for end-users.

One of the best bets is [VirtualBox](https://www.virtualbox.org). We also have a guide to help you use [VirtualBox to install Linux](https://itsfoss.com/install-linux-in-virtualbox/).

![virtualbox screenshot](https://itsfoss.com/content/images/2023/07/virtualbox-7.png)

It is an open-source program with a range of features, and a user-friendly interface. You can use it on Windows, Linux, and macOS as well.

You can also opt for proprietary (but popular) options like [VMware Workstation](https://www.vmware.com/products/workstation-player.html).

Want to get an idea on programs like these? You can check out some options available for Linux to see what kind of solutions are available:

[Top 9 Best Virtualization Software for Linux [2023]We take a look at some of the best virtualization programs that make things easy for users creating/managing VMs.](https://itsfoss.com/virtualization-software-linux/)![](https://itsfoss.com/content/images/2023/06/virtualization-software-for-linux.png)


![](https://itsfoss.com/content/images/2023/06/virtualization-software-for-linux.png)

## Checking system resources and requirements

Creating and using a virtual machine is not entirely a super intensive process. However, there are a couple of variables that you might have to keep an eye on.

Some of those include:

- Making sure that you have at least 4 GB RAM in your system (the more, the merrier)
- 64-bit processor with dual-core or more

If you did not know, VMs use up resources of your system even if they are isolated machines. Most minimum specification recommendations include 4 GB of RAM, but **I would recommend 8 GB** instead.

If you want to **run two virtual machines**, you might need **more than 8 GB of RAM** on Windows.

Coupled with the memory, you should have a **processor with multiple cores**. So, some cores can freely let you do other things on your host while some are busy with the virtual machines.

Once you are sure about the processor and memory, next comes the **disk space**.

For virtual machines, the disk is usually dynamically allocated, meaning, the space from your physical storage drive is consumed as much as the OS and its files add up with time.

In some type of virtual disk, it reserves the entire space you specify. So, when you do that, check the free disk space before you initiate it. It is typically a good idea to choose a separate drive where you do not have Windows system installed.

**Considering you follow all the above-mentioned tips, your Windows system will be ready to run and manage virtual machines. Now, you can **

**easily install Linux in a virtual machine on Windows**.

[How to Install Linux Inside Windows Using VirtualBoxUsing Linux in a virtual machine allows you to try Linux within Windows. This step-by-step guide shows you how to install Linux inside Windows using VirtualBox.](https://itsfoss.com/install-linux-in-virtualbox/)![](https://itsfoss.com/content/images/2023/07/install-linux-inside-windows-using-vm.png)


![](https://itsfoss.com/content/images/2023/07/install-linux-inside-windows-using-vm.png)

💬* So, what would be your preferred way to handle virtual machines? Let us know your thoughts in the comments below.*