All Products
Search
Document Center

Elastic Compute Service:Best practices for the UEFI and Legacy BIOS boot modes

Last Updated:Dec 05, 2023

The boot mode is the mode in which the system disk is booted during instance creation. Elastic Compute Service (ECS) supports two boot modes: Unified Extensible Firmware Interface (UEFI) and Legacy Basic Input/Output System (BIOS). This topic describes the differences between UEFI and Legacy BIOS and how to view and change the boot mode of an image.

Overview of boot modes

The boot mode of an ECS instance is determined based on the supported boot modes of the instance type and the boot mode of the image that is used to create the instance.

Boot modes of instance types

ECS instance types support UEFI, Legacy BIOS, or both. You cannot change the supported boot modes of ECS instance types. The following table describes the boot modes that are supported by different instance families.

Boot mode

Instance family

Legacy BIOS

  • x86-based enterprise-level computing instance families

    • ecs.i2, ecs.i2g, ecs.i2ne, ecs.i2gne, ecs.d2s, ecs.re6, ecs.d2c, ecs.u1, ecs.d3s, ecs.d3c, ecs.i3g, ecs.i4g, ecs.i4p, ecs.i4r

    • ecs.hfc5, ecs.ic5

    • ecs.g6a, ecs.c6a, ecs.r6a, ecs.g6h, ecs.re6p

    • ecs.g7a, ecs.r7a, ecs.c7a, ecs.re7p, ecs.r7p, ecs.g7nex, ecs.c7nex

  • Enterprise-level heterogeneous computing instance families

    • ecs.gn5, ecs.gn5i, ecs.vgn5i

    • ecs.gn6e, ecs.gn6i, ecs.gn6v, ecs.vgn6i-vws

    • ecs.gn7, ecs.gn7e, ecs.gn7i, ecs.gn7r, ecs.gn7s, ecs.sgn7i-vws, ecs.vgn7i-vws, ecs.sccgn7ex

  • ECS Bare Metal Instance families and Super Computing Cluster (SCC) instance families

    • ecs.ebmg5, ecs.ebmr5, ecs.ebmhfg5

    • ecs.ebmg6e, ecs.ebmc6e, ecs.hfr6, ecs.ebmc6, ecs.ebmr6, ecs.ebmgn6i, ecs.ebmgn6v

    • ecs.ebmr7, ecs.ebmg7, ecs.ebmc7, ecs.ebmhfr7, ecs.ebmhfg7, ecs.ebmhfc7, ecs.ebmgn7e, ecs.ebmgn7i

UEFI

  • x86-based enterprise-level computing instance families

    • ecs.c6t, ecs.g6t

    • ecs.c7t, ecs.g7t, ecs.r7t

  • ARM-based enterprise-level computing instance families

    • ecs.c6r, ecs.g6r

    • ecs.g8y, ecs.c8y, ecs.r8y

  • ECS Bare Metal Instance families and SCC instance families

    • ecs.ebmg6a, ecs.ebmr6a, ecs.ebmc6a, ecs.ebmgn6ia

    • ecs.ebmg7a, ecs.sccc7, ecs.sccg7, ecs.ebmc7a, ecs.ebmr7a, ecs.ebmgn7ex, ecs.ebmgn7ix, ecs.ebmgn7vx

Legacy BIOS and UEFI

  • x86-based enterprise-level computing instance families

    • ecs.g5, ecs.c5, ecs.g5ne, ecs.hfg5, ecs.r5

    • ecs.g6, ecs.c6, ecs.c6e, ecs.hfg6, ecs.g6e, ecs.r6e, ecs.hfc6, ecs.r6

    • ecs.g7, ecs.c7, ecs.r7, ecs.hfg7, ecs.g7ne, ecs.hfc7, ecs.hfr7, ecs.g7nex, ecs.c7nex

    • ecs.g8i, ecs.c8i, ecs.g8a, ecs.c8a, ecs.r8a, ecs.g8ae, ecs.c8ae, ecs.r8ae, ecs.hfg8i, ecs.hfc8i, ecs.hfr8i

  • x86-based shared computing instance families

    • ecs.n4

    • ecs.t5

    • ecs.s6, ecs.t6

When you select an instance type that supports a specific boot mode during instance creation, only images that support the boot mode are displayed. For example, if you select a security-enhanced instance type that supports only UEFI, only UEFI images are displayed, as shown in the following figure.

image..png

Boot modes of images

During instance creation, the system disk is booted based on the boot mode of the image.

  • Public images

    You cannot change the boot modes of public images.

    • UEFI public images: support only UEFI.

      For example, the boot mode of public images whose names include UEFI, such as Alibaba Cloud Linux 2.1903 64-bit (UEFI), Ubuntu 18.04 64-bit (UEFI), and Debian 11.6 64-bit (UEFI), is UEFI.

    • ARM public images: support only UEFI.

      For example, the boot mode of public images whose names include ARM, such as Ubuntu 20.04 64-bit for ARM and CentOS 8.4 64-bit for ARM, is UEFI.

    • Other public images: support only Legacy BIOS.

  • Custom images

    By default, a custom image inherits the boot mode of the image from which the custom image is derived. For information about how to change the default boot mode of a custom image, see the "Change the boot mode of a custom image" section of this topic.

Advantages of UEFI over Legacy BIOS

  • Support for large disk sizes

    Legacy BIOS uses the Master Boot Record (MBR) partitioning scheme and supports hard disks that are up to 2 TB in size. UEFI uses the GUID Partition Table (GPT) partitioning scheme and supports hard disks that are larger than 2 TB in size.

  • High speed and performance

    Legacy BIOS requires all devices to be scanned at boot time. UEFI requires only necessary drivers to load at boot time, and boots faster than Legacy BIOS.

  • Security

    UEFI provides the Secure Boot feature. UEFI allows only authentic drivers and services to load at boot time and ensures that instances do not load malware on startup. UEFI requires digital signatures for drivers and the kernel, and can be used to protect against piracy and boot-sector malware.

  • Scalability

    UEFI is an extensible, standard solid-state interface. Legacy BIOS is a rigid, unofficial standard that is developed based on conventions that are no longer relevant and is poorly documented.

  • Flexibility

    UEFI is a 32-bit or 64-bit program that is written in the C language. UEFI is not limited to real mode and provides more addressable address space. Legacy BIOS is a 16-bit program assembly language that can run only in 16-bit real mode and provides only 1 MB of addressable memory.

View the boot mode of an image

You can use one of the following methods to view the boot mode of an image:

  • Method 1: Use the ECS console

    In the ECS console, go to the details page of an image to view the boot mode of the image.

    image

  • Method 2: Call an API operation

    Call the DescribeImages operation to query an image and check the boot mode of the image in the BootMode response parameter.

    • If the value of BootMode is BIOS, the image uses the Legacy BIOS boot mode.

    • If the value of BootMode is UEFI, the image uses the UEFI boot mode.

Create a UEFI image or Legacy BIOS image

To create a UEFI image or Legacy BIOS image, you can use the ECS console or call the ImportImage or CreateImage operation.

Method 1: Use the ECS console

In the ECS console, you can specify the boot mode of an image only when you import a source image. By default, ARM images use the UEFI boot mode, as shown in the following figure. For non-ARM images, you can specify a boot mode based on your business requirements. For more information, see Import a custom image.

image

Method 2: Call an API operation

You can call the CreateImage or ImportImage operation to create a UEFI image or Legacy BIOS image.

  • ImportImage

    Use SDK for Java to create a UEFI image

    import com.aliyuncs.CommonRequest;
    import com.aliyuncs.CommonResponse;
    import com.aliyuncs.DefaultAcsClient;
    import com.aliyuncs.IAcsClient;
    import com.aliyuncs.exceptions.ClientException;
    import com.aliyuncs.exceptions.ServerException;
    import com.aliyuncs.http.MethodType;
    import com.aliyuncs.profile.DefaultProfile;
    /*
    pom.xml
    <dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-core</artifactId>
    <version>4.6.0</version>
    </dependency>
    */
    
    public class ImportImage {
        public static void main(String[] args) {
    
            DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<your-access-key-id>", "<your-access-key-secret>");
            IAcsClient client = new DefaultAcsClient(profile);
            CommonRequest request = new CommonRequest();
    
            request.setSysMethod(MethodType.POST);
            request.setSysDomain("ecs-cn-hangzhou.aliyuncs.com");
            request.setSysVersion("2014-05-26");
            request.setSysAction("ImportImage");
            request.putQueryParameter("RegionId", "cn-hangzhou");
            request.putQueryParameter("BootMode", "UEFI");
            request.putQueryParameter("DiskDeviceMapping.1.DiskImSize", "20");
            request.putQueryParameter("DiskDeviceMapping.1.OSSBucket", "ale-test");
            request.putQueryParameter("DiskDeviceMapping.1.OSSObject", "aliyun.raw");
            request.putQueryParameter("Platform", "Aliyun");
            try {
                CommonResponse response = client.getCommonResponse(request);
                System.out.println(response.getData());
            } catch (ServerException e) {
                e.printStackTrace();
            } catch (ClientException e) {
                e.printStackTrace();
            }
        }
    }
    

    Use SDK for Python to create a Legacy BIOS image

    #!/usr/bin/env python
    #coding=utf-8
    
    from aliyunsdkcore.client import AcsClient
    from aliyunsdkcore.request import CommonRequest
    from aliyunsdkcore.auth.credentials import AccessKeyCredential
    from aliyunsdkcore.auth.credentials import StsTokenCredential
    
    credentials = AccessKeyCredential('<your-access-key-id>', '<your-access-key-secret>')
    client = AcsClient(region_id='cn-hangzhou', credential=credentials)
    
    request = CommonRequest()
    request.set_accept_format('json')
    request.set_domain('ecs-cn-hangzhou.aliyuncs.com')
    request.set_method('POST')
    request.set_protocol_type('https') # https | http
    request.set_version('2014-05-26')
    request.set_action_name('ImportImage')
    
    request.add_query_param('RegionId', "cn-hangzhou")
    request.add_query_param('BootMode', "BIOS")
    request.add_query_param('DiskDeviceMapping.1.DiskImSize', "20")
    request.add_query_param('DiskDeviceMapping.1.OSSBucket', "ale-test")
    request.add_query_param('DiskDeviceMapping.1.OSSObject', "aliyun.raw")
    request.add_query_param('Platform', "Aliyun")
    
    response = client.do_action(request)
    print(str(response, encoding = 'utf-8'))
    
  • CreateImage

    Use SDK for Java to create a UEFI image

    import com.aliyuncs.DefaultAcsClient;
    import com.aliyuncs.IAcsClient;
    import com.aliyuncs.exceptions.ClientException;
    import com.aliyuncs.exceptions.ServerException;
    import com.aliyuncs.profile.DefaultProfile;
    import com.google.gson.Gson;
    import java.util.*;
    import com.aliyuncs.ecs.model.v20140526.*;
    /*
    pom.xml
    <dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-core</artifactId>
    <version>4.6.0</version>
    </dependency>
    */
    
    public class CreateImage {
    
        public static void main(String[] args) {
    
            DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<your-access-key-id>", "<your-access-key-secret>");
            IAcsClient client = new DefaultAcsClient(profile);
    
            CreateImageRequest request = new CreateImageRequest();
            request.setRegionId("cn-hangzhou");
            request.setInstanceId("i-xxxx");
            request.setBootMode("UEFI");
            request.setImageName("test-uefi");
    
            try {
                CreateImageResponse response = client.getAcsResponse(request);
                System.out.println(new Gson().toJson(response));
            } catch (ServerException e) {
                e.printStackTrace();
            } catch (ClientException e) {
                System.out.println("ErrCode:" + e.getErrCode());
                System.out.println("ErrMsg:" + e.getErrMsg());
                System.out.println("RequestId:" + e.getRequestId());
            }
    
        }
    }
    

    Use SDK for Python to create a Legacy BIOS image

    #!/usr/bin/env python
    #coding=utf-8
    
    from aliyunsdkcore.client import AcsClient
    from aliyunsdkcore.acs_exception.exceptions import ClientException
    from aliyunsdkcore.acs_exception.exceptions import ServerException
    from aliyunsdkcore.auth.credentials import AccessKeyCredential
    from aliyunsdkcore.auth.credentials import StsTokenCredential
    from aliyunsdkecs.request.v20140526.CreateImageRequest import CreateImageRequest
    
    credentials = AccessKeyCredential('<your-access-key-id>', '<your-access-key-secret>')
    client = AcsClient(region_id='cn-hangzhou', credential=credentials)
    
    request = CreateImageRequest()
    request.set_accept_format('json')
    
    request.set_InstanceId("i-xxxx")
    request.set_ImageName("test-bios")
    request.set_BootMode("BIOS")
    
    response = client.do_action_with_exception(request)
    print(str(response, encoding='utf-8'))
    

Change the boot mode of a custom image

You can change the boot mode of a custom image in the ECS console or by calling an API operation.

You can change the boot mode of an image in the following scenarios:

  • You changed the boot partition configuration of the system disk on an ECS instance and want the custom images that are created from the instance to use a different boot mode.

  • You want to change the boot mode of an imported custom image.

Note

If an image is associated with ECS instances, you cannot change the boot mode of the image.

Method 1: Use the ECS console

In the ECS console, go to the details page of an image to change the boot mode of the image. For more information, see Modify the attributes and tags of an image.

Method 2: Call an API operation

Call the ModifyImageAttribute operation and modify the BootMode parameter to change the boot mode of an image.

Use SDK for Java to change the boot mode of an image to UEFI

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.google.gson.Gson;
import java.util.*;
import com.aliyuncs.ecs.model.v20140526.*;
/*
pom.xml
<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>aliyun-java-sdk-core</artifactId>
  <version>4.6.0</version>
</dependency>
*/

public class ModifyImageAttribute {

    public static void main(String[] args) {

        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<your-access-key-id>", "<your-access-key-secret>");
        IAcsClient client = new DefaultAcsClient(profile);

        ModifyImageAttributeRequest request = new ModifyImageAttributeRequest();
        request.setRegionId("cn-hangzhou");
        request.setImageId("m-xxx");
        request.setBootMode("UEFI");

        try {
            ModifyImageAttributeResponse response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            System.out.println("ErrCode:" + e.getErrCode());
            System.out.println("ErrMsg:" + e.getErrMsg());
            System.out.println("RequestId:" + e.getRequestId());
        }

    }
}

Use SDK for Python to change the boot mode of an image to Legacy BIOS

#!/usr/bin/env python
#coding=utf-8

from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkcore.auth.credentials import AccessKeyCredential
from aliyunsdkcore.auth.credentials import StsTokenCredential
from aliyunsdkecs.request.v20140526.ModifyImageAttributeRequest import ModifyImageAttributeRequest

credentials = AccessKeyCredential('<your-access-key-id>', '<your-access-key-secret>')
client = AcsClient(region_id='cn-hangzhou', credential=credentials)
request = ModifyImageAttributeRequest()
request.set_accept_format('json')
request.set_ImageId("m-xxx")
request.set_BootMode("BIOS")

response = client.do_action_with_exception(request)
print(str(response, encoding='utf-8'))