All Products
Search
Document Center

:How do I fix a format error of the /etc/fstab configuration file of a Linux instance?

Last Updated:Jul 26, 2021

Disclaimer: This topic may be contributed by a community or contain information about third-party products. We recommend that you visit the official website of the community or the third-party products for help and support. The third-party products are not supported by Alibaba Cloud after-sales service. This topic is for reference only. Alibaba Cloud does not make guarantees or warranties, express or implied.

Problem description

If the /etc/fstab configuration file of a Linux instance is incorrectly formatted, the instance may fail to restart.

Cause

The /etc/fstab configuration file is incorrectly formatted. The /etc/fstab configuration file is used to store disk attach information of an instance. If incorrect attach information is written to the configuration file or the file has access errors such as permission configuration errors and data loss, an exception may occur during instance startup, which causes a startup failure.

Solution

Take note of the following items:

  • Before you perform high-risk operations such as modifying instance configurations or data, we recommend that you check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
  • You can modify the configurations and data of instances including Elastic Compute Service (ECS) and ApsaraDB RDS instances. We recommend that you create snapshots or enable RDS log backup before you modify instance configurations or data.
  • If you have authorized or submitted sensitive information such as the logon account and password in the Alibaba Cloud Management Console, we recommend that you modify the information in a timely manner.
  1. Create a snapshot for the system disk of the Linux instance to avoid data security risks caused by accidental operations. For more information about how to create a snapshot, see Create a snapshot for a disk.
  2. Log on to the Linux instance by using SSH or Virtual Network Computing (VNC). For more information, see Connection overview.
    Note: If your instance fails to start due to the format error of the /etc/fstab configuration file, you can go to How do I handle the startup exception of a Linux instance due to the format error of the /etc/fstab configuration file to fix the error.
  3. Check whether the current /etc/fstab configuration file is correctly formatted based on the following correct format:
    /[$Partion of the data disk] /[$Mount directory] [$Type of the file system] defaults 0 0
    Note:
    • In this topic, the correct configuration file format /dev/vdb1 /mnt ext4 defaults 0 0 is used. In actual scenarios, replace the variables with your actual configurations.
    • [$Partition of the data disk] indicates the disk partition to be mounted. Example: /dev/vdb1.
    • [$Mount directory] indicates the directory to which the partition is mounted. Example: /mnt.
    • [$Type of the file system] indicates the type of the file system of the partition. Example: ext4.
  4. Run the following command to check whether the /etc/fstab configuration file is formatted as the previous command.
    cat /etc/fstab
  5. If a format error exists, edit the /etc/fstab configuration file. Run the following command to edit the /etc/fstab configuration file:
    Note: Back up data in the instance before you modify the configuration file.
    vim /etc/fstab
  6. Press the A key to find the wrong command line. Modify it based on the configuration format in Step 3. Press the Esc key to exit the edit mode. Enter :wq, and then press the Enter key to save the configuration file and exit.
    Note: The colon (:) in :wq is entered by pressing the Shift key and the colon (:).

References

Applicable scope

  • ECS