All Products
Search
Document Center

:How to Configure File Disk Identification Mode to UUID in fstab File

Last Updated:Jul 12, 2022

Overview

In the Linux, the file system mount information is usually configured in the fstab file. If the file system is configured incorrectly, the system startup is abnormal. This topic describes how to configure the file disk identification method to UUID in the fstab file to resolve this restart exception.

Error message

Take note of the following items:

  • Before you perform high-risk operations such as modifying the configurations or data of Alibaba Cloud instances, we recommend that you check the disaster recovery and fault tolerance capabilities of the instance to ensure data security.
  • Before you modify the specifications or data of an Alibaba Cloud instance, such as an Elastic Compute Service (ECS) instance or an ApsaraDB RDS instance, we recommend that you create snapshots or enable backups for the instance. For example, you can enable log backups for an ApsaraDB RDS instance.
  • If you have granted specific users the permissions on sensitive information, such as usernames and passwords, or submitted sensitive information in the Alibaba Cloud Management Console, we recommend that you modify the sensitive information at the earliest opportunity.

Background information

fstab supports the use of disk partition names (such as /dev/vdb1) or UUID to identify file systems. The differences between the two are as follows:

  • If disk partition names are used to identify file systems in the fstab file, the disk partitions may not be mounted to the original mount points if the attach sequence of the disks is changed. In this case, applications that run on your ECS instance may be affected.
  • If UUIDs are used to identify file systems in the fstab file, the disk partitions can still be mounted to the original mount points if the attach sequence of the disks is changed. Therefore, we recommend that you use UUIDs to identify file systems.

Procedure

  1. Connect to an ECS instance. For more information about how to connect to an ECS instance, see Use password or key authentication to log on to a Linux instance.
  2. Run the following command to view information about the block devices that exist in the current Linux instance:
    blkid
    If an output similar to the following one is returned, one of the solutions is applicable to your system kernel version:
    /dev/vda1: UUID="8fb1dc87-472b-4a8d-b289-****" BLOCK_SIZE="4096" TYPE="ext4" 
  3. Run the following command to view information about the configured block devices in the current /etc/fstab file:
    cat /etc/fstab
    If an output similar to the following one is displayed, Python is installed.
    image.png
  4. Check that the blkid command result matches the contents of the /etc/fstab file, and then fix the mismatched configuration items in the /etc/fstab file.
    1. Confirm the mismatched content.
      contains but is not limited to the following items to be confirmed:
      • Make sure that the information of the file systems which are automatically mounted is correctly configured and that the file systems exist on the instance.

        If the file systems do not exist on the instance and the nofail parameter is not set on the corresponding lines in the /etc/fstab file, the operating system cannot find the file systems to mount on instance startup and cannot start.

      • If UUIDs are used to specify the file systems to mount, make sure that the UUIDs in the /etc/fstab file are the same as those in the blkid command output.
      • Make sure that the configured mount points have been created and do not conflict.
      • Ensure that the parameters configuration items for each line in the /etc/fstab file meet the format requirements of the file system.
    2. Run the following command to back up /etc/fstab files:
      cp /etc/fstab /etc/fstab.bak
    3. Fix mismatched configuration items.
      1. Run the following command to enter the edit mode:
        vi /etc/fstab
      2. Replace the mismatched sample values with the correct values, press the Esc key, enter the :wq and press Enter to save and exit the file.
        Note: For more information, see More information.
    4. After the repair is complete, make sure that the content of the /etc/fstab file is consistent with the result of the blkid command.

References

The following content is an example of fstab file configuration:

fstab文件说明
 
No. Section Description
<file system> The file systems to be mounted to the partitions.

We recommend that you use the UUIDs of the file systems. You can run the blkid command to query the UUIDs of the file systems in the partitions.

2 <dir> The mount points of the file systems.

You can create mount points. In this topic, the /test01 and /test02 mount points are created.

3 <type> The types of file systems to be mounted to the partitions.

You can run the blkid command to query the types of the file systems.

4 <options> The parameters used for mounting. Typically, the defaults parameter is used. If you want to use multiple parameters, separate them with commas (,). Example: defaults,noatime.

For more information about the <options> parameters, see fstab.

5 <dump> Indicates whether the dump tool backs up the file systems.
  • 0: The dump tool does not back up the file systems.
  • 1: The dump tool backs up the file systems.

Typically, the dump tool is not used. In this case, this parameter is set to 0.

6 <pass> The priority in which fsck checks the file systems.
  • 0: The file systems are not checked.
  • 1: The file system corresponding to root directory (/) is checked.
  • 2: All file systems except the one corresponding to root directory (/) are checked.

Typically, this parameter is set to 0.

References

Ideal For

  • ECS