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
- 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"
- 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. - 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.- 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.
- 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.
- Fix mismatched configuration items.
- Run the following command to enter the edit mode:
vi /etc/fstab
- 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.
- Run the following command to enter the edit mode:
- After the repair is complete, make sure that the content of the
/etc/fstab
file is consistent with the result of theblkid
command.
- Confirm the mismatched content.
References
The following content is an example of fstab file configuration:
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 |
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 |
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.
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.
Typically, this parameter is set to 0. |
References
- Linux instance's "/etc/fstab" configuration file is malformed
- What do I do if system startup exceptions occur due to the configuration errors of the /etc/fstab file on Linux instances?
Ideal For
- ECS