Esta página ainda não está disponível no idioma selecionado. Estamos trabalhando para adicionar mais opções de idiomas. Agradecemos sua compreensão.

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
On this page

Changing Disk Identifiers in the GRUB File to UUID

Updated on 2024-12-12 GMT+08:00

Scenarios

When optimizing a Linux private image, you need to change disk identifiers to UUID in the GRUB file of the ECS.

Modify the menu.lst or grub.cfg file (/boot/grub/menu.lst, /boot/grub/grub.cfg, /boot/grub2/grub.cfg, /boot/grub/grub.conf, or /boot/efi/EFI/euleros/grub.cfg), and configure the boot partition using a UUID.
NOTE:

The root partition identified in the configuration file varies depending on the OS. It may be root=/dev/xvda or root=/dev/disk.

Procedure

  • Ubuntu 14.04: 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 change is required. The procedure is as follows:
    1. Log in to the ECS as user root.
    2. Run the following command to query all types of mounted file systems and 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 root partition in 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 UUID format and requires no change.
      • If root=/dev/xvda1 is contained, the root partition is in the device name format. Go to 5.
    1. Identify the UUID of the root partition device based on root=/dev/xvda1 (device name of the root partition) and the partition 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 editing mode and change the root partition to the UUID format, for example, from root=/dev/xvda1 to root=UUID=ec51d860-34bf-4374-ad46-a0c3e337fd34.
    4. Press Esc, enter :wq, and press Enter. The system saves the configuration and exits 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
      }
  • CentOS 6.5: Run blkid to obtain the UUID of the root partition. Modify the /boot/grub/grub.conf file and use the UUID of the root partition to configure the boot item. If the root partition already uses UUID, no change is required. The procedure is as follows:
    1. Log in to the ECS as user root.
    2. Run the following command to query all types of mounted file systems and device UUIDs:

      blkid

      The following information is displayed:

      /dev/xvda1: UUID="749d6c0c-990a-4661-bed1-46769388365a" TYPE="swap"  
      /dev/xvda2: UUID="f382872b-eda6-43df-9516-5a687fecdce6" TYPE="ext4"
    1. Run the following command to query the grub.conf file:

      cat /boot/grub/grub.conf

      The following information is displayed:

      default=0 
      timeout=5 
      splashimage=(hd0,1)/boot/grub/splash.xpm.gz 
      hiddenmenu 
      title CentOS (2.6.32-573.8.1.el6.x86_64) 
      root (hd0,1) 
      kernel /boot/vmlinuz-2.6.32-573.8.1.el6.x86_64 ro root=/dev/xvda2 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=autoKEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet 
      initrd /boot/initramfs-2.6.32-573.8.1.el6.x86_64.img
    1. Check whether the root partition in the /boot/grub/grub.conf configuration file contains root=/dev/xvda2 or root=UUID=f382872b-eda6-43df-9516-5a687fecdce6.
      • If root=UUID=f382872b-eda6-43df-9516-5a687fecdce6 is contained, the root partition is in UUID format and requires no change.
      • If root=/dev/xvda2 is contained, the root partition is in the device name format. Go to 5.
    1. Identify the UUID of the root partition device based on root=/dev/xvda2 (device name of the root partition) and the partition information obtained by running the blkid command.
    2. Run the following command to open the grub.conf file:

      vi /boot/grub/grub.conf

    3. Press i to enter editing mode and change the root partition to the UUID format, for example, from root=/dev/xvda2 to root=UUID=f382872b-eda6-43df-9516-5a687fecdce6.
    4. Press Esc, enter :wq, and press Enter. The system saves the configuration and exits the vi editor.
    5. Run the following command to verify the change:

      cat /boot/grub/grub.conf

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

      default=0 
      timeout=5 
      splashimage=(hd0,1)/boot/grub/splash.xpm.gz 
      hiddenmenu 
      title CentOS (2.6.32-573.8.1.el6.x86_64) 
      root (hd0,1) 
      kernel /boot/vmlinuz-2.6.32-573.8.1.el6.x86_64 ro root=UUID=f382872b-eda6-43df-9516-5a687fecdce6 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=autoKEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet 
      initrd /boot/initramfs-2.6.32-573.8.1.el6.x86_64.img
  • CentOS 7.0: Run blkid to obtain the UUID of the root partition. Modify the /boot/grub2/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.
    1. Log in to the ECS as user root.
    2. Run the following command to query all types of mounted file systems and 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" 
    1. Run the following command to query the grub.cfg file:

      cat /boot/grub2/grub.cfg

      The following information is displayed:

      ......
      menuentry 'CentOS Linux (3.10.0-229.el7.x86_64) 7 (Core)' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-4eb40294-4c6f-4384-bbb6-b8795bbb1130' { 
      load_video 
      set gfxpayload=keep 
      insmod gzio 
      insmod part_msdos 
      insmod xfs 
      set root='hd0,msdos2' 
      if [ x$feature_platform_search_hint = xy ]; then 
      search --no-floppy --fs-uuid --set=root --hint='hd0,msdos2'4eb40294-4c6f-4384-bbb6-b8795bbb1130 
      else 
      search --no-floppy --fs-uuid --set=root 4eb40294-4c6f-4384-bbb6-b8795bbb1130 
      fi 
      linux16 /boot/vmlinuz-3.10.0-229.el7.x86_64 root=/dev/xvda2 ro crashkernel=auto rhgb quiet LANG=en_US.UTF-8 
      initrd16 /boot/initramfs-3.10.0-229.el7.x86_64.img 
      }
    1. Check whether the root partition in the /boot/grub2/grub.cfg configuration file contains root=/dev/xvda2 or root=UUID=4eb40294-4c6f-4384-bbb6-b8795bbb1130.
      • If root=UUID=4eb40294-4c6f-4384-bbb6-b8795bbb1130 is contained, the root partition is in UUID format and requires no change.
      • If root=/dev/xvda2 is contained, the root partition is in the device name format. Go to 5.
    1. Identify the UUID of the root partition device based on root=/dev/xvda2 (device name of the root partition) and the partition information obtained by running the blkid command.
    2. Run the following command to open the grub.cfg file:

      vi /boot/grub2/grub.cfg

    3. Press i to enter editing mode and change the root partition to the UUID format, for example, from root=/dev/xvda2 to root=UUID=4eb40294-4c6f-4384-bbb6-b8795bbb1130.
    4. Press Esc, enter :wq, and press Enter. The system saves the configuration and exits the vi editor.
    5. Run the following command to verify the change:

      cat /boot/grub2/grub.cfg

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

      ......
      menuentry 'CentOS Linux (3.10.0-229.el7.x86_64) 7 (Core)' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-4eb40294-4c6f-4384-bbb6-b8795bbb1130' { 
      load_video 
      set gfxpayload=keep 
      insmod gzio 
      insmod part_msdos 
      insmod xfs 
      set root='hd0,msdos2' 
      if [ x$feature_platform_search_hint = xy ]; then 
      search --no-floppy --fs-uuid --set=root --hint='hd0,msdos2'4eb40294-4c6f-4384-bbb6-b8795bbb1130 
      else 
      search --no-floppy --fs-uuid --set=root 4eb40294-4c6f-4384-bbb6-b8795bbb1130 
      fi 
      linux16 /boot/vmlinuz-3.10.0-229.el7.x86_64 root=UUID=4eb40294-4c6f-4384-bbb6-b8795bbb1130 ro crashkernel=auto rhgb quiet LANG=en_US.UTF-8 
      initrd16 /boot/initramfs-3.10.0-229.el7.x86_64.img 
      }

Usamos cookies para aprimorar nosso site e sua experiência. Ao continuar a navegar em nosso site, você aceita nossa política de cookies. Saiba mais

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback