VirtualBox is a free, open-source, cross-platform virtualization tool that allows you to create virtual machines and export them as Virtual Hard Disk (VHD) images. This topic guides you through creating a virtual machine (VM) in VirtualBox and installing a Linux operating system.
Prerequisites
VirtualBox is installed. If not, download from VirtualBox.
An ISO image is ready. Obtain an ISO file for your target OS (e.g., CentOS-7-x86_64-Minimal-2009.iso). You can download ISOs from the Alibaba Cloud Official Image Site.
Network connectivity is stable.
Procedure
Installation steps vary by operating system. This guide demonstrates how to create a VM and install CentOS 7.9 using VirtualBox 7.1.10.
Step 1: Create a virtual machine
Open the Oracle VirtualBox Manager. In the toolbar, go to File > Tools > Global Tools (or Preferences depending on OS), select the Expert tab, and click OK.
NoteIn VirtualBox 7.1.10, you must enable Expert mode to select specific disk file formats (like VHD) during creation. Otherwise, the wizard defaults to the VDI format.
Click New in the toolbar to launch the creation wizard.
Create a virtual machine.
Configure the Name And Operating System:
Name: Enter a descriptive name. Example: centosVM.
Directory: Choose the directory where the VM files will be stored.
ISO Image: Select the prepared ISO image file.
Version, Type: VirtualBox will automatically populate these fields based on the ISO.
Skip Unattended Installation: Check this box. We recommend manual installation to ensure custom partition configurations.
Configure Hardware.
Base Memory: Allocate RAM for the VM (e.g., 2048 MB).
Processors: Assign the number of virtual CPU cores.
Enable EFI (special OSes Only): Check this only if you intend to use UEFI boot mode. Leave unchecked for BIOS/Legacy boot.
In the Virtual Hard Disk section, select Create A Virtual Hard Disk Now.
Set the Disk Size and storage location.
Select Hard Disk File Type.
NoteECS supports importing image files only in the RAW, VHD, QCOW2, and VMDK formats. If you select a different format here, you must convert the format of the image before importing it.
Click Finish to provision the virtual machine.
Step 2: Install the operating system
You can install the OS using either BIOS or UEFI boot mode. This choice determines how the ECS instance created from this image will boot. For more information about boot modes, see Instance boot modes.
BIOS
Select the new VM in the list and click Start.
The VM will boot from the ISO. Follow the on-screen installation wizard.
Select your language and click Continue.
On the INSTALLATION SUMMARY page, click INSTALLATION DESTINATION.
On the INSTALLATION DESTINATION page, select Local Standard Disks for Device Selection, select I Will Configure Partitioning for Partitioning, and then click Done.
On the MANUAL PARTITIONING page, click
, set Mount Point to /, Device Type to Standard Partition, and File System to ext4, and then click Done.On the INSTALLATION SUMMARY page, click NETWORK & HOST NAME.
On the NETWORK & HOST NAME page, select Ethernet, click the ON button on the right side, and then click Done.
On the INSTALLATION SUMMARY page, click Begin Installation.
Once installation completes, set a password for the root user, and then click FINISH CONFIGURATION.
Remember this password. It is required to log in to the VM.
Restart the system.
Log on to the VM and run the following command to verify the partition layout. Ensure the root partition is mounted correctly on a standard partition structure, otherwise, the instance may fail to boot or resize storage later.
lsblkA command output similar to the following one is returned.

UEFI
Select the new VM in the list and click Start.
Follow the on-screen installation wizard.
Select your language and click Continue.
On the INSTALLATION SUMMARY page, click INSTALLATION DESTINATION.
On the INSTALLATION DESTINATION page, select Local Standard Disks for Device Selection, select I Will Configure Partitioning for Partitioning, and then click Done.
On the MANUAL PARTITIONING page, click
, set Mount Point, Device Type, and File System, and then click Done.You must first mount the /boot/efi partition, select Standard Partition for Device Type, and then select EFI System Partition for File System.
Mount the / root partition, select Standard Partition for Device Type, and then select Ext4 for File System.
ImportantThe system disk can have only the root partition. If the system disk has other partitions, the instance cannot start or the disk cannot be resized. Therefore, you must mount the root partition at last.
On the INSTALLATION SUMMARY page, click Begin Installation.
Once the installation completes, set a password for the root user, and then click FINISH CONFIGURATION.
Remember this password. It is required to log in to the VM.
Restart the system.
Log on to the VM and run the following command to verify the partition layout. Ensure the root partition is mounted correctly on a standard partition structure, otherwise, the instance may fail to boot or resize storage later.
lsblkA command output similar to the following one is returned.

What to do next
Prepare the image for import to Alibaba Cloud by performing the following tasks:
Install cloud-init: Required for the ECS instance to initialize system configurations (hostnames, keys, etc.) upon first boot.
Install the virtio driver: Crucial for KVM compatibility. You must verify and install virtio drivers on the source server to ensure the instance boots correctly on Alibaba Cloud.
(Optional) Customize Linux images: If using a non-standard distribution, you may need to add parsing scripts to ensure the system recognizes Alibaba Cloud metadata.
Check and repair an image: Use the Image Compliance Tool to automatically validate the image file before importing it.