• Bare Metal Server

bms
  1. Help Center
  2. Bare Metal Server
  3. Private Image Creation Guide (BMS)
  4. Creating a Linux Image
  5. Modifying the Hardware Device Driver That Boots the OS

Modifying the Hardware Device Driver That Boots the OS

Scenarios

This section describes how to modify the hardware device driver that is 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 2.2, EulerOS 2.3, SUSE 12 SP1, SUSE 12 SP2, SUSE 12 SP3, CentOS, and XenServer, use the vi editor to open the /etc/dracut.conf file and change or add the value of add_drivers.

      As shown in the following, the value of add_drivers is the driver of the server's RAID controller card.

      logfile=/var/log/dracut.log
      # fileloglvl=7
      ...
      ...
      # additional kernel modules to the default
      add_drivers+="ahci megaraid_sas mpt3sas mpt2sas"
    • For Ubuntu 14.04 or Debian 8.6, use the vi editor to open the /etc/initramfs-tools/modules file and add ahcimegaraid_sasmpt3sas, 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
    • For Ubuntu 16.04, add the drivers to both 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" to the end of the /etc/dracut.conf file by performing operations similar to those for Red Hat and Oracle Linux 7.3.

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

        apt-get install initramfs-tools

        After the installation is complete, add the ahcimegaraid_sasmpt3sas, and mpt2sas 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 for ARM, run the following commands to update the kernel and driver, 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 change the value of INITRD_MODULES.

      As shown in the following, the value of INITRD_MODULES= is the driver of the server's RAID controller card.

      ...
      #
      INITRD_MODULES="ahci megaraid_sas mpt3sas mpt2sas"
      ## Type:   string(yes)
      ...
    NOTE:

    You can enter multiple RAID controller card drivers separated by spaces. The RAID controller card driver name can be obtained from the purchased hardware device. Images support coexistence of multiple RAID controller card drivers, for example, mpt2sas, megaraid_sas, and mpt3sas. If the OS does not support a hardware driver, it must be installed.

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

    For Rad Hat, Oracle Linux, EulerOS 2.2, EulerOS 2.3, SUSE 12 SP1, SUSE 12 SP2, SUSE 12 SP3, Ubuntu 16.04, CentOS, and XenServer, run the dracut -f command.

    • For Rad Hat, Oracle Linux, EulerOS 2.2, EulerOS 2.3, CentOS, and XenServer, 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 and then observe the last few lines of the command output.

      In the command output, the following information is displayed:

      ...
      Some kernel modules could not be included
      This is not necessarily an error:
      pcmcia
      sdhci_acpi
      swap

      The drivers that are not loaded do not include the manually-added one, indicating that the RAID card driver has been loaded.

    • For SUSE 12 SP2 and SUSE 12 SP3, 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, or Debian 8.6, 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 installed:

      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 and check whether the values of Kernel Modules include the manually added driver.

  3. For SUSE 11 SP4, change the virtual disks in the VM file to physical disks. For Red Hat 7.3, Oracle Linux 7.3, SUSE 12 SP1, and EulerOS 2.2, skip this step. For SUSE 11 SP4, perform the following steps:
    NOTE:

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

    1. In the /boot/grub directory, run the blkid command to check whether the 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 steps to install the VM OS are correct and reinstall the VM OS.

    2. Use the vi editor to open the /boot/grub/menu.lst file, modify the OS boot parameters, and save the configuration. The following figures show the original and modified /boot/grub/memu.lst files.

      Original menu.lst file:

      Modified menu.lst file:

    3. Use the vi editor to open the /boot/grub/device.map file. The following information shows the original and modified /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. The following figures show the original and modified /etc/fstab file.

      Original fstab file:

      Modified fstab file:

    5. Use the vi editor to open the /etc/mtab file, delete the row that contains the CDROM of /dev/sr0, and save the configuration. The following figure shows the modified /etc/mtab file.

      Modified /etc/mtab file:

      NOTE:

      If no /dev/sr0 configuration item exists, skip this step.

    6. Use the vi editor to open the /etc/sysconfig/bootloader file. The following figures show the original and modified /etc/sysconfig/bootloader file.

      Original bootloader file:

      Modified bootloader file:

    If SUSE 11 SP4 uses the LVM partitioning mechanism, perform the following operations to replace the virtual disks in the VM file with the actual physical disks:

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

      If some disk partitions do not have UUIDs, check whether the steps to install the VM OS are correct and reinstall the VM OS.

    2. Use the vi editor to open the /boot/grub/menu.lst file, modify the OS boot parameters, and save the configuration. The following figures show the original and modified /boot/grub/memu.lst files.

      Original menu.lst file:

      Modified menu.lst file:

    3. Use the vi editor to open the /boot/grub/device.map file. The following information shows the original and modified /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. The following figures show the original and modified /etc/fstab file.

      Original fstab file:

      Modified fstab file:

    5. Use the vi editor to open the /etc/sysconfig/bootloader file. The following figures show the original and modified /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 command to ensure that the value of resume is by-uuid.

  4. For Ubuntu 16.04 for ARM, modify the grubfstab, and interfaces files.
    1. Modify the parameters in the /etc/default/grub file shown in the following figure.

      Change the value of GRUB_DISABLE_LINUX_UUID to true. Then run the sudo update-grub2 command.

      ...
      # 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
      ...
    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. Modify the /etc/network/interfaces file and delete all interface information except the lo interface. The following figure shows the modified information.
      # 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
      
      ~
      ~