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 |
|
UEFI |
|
Legacy BIOS and UEFI |
|
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.
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.
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.
Method 2: Call an API operation
You can call the CreateImage or ImportImage operation to create a UEFI image or Legacy BIOS image.
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'))
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.
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'))