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
Situation Awareness
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
Help Center/ Bare Metal Server/ Private Image Creation Guide/ Linux/ Modifying the Hardware Device Drivers That Boot the OS

Modifying the Hardware Device Drivers That Boot the OS

Updated on 2023-07-24 GMT+08:00

Scenario

This section describes how to modify the hardware device drivers that are loaded during OS startup.

Prerequisites

You have logged in to the VM.

Procedure

  1. Add or modify the configuration file.
    • For Red Hat/Oracle Linux/EulerOS/OpenEuler/SUSE 12/SUSE 15/CentOS, use the vi editor to open the /etc/dracut.conf file and change or add the value of add_drivers. In the following example, the value of add_drivers is a list of RAID drivers.
      logfile=/var/log/dracut.log
      # fileloglvl=7
      ...
      ...
      # additional kernel modules to the default
      add_drivers+="ahci megaraid_sas mpt3sas mpt2sas virtio_blk virtio_scsi virtio_net"
      NOTE:

      If an error is reported, add a space before and after the driver list in the quotation marks and try again.

    • For Ubuntu 14.04 or Debian, use the vi editor to open the /etc/initramfs-tools/modules file and add ahci, megaraid_sas, mpt3sas, and mpt2sas drivers (the format depends on the OS).
      # List of modules that you want to include in your initramfs.
      # They will be loaded at boot time in the order below.
      #
      # Syntax:  module_name [args ...]
      #
      # You must run update-initramfs(8) to effect this change.
      #
      # Examples:
      #
      # raid1
      # sd_mod
      ahci
      megaraid_sas
      mpt3sas
      mpt2sas
      virtio_blk
      virtio_scsi
      virtio_net
    • For Ubuntu 16.04/Ubuntu 18.04, add drivers to the /etc/dracut.conf and /etc/initramfs-tools/modules files. Before editing the files, install required software.
      1. Run the following command to install dracut:

        apt-get install dracut

        After the installation is complete, add add_drivers+="ahci megaraid_sas mpt3sas mpt2sas virtio_blk virtio_scsi virtio_net" to the end of the /etc/dracut.conf file by performing operations similar to those for Red Hat and Oracle Linux 7.3.

        NOTE:

        If an error is reported, add a space before and after the driver list in the quotation marks and try again.

      2. Run the following command to install initramfs-tools:

        apt-get install initramfs-tools

        After the installation is complete, add the ahci, megaraid_sas, mpt3sas, mpt2sas, and virtio_blk virtio_scsi virtio_net drivers to the end of the /etc/initramfs-tools/modules file by performing operations similar to those for Ubuntu 14.04.

    • For Ubuntu 16.04 ARM, run the following commands to update the kernel and drivers, and then restart the VM:

      sudo apt-get update

      sudo apt-get dist-upgrade

    • For SUSE 11 SP4, use the vi editor to open the /etc/sysconfig/kernel file, and add or change the value of INITRD_MODULES. In the following example, the value of INITRD_MODULES is a list of RAID drivers.
      ...
      #
      INITRD_MODULES="ahci megaraid_sas mpt3sas mpt2sas virtio_blk virtio_scsi virtio_net"
      ## Type:   string(yes)
      ...
    NOTE:

    You can enter multiple RAID drivers and separate them with spaces. The RAID driver names can be obtained from the purchased hardware devices. Multiple types of drivers can be added at the same time, such as mpt3sas, mpt2sas, and megaraid_sas. If any hardware driver cannot be installed here, you can install it after the BMS is created.

  2. Update the kernel. For Ubuntu 16.04 ARM and Ubuntu 18.04 ARM, skip this step.

    For Rad Hat/Oracle Linux/EulerOS/SUSE 12/SUSE 15/Ubuntu 16.04/Ubuntu 18.04/CentOS run the dracut -f command.

    • For Rad Hat/Oracle Linux/EulerOS/OpenEuler/CentOS, run the dracut -f command. Wait for several seconds. If no command output is returned, the drivers have been loaded.
    • For SUSE 12 SP1, run the dracut -f command. Check the command output in the last few lines. If message "Some kernel modules could not be included. This is not necessarily an error:" is displayed and drivers not loaded are displayed (excluding the RAID drivers), the RAID drivers are loaded successfully.
      ...
      Some kernel modules could not be included
      This is not necessarily an error:
      pcmcia
      sdhci_acpi
      swap
    • For SUSE 12/SUSE 15, run the dracut -f command. The kernel is updated successfully if information similar to the following is displayed.

    • For Ubuntu 14.04/Ubuntu 16.04/Ubuntu 18.04/Debian, run the following command to generate initrd:

      update-initramfs -u

      Run the following commands to check whether the ahci, megaraid_sas, mpt3sas, and mpt2sas drivers have been loaded:

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

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

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

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

    • For SUSE 11 SP4, run the mkinitrd command to check whether the value of Kernel Modules contains the manually added drivers. If the following command output is displayed, the drivers are successfully loaded.

  3. For SUSE 11 SP4, change the virtual disks in the VM file to physical disks. For other OSs, such as Rad Hat, CentOS, Oracle Linux, SUSE 12, and EulerOS, skip this step.
    NOTE:

    If LVM is used, perform 3.a to 3.e to change the drive letter mode.

    1. In the /boot/grub directory of the VM, run the blkid command to check whether disk partitions are normal.
      linux-a5d6:/boot/grub # blkid
      /dev/sda1: UUID="c23d47f8-ef1b-4c4e-9a3b-5ae138ef7184" TYPE="swap"
      /dev/sda2: UUID="27644978-e244-4a8c-996a-03119fdaff71" TYPE="ext3"

      If some disk partitions do not have UUIDs, check whether the VM OS is properly installed. If it is not, install it again.

    2. Use the vi editor to open the /boot/grub/menu.lst file, modify the OS boot parameters, and save the configuration.

      Original menu.lst file

      Modified menu.lst file

    3. Use the vi editor to open the /boot/grub/device.map file.

      Original device.map file

      (hd0)   /dev/disk/by-id/ata-QEMU_HARDDISK_QM00001
      ~

      Modified device.map file

      (hd0)   /dev/sda
    4. Use the vi editor to open the /etc/fstab file.

      Original fstab file

      Modified fstab file

    5. Use the vi editor to open the /etc/mtab file, delete the line where CDROM of /dev/sr0 is located, and save the configuration.

      Modified mtab file

      NOTE:

      If the /dev/sr0 configuration item does not exist, skip this step.

    6. Use the vi editor to open the /etc/sysconfig/bootloader file.

      Original bootloader file

      Modified bootloader file

    If SUSE 11 SP4 uses LVM, replace the virtual disks in the VM file with the actual physical disks.

    1. In the /boot/grub directory of the VM, run the blkid command to check whether disk partitions are normal.

      If some disk partitions do not have UUIDs, check whether the VM OS is properly installed. If it is not, install it again.

    2. Use the vi editor to open the /boot/grub/menu.lst file, modify the OS boot parameters, and save the configuration.

      Original menu.lst file

      Modified menu.lst file

    3. Use the vi editor to open the /boot/grub/device.map file.

      Original device.map file

      (hd0)    /dev/disk/by-id/ata-QEMU_HARDDISK_QM00001

      Modified device.map file

      (hd0)    /dev/sda
      ~
    4. Use the vi editor to open the /etc/fstab file.

      Original fstab file

      Modified fstab file

    5. Use the vi editor to open the /etc/sysconfig/bootloader file.

      Original bootloader file

      Modified bootloader file

    After the configuration is complete, run the mkinitrd command. If the value of resume is not by-uuid, run the reboot and then mkinitrd commands to ensure that the value of resume is by-uuid.

  4. For Ubuntu 18.04 and Ubuntu 16.04 ARM, modify the grub, fstab, and interfaces files.
    1. Modify parameters in the /etc/default/grub configuration file.

      Set GRUB_DISABLE_LINUX_UUID to true.

      ...
      # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to linux
      GRUB_DISABLE_LINUX_UUID=true
      
      # Uncomment to disable generation of recovery mode menu entries
      ...

      Then, run the sudo update-grub2 command.

    2. Change the UUID in the /etc/fstab file to that of /dev/sdax, which can be obtained by running the sudo blkid command.

    3. Delete all interface information except lo interface from the /etc/network/interfaces file.
      # This file describes the network interfaces available on your system
      # and how to activate them. For more information, see interfaces (5).
      
      source /etc/network/interfaces.d/*
      
      # The loopback network interface
      auto lo
      iface to inet loopback
      
      ~
      ~

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