このページは、お客様の言語ではご利用いただけません。Huawei Cloudは、より多くの言語バージョンを追加するために懸命に取り組んでいます。ご協力ありがとうございました。

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Image Management Service/ Best Practices/ Creating a Linux Image Using VirtualBox and an ISO File/ Configuring the VM/ Installing Drivers and Changing the Disk Identifiers to the UUID Format

Installing Drivers and Changing the Disk Identifiers to the UUID Format

Updated on 2023-06-09 GMT+08:00

To ensure that the ECSs created from the image support both Xen and KVM virtualization, install Native Xen and KVM drivers and change the disk identifiers to the UUID format for the VM which is used as the image source.

This section describes how to perform these operations on a Linux VM that runs Ubuntu 20.04. For other OSs, see Optimization Process (Linux).

Install Native Xen and KVM Drivers

  1. Run the following command to open the modules file:

    vi /etc/initramfs-tools/modules

  2. Press i to enter the editing mode and add the native Xen (xen-pv) and KVM (virtio) drivers to the /etc/initramfs-tools/modules file (the format depends on the OS requirements).
    [root@CTU10000xxxxx ~]#vi /etc/initramfs-tools/modules 
    ...
    # Examples: 
    # 
    # raid1 
    # sd_mOd 
    xen-blkfront 
    xen-netfront 
    virtio_blk 
    virtio_scsi 
    virtio_net 
    virtio_pci 
    virtio_ring 
    virtio  
  3. Press Esc, enter :wq, and press Enter to save the settings and exit the vi editor.
  4. Run the following command to generate initrd again:

    update-initramfs -u

  5. Run the following commands to check whether native Xen and KVM drivers have been installed:

    lsinitramfs /boot/initrd.img-`uname -r` |grep xen

    lsinitramfs /boot/initrd.img-`uname -r` |grep virtio

    [root@ CTU10000xxxxx home]# lsinitramfs /boot/initrd.img-`uname -r` |grep xen 
    lib/modules/3.5.0-23-generic/kernel/drivers/net/ethernet/qlogic/netxen 
    lib/modules/3.5.0-23-generic/kernel/drivers/net/ethernet/qlogic/netxen/netxen_nic.ko 
    lib/modules/3.5.0-23-generic/kernel/drivers/net/xen-netback 
    lib/modules/3.5.0-23-generic/kernel/drivers/net/xen-netback/xen-netback.ko 
    lib/modules/3.5.0-23-generic/kernel/drivers/block/xen-blkback 
    lib/modules/3.5.0-23-generic/kernel/drivers/block/xen-blkback/xen-blkback.ko 
     
    [root@ CTU10000xxxxx home]# lsinitramfs /boot/initrd.img-`uname -r` |grep virtio 
    lib/modules/3.5.0-23-generic/kernel/drivers/scsi/virtio_scsi.ko
    NOTE:

    If you add built-in drivers to the initrd or initramfs file, the VM will not be affected. This makes it easy to modify the drivers. However, the drivers cannot be shown by running the lsinitrd command. You can run the following commands to check whether the drivers are built-in ones in the kernel:

    [root@ CTU10000xxxxx home]# cat /boot/config-`uname -r` | grep CONFIG_VIRTIO | grep y
    CONFIG_VIRTIO_BLK=y
    CONFIG_VIRTIO_NET=y
    CONFIG_VIRTIO=y
    CONFIG_VIRTIO_RING=y
    CONFIG_VIRTIO_PCI=y
    CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
    [root@ CTU10000xxxxx home]# cat /boot/config-`uname -r` | grep CONFIG_XEN | grep y
    CONFIG_XEN_BLKDEV_FRONTEND=y
    CONFIG_XEN_NETDEV_FRONTEND=y

Change the Disk Identifier in the GRUB Configuration File to the UUID Format

Take Ubuntu 20.04 as an example. Run blkid to obtain the UUID of the root partition. Modify the /boot/grub/grub.cfg file and use the UUID of the root partition to configure the boot item. If the root partition already uses UUID, no modification is required. The procedure is as follows:
  1. Log in to the newly created VM as user root.
  2. Run the following command to query all types of mounted file systems and their device UUIDs:

    blkid

    The following information is displayed:

    /dev/xvda1: UUID="ec51d860-34bf-4374-ad46-a0c3e337fd34" TYPE="ext3"
    /dev/xvda5: UUID="7a44a9ce-9281-4740-b95f-c8de33ae5c11" TYPE="swap"
  1. Run the following command to query the grub.cfg file:

    cat /boot/grub/grub.cfg

    The following information is displayed:

    ......menuentry 'Ubuntu Linux, with Linux 3.13.0-24-generic' --class ubuntu --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.13.0-24-generic-advanced-ec51d860-34bf-4374-ad46-a0c3e337fd34' {
    recordfail
    load_video
    gfxmode $linux_gfx_mode
    insmod gzio
    insmod part_msdos
    insmod ext2
    if [ x$feature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root ec51d860-34bf-4374-ad46-a0c3e337fd34
    else
    search --no-floppy --fs-uuid --set=root ec51d860-34bf-4374-ad46-a0c3e337fd34
    fi
    echo 'Loading Linux 3.13.0-24-generic ...'
    linux /boot/vmlinuz-3.13.0-24-generic root=/dev/xvda1 ro 
    echo 'Loading initial ramdisk ...'
    initrd /boot/initrd.img-3.13.0-24-generic 
    }
  1. Check whether the /boot/grub/grub.cfg configuration file contains root=/dev/xvda1 or root=UUID=ec51d860-34bf-4374-ad46-a0c3e337fd34.
    • If root=UUID=ec51d860-34bf-4374-ad46-a0c3e337fd34 is contained, the root partition is in the UUID format and no further action is required.
    • If root=/dev/xvda1 is contained, the root partition is represented by a device name. Go to step 5.
  1. Obtain the UUID of the root partition based on root=/dev/xvda1 and information obtained by running the blkid command.
  2. Run the following command to open the grub.cfg file:

    vi /boot/grub/grub.cfg

  3. Press i to enter the editing mode. Change the identifier of the root partition to the UUID format. For example, change root=/dev/xvda1 to root=UUID=ec51d860-34bf-4374-ad46-a0c3e337fd34.
  4. Press Esc, enter :wq, and press Enter to save the settings and exit the vi editor.
  5. Run the following command to verify the change:

    cat /boot/grub/grub.cfg

    The change is successful if information similar to the following is displayed:

    ......menuentry 'Ubuntu Linux, with Linux 3.13.0-24-generic' --class ubuntu --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.13.0-24-generic-advanced-ec51d860-34bf-4374-ad46-a0c3e337fd34' {
    recordfail
    load_video
    gfxmode $linux_gfx_mode
    insmod gzio
    insmod part_msdos
    insmod ext2
    if [ x$feature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root ec51d860-34bf-4374-ad46-a0c3e337fd34
    else
    search --no-floppy --fs-uuid --set=root ec51d860-34bf-4374-ad46-a0c3e337fd34
    fi
    echo 'Loading Linux 3.13.0-24-generic ...'
    linux /boot/vmlinuz-3.13.0-24-generic root=UUID=ec51d860-34bf-4374-ad46-a0c3e337fd34 ro
    echo 'Loading initial ramdisk ...'
    initrd /boot/initrd.img-3.13.0-24-generic
    }

Change the Disk Identifiers in the fstab File to the UUID Format

Take Ubuntu 20.04 as an example. Run blkid to obtain the UUIDs of all partitions. Modify the /etc/fstab file and use the partition UUIDs to configure automatic partition mounting.

  1. Run the following command to query all types of mounted file systems and their device UUIDs:

    blkid

    The following information is displayed:

    /dev/xvda2: UUID="4eb40294-4c6f-4384-bbb6-b8795bbb1130" TYPE="xfs"  
    /dev/xvda1: UUID="2de37c6b-2648-43b4-a4f5-40162154e135" TYPE="swap"
  2. Run the following command to query the fstab file:

    cat /etc/fstab

    The following information is displayed:

    [root@CTU1000028010 ~]# cat /etc/fstab  
    /dev/xvda2  /       xfs     defaults    0 0 
    /dev/xvda1  swap    swap    defaults    0 0     
  3. Check whether the disk identifiers in the fstab file are device names or UUIDs.
    • If they are UUIDs, no further action is required.
    • If they are device names, go to step 4.
  4. Run the following command to open the fstab file:

    vi /etc/fstab

  5. Press i to enter the editing mode and change the disk identifiers to the UUID format.
  6. Press Esc, enter :wq, and press Enter to save the settings and exit the vi editor.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback