All Products
Search
Document Center

Elastic Compute Service:System startup exceptions caused by incorrect configuration of the /etc/fstab file of a Linux instance

Last Updated:May 21, 2024

Note

Disclaimer: This topic may contain information about third-party products. The information is for reference only. Alibaba Cloud does not make a guarantee, explicitly or implicitly, with respect to the performance and reliability of the third-party products, and potential impacts of operations on the products.

Issue

You cannot log on to a Linux instance by using the remote connection software. When you connect to a Linux instance by using the Management Terminal, the system enters emergency mode and an error occurs.

  • The following error is reported on the CentOS instance.

  • The following error is reported on the Ubuntu instance.

    An error occurred while mounting /alidata.
    Press S to skip mounting or M for manual recovery
    

    The following figure shows the specific information. Ubuntu进入维护模式

Cause

This is usually because the wrong file system is written to the /etc/fstab file or the partition information of the disk is incorrect. /etc/fstab files are used to store the disk mount information of a server. If incorrect mount information is written to the configuration file or the file itself has access errors, such as permission configurations and file loss, an exception may occur during system startup, resulting in startup failure.

Solution

Note

Take note of the following items:

  • Before you perform high-risk operations such as modifying the specifications or data of an Alibaba Cloud instance, 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.

This section focuses on the workaround for CentOS and Ubuntu systems that fail to start due to /etc/fstab configuration file errors.

Note

Description: This topic applies to operating systems such as CentOS6.5, CentOS7.0, Ubuntu12.04, and Ubuntu14.04. The configurations of other operating system versions may vary. For more information, see the official documentation of the corresponding operating system.

CentOS instance

This topic describes two methods to solve this problem. We recommend that you use Ubuntu instance.

Method 1

  1. Connect to an ECS instance by using Use the management terminal to connect to a Linux instance. When the system prompts you to enter first aid mode, enter the instance logon password.

  2. Run the following command to change the mount mode of the root partition to read /write:

    mount / -o remount,rw

  3. Run the blkid command to view the partitions and file systems of the disks on the ECS instance. As shown in the following figure, the data disk partition of the ECS instance is /dev/xvdb1, and the file system type is ext4.

  4. Run the following command to check whether the partition information of the disk is consistent with the file system and the result returned in the previous step:

    vim /etc/fstab

  5. If they are inconsistent, follow these steps to modify them.

    1. Move the cursor to the abnormal parameter line, press the i key to enter the edit mode, and write the correct partition information, as shown below.

      /dev/xvdb1 /mydata ext4 defaults,nofail 0 0
      Note

      Note: We recommend that you add the nofail parameter when you mount the instance. If the device does not exist when you start the instance, it will be ignored to avoid errors.

    2. Press the Esc key to exit the edit mode and enter the :wq!, Press the Enter key to save and exit.

  6. Run the reboot command to restart the system and confirm that you can log on to the system.

Method 2

  1. Restart the instance in the ECS console (or forcibly restart the example), and then use VNC to connect to the instance. When the system starts to the kernel options interface, press the e key to enter and modify the grub boot file.

  2. Move the cursor to the Linux kernel parameter line, delete the remaining kernel parameter, add rw init=/bin/bash parameters, as shown in the following figure, and then press the Ctrl and x keys to enter the single-user mode.

  3. See Steps 3 to 6 of Ubuntu instance. After you modify the /etc/fstab configuration, restart the instance.

Ubuntu instance

  1. Connect to an ECS instance by using Use the management terminal to connect to a Linux instance.

  2. Press the S key to skip disk mounting and go to the system.

  3. Run the following command to change the mount mode of the root partition to read /write:

    mount / -o remount,rw

  4. Run the blkid command to view the partitions and file systems of the disks on the ECS instance. As shown in the following figure, the data disk partition of the ECS instance is /dev/xvdb1, and the file system is ext4.

  5. Run the following command to check whether the partition information of the disk is consistent with the file system and the result returned in the previous step.

    vim /etc/fstab

  6. If they are inconsistent, follow these steps.

    1. Move the cursor to the abnormal parameter line, press the i key to enter the edit mode, and write the correct partition information, as shown below.

      /dev/xvdb1 /mydata ext4 defaults,nofail 0 0
      Note

      Note: We recommend that you add the nofail parameter when you mount the instance. If the device does not exist when you start the instance, it will be ignored to avoid errors.

    2. Press the Esc key to exit the edit mode and enter the :wq!, Press the Enter key to save and exit.

  7. Run the reboot command to restart the system and confirm that you can log on to the system.

References

For more information about how to attach a disk to a Linux instance, see Format a data disk in Linux.

Applicable scope

  • Elastic Compute Service