All Products
Search
Document Center

Elastic Compute Service:Create a virtual machine and install a Windows operating system

Last Updated:May 14, 2024

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 Windows operating system provided by VirtualBox. 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: win2019zh-cn20221013110224.iso.

  • Network connectivity is good.

Procedure

The procedure to install an operating system on a virtual machine may vary based on the operating system. In this topic, VirtualBox 7.0.2 is used to create a virtual machine and install Windows Server 2019 on the virtual machine.

Step 1: Create a virtual machine

  1. Open Oracle VM VirtualBox Manager and click New.

  2. In the Create Virtual Machine wizard, configure parameters and click Next.

    • Name: Enter a name for the virtual machine. Example: Windows VM.

    • Folder: Specify a folder in which to store the virtual machine on your computer.

    • Type: Select Microsoft Windows as the operating system type.

    • Version: Select an operating system version.

  3. On the Create Virtual Machine page, select a memory size based on the configuration of the virtual machine that you want to create and the requirements of the Windows operating system that you want to install, and then click Next. The default memory size is 1,024 MB. In this example, 4,096 MB is used.

  4. On the Create Virtual Machine page, select Create a virtual hard disk now for Hard disk and click Create.

  5. On the Create Virtual Hard Disk page, select VHD (Virtual Hard Disk) for Hard disk file type and click Next.

    Note

    Only image files in the RAW, VHD, and QCOW2 formats can be imported to Elastic Compute Service (ECS). If you select a different format here, you must convert the created image to a supported format before you can import the image to ECS. For more information, see Convert the format of an image.

  6. On the Create Virtual Hard Disk page, select Dynamically allocated for Storage on physical hard disk and click Next.

  7. On the Create Virtual Hard Disk page, select a directory in which to store the virtual hard disk file for the virtual machine, specify the size of the virtual hard disk, and then click Create. In this example, the size of the virtual hard disk is set to 40 GB.

    Wait until the virtual machine is created.

Step 2: Install a Windows operating system

The boot mode is the mode in which the system disk is booted during ECS instance creation. Two boot modes are available: Unified Extensible Firmware Interface (UEFI) and Basic Input Output System (BIOS). 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 Best practices for using the UEFI and BIOS boot modes.

Method 1: Install a Windows operating system in BlOS mode

  1. Open Oracle VM VirtualBox Manager and select the new virtual machine. Example: Windows VM.

  2. Click Settings.

  3. Choose Storage > Empty > 盘片 > Choose a disk file, select the Windows image file win2019zh-cn20221013110224.iso, and then click OK.

  4. Select the new virtual machine and click Start to start the virtual machine.

  5. Install the Windows operating system on the virtual machine. Configure the required parameters and wait for the installation to complete.

Method 2: Install a Windows operating system in UEFI mode

  1. Open Oracle VM VirtualBox Manager and select the new virtual machine. Example: Windows VM.

  2. Click Settings.

  3. Choose Storage > Empty > 盘片 > Choose a disk file, select the Windows image file win2019zh-cn20221013110224.iso, and then click OK.

  4. Click Settings.

  5. In the Settings Windows, select System in the left-side navigation pane. On the Motherboard tab, select Enable EFI (special OSes only) for Extended Features and click OK.

  6. Select the new virtual machine and click Start to start the virtual machine.

  7. Install the Windows operating system on the virtual machine. Configure the required parameters.

    Note
    • During the virtual machine boot process, press any key to boot the operating system. Otherwise, you are directed to the shell command prompt.

    • 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.

  8. Create an EFI partition.

    1. On the partition loading page, press Shift+F10 to open the command prompt. Then, run the diskpart command to start Microsoft DiskPart.

    2. Run the following command to query the disks that are installed on the virtual machine:

      list disk
    3. Run the following command to select a hard disk:

      select disk 0
    4. Run the following command to clear all partitions on the selected disk:

      clean
    5. Run the following command to convert the selected disk to a GUID partition table (GPT) partitioned disk:

      convert gpt
    6. Run the following command to create an EFI partition:

      create partition efi size=[$Size]
      Note

      [$Size] specifies the partition size. We recommend that you set this parameter to a value smaller than or equal to 300 MB. In this example, 200 MB is used.

    7. Run the following command to create a primary partition and use the remaining space:

      create partition primary
    8. Run the following command to verify that the EFI partition is created:

      list partition
    9. Click Refresh to update partition information. Click Format to format the system partition. Then, click Next.

  9. Install the Windows operating system on the virtual machine. Configure the required parameters and wait for the installation to complete.

  10. Set a logon password for the virtual machine. Log on to the virtual machine and open the Disk Management window to verify that the EFI partition is created.

  11. Choose Start > Run. Enter cmd to open the command prompt.

  12. Run the following command to verify that the boot mode of the operating system is UEFI.

    msinfo32

Step 3: Configure the operating system

  1. After the Windows operating system is installed, activate the operating system. Alternatively, import the generated custom image to ECS and then use Alibaba Cloud Key Management Service (KMS) to activate the operating system. For more information, see How do I use KMS domain names to activate a Windows instance in a VPC?

  2. Allow remote access to the Windows operating system.

    1. In the Control Panel, select System and Security.

    2. In the System section, click Allow remote access.

    3. On the Remote tab of the System Properties window, make sure that Allow remote connection to this computer is selected, and then click OK.

  3. Disable the Windows Defender Firewall.

    1. In the Control Panel, select System and Security.

    2. In the Windows Defender Firewall section, click Check firewall status.

    3. In the left-side navigation pane, select Turn Windows Defender Firewall on or off.

    4. 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.