VirtualBox is a free open source cross-platform virtual machine software. You can create a Windows image file in the Virtual Hard Disk (VHD) format based on the software. This topic describes how to create a virtual machine by using VirtualBox and install a Windows operating system on the virtual machine.
Prerequisites
VirtualBox is installed. If VirtualBox is not installed, click VirtualBox to download VirtualBox.
An ISO image file is prepared. Example: win2022zh-cn.iso.
Network connectivity is stable.
Procedure
The procedure to install an operating system on a virtual machine may vary based on the operating system. In this topic, VirtualBox 7.1.10 is used to create a virtual machine and install Windows Server 2022 on the virtual machine.
Step 1: Create a virtual machine
Open Oracle VirtualBox Manager, click Global Settings in the toolbar, select the Expert tab, and click OK.
NoteIn this version of VirtualBox, you must select the Expert tab to enable expert mode. This allows you to select the virtual disk file type when creating a virtual machine. Otherwise, the VDI format is used by default.
Click New in the toolbar.
Create a virtual machine.
In the Virtual Machine Name And Operating System Type section, configure the name and operating system type of the virtual machine.
Name: Enter a name for the virtual machine. Example: WindowsVM.
Folder: Select a folder in which to store the virtual machine.
ISO Image: Select the prepared ISO image file.
Version and Type: VirtualBox automatically fills in the operating system version and type based on the ISO image file.
Skip Unattended Installation: By default, VirtualBox automatically installs the selected operating system. We recommend that you select Skip Unattended Installation.
In the Hardware section, configure the hardware of the virtual machine.
Memory Size: Allocate the amount of memory to be used when the virtual machine starts.
Processors: Allocate the number of virtual CPUs.
Enable EFI (special OSes Only): Select this option if you want to start the virtual machine in UEFI mode. Otherwise, the virtual machine starts in BIOS mode.
In the Virtual Hard Disk section, select Create A Virtual Hard Disk Now.
Select a location to store the virtual hard disk file and specify the disk size.
Select Hard Disk File Type.
NoteOnly image files in the RAW, VHD, QCOW2, and Virtual Machine Disk (VMDK) formats can be imported to ECS. If you select a different format here, you must convert the format of the image before you can import the image.
Click Finish and wait for the virtual machine to be created.
Step 2: Install an operating system
The boot mode is the mode in which the system disk is booted during ECS instance creation. Two boot modes are available: Basic Input Output System (BIOS) and Unified Extensible Firmware Interface (UEFI). You can use one of the boot modes to install a Windows operating system. After the operating system is installed, the system disk is booted in the boot mode. For more information about boot modes, see Instance boot modes.
BIOS mode
Select the new virtual machine and click Start in the toolbar to start the virtual machine.
Manually select the required installation parameters to install the Windows operating system on the virtual machine, and wait for the installation to complete.
UEFI mode
Select the new virtual machine and click Start in the toolbar to start the virtual machine.
Select the required installation parameters to install the Windows operating system on the virtual machine.
Create a custom EFI partition.
In the operating system that uses the UEFI boot mode, the default partitions include a recovery partition, which causes an instance startup exception or a disk resizing exception. As a result, the system partition cannot be read. To resolve this issue, you must create Extensible Firmware Interface (EFI) partitions when you select disks during the operating system installation process.
ImportantDuring the virtual machine boot process, press any key to boot the operating system. Otherwise, you are directed to the shell command prompt.
Step 3: Configure the operating system
Allow remote access to the Windows operating system.
In the Control Panel, select System And Security.
In the System section, click Allow Remote Access.
On the Remote tab of the System Properties window, make sure that Allow Remote Connection To This Computer is selected, and then click OK.
Disable the Windows Defender Firewall.
In the Control Panel, select System And Security.
In the Windows Defender Firewall section, click Check Firewall Status.
In the left-side navigation pane, select Turn Windows Defender Firewall On Or Off.
On the Customize Settings For Each Type Of Network page, set Private Network Settings and Public Network Settings to Turn Off Windows Defender Firewall (not Recommended), and then click OK.
What to do next
You can perform the following operations based on your business requirements:
Install Vminit to ensure that the ECS instances created from the image can complete initialization.
Install the virtio driver to prevent the operating system in the image from failing to start after the image is imported to ECS. Before you import the image, you must check whether the virtio driver is installed.