Help Center> Elastic Cloud Server> Troubleshooting> Linux Issues> Troubleshooting Emergency Mode

Troubleshooting Emergency Mode

Symptom

When a Linux ECS enters the emergency mode during startup, the system displays the message "Welcome to emergency mode" and asks you to enter the password of user root for maintenance.

Figure 1 Emergency mode

Possible Causes

The emergency mode allows you to recover the system even if the system fails to enter the rescue mode. In emergency mode, the system installs only the root file system for data reading. It does not attempt to install any other local file systems or activate network interfaces.

The emergency mode is generally due to:

  • An error occurred in the /etc/fstab file, leading to the failure in mounting the file system.
  • An error occurred in the file system.

Constraints

The operations in this section are applicable to the Linux emergency mode. The operations involve recovering the file system, which may lead to loss of data. Therefore, back up data before recovering the file system.

Solution

  1. Enter the password of user root and press Enter to enter the recovery mode.
  2. In emergency mode, the root partition is mounted in read-only mode. To modify the files in the root directory, run the following command to mount the root partition in read-write mode:

    # mount -o rw,remount /

  3. Run the following command to try to mount all unmounted file systems and check whether the fstab file is correct:

    # mount -a

    • If the message "mount point does not exist" is displayed, the mount point is unavailable. In such a case, create the mount point.
    • If the message "no such device" is displayed, the file system device is unavailable. In such a case, comment out or delete the mount line.
    • If the message "an incorrect mount option was specified" is displayed, the mount parameter has been incorrectly set. In such a case, correct the parameter setting.
    • If no error occurs and the message "UNEXPECTED INCONSISTENCY;RUN fsck MANUALLY" is displayed, the file system is faulty. In such a case, go to step 7.
  4. Run the following command to open the /etc/fstab file and correct the error:

    # vi /etc/fstab

    The /etc/fstab file contains the following parameters separated by space:

    [file system] [dir] [type] [options] [dump] [fsck]

    Table 1 /etc/fstab parameters

    Parameter

    Description

    [file system]

    Specifies the partition or storage device to be mounted.

    You are advised to set file system in UUID format. To obtain the UUID of a device file system, run the blkid command.

    Format for reference:

    # <device> <dir> <type> <options> <dump> <fsck>

    UUID=b411dc99-f0a0-4c87-9e05-184977be8539 /home ext4 defaults 0 2

    UUIDs are independent of disk order. If the sequence of storage devices is changed manually or undergoes some random changes by some BIOSs, or the storage devices are removed and installed again, using UUIDs is more effective.

    [dir]

    Specifies the mount point of a file system.

    [type]

    Specifies the type of the file system to which a device or partition is mounted. The following file systems are supported: ext2, ext3, ext4, reiserfs, xfs, jfs, smbfs, iso9660, vfat, ntfs, swap, and auto.

    If type is set to auto, the mount command will speculate on the type of the file system that is used, which is useful for mobile devices, such as CD-ROM and DVD.

    [options]

    Specifies the parameters used for mounting. Some parameters are available only for specific file systems. For example, defaults uses default mounting parameters of a file system. The default parameters of the ext4 file system are rw, suid, dev, exec, auto, nouser, and async.

    For more parameters, run the # man mount command to view the man manual.

    [dump]

    Specifies whether file system data is backed up.

    The parameter value can be 0 or 1. 0 indicates that data is not backed up, and 1 indicates that data is backed up. If you have not installed dump, set the parameter value to 0.

    [fsck]

    Specifies the sequence of checking file systems.

    The parameter value can be 0, 1, or 2. 0 indicates that the devices will not be checked by fsck. 1 indicates the highest priority of the root directory to be checked by fsck, and 2 indicates the lower priority of other devices to be checked.

  5. After the modification, run the following command to check the fstab file:

    # mount –a

  6. Run the following command to restart the ECS:

    # reboot

  7. If no error occurred, the fault may be caused by the file system. Then, run the following command:

    # dmesg |egrep "ext[2..4]|xfs" |grep –i error

    • If the error message "I/O error... inode" is displayed, the fault is caused by a file system error.
    • If no file error is found in the log system, the fault is generally caused by the damaged superblock. The superblock is the header of the file system. It records the status, size, and idle disk blocks of the file system.
    • If the superblock of a file system is damaged, for example, data is written to the superblock partition of the file system by mistake, the system may fail to identify the file system. As a result, the system enters the emergency mode during startup. The ext2fs file system backs up the superblock and stores the backup at the blockgroup boundary of the driver.
  8. Run the following command to unmount the directory where the file system error occurred:

    # Unmount Mount point

  9. Check and recover the damaged file system.

    Recovering the file system may lead to loss of data. Back up data before the recovery.

    • For the ext file system, run the following command to check whether the file system is faulty:

      # fsck -n /dev/vdb1

      If the message "The super block Cloud no be read or does not describe a correct ext2 filesystem" is displayed, go to step 10.

      To recover the file system, run the following command:

      # fsck /dev/vdb1

    • For the xfs file system, run the following command to check whether the file system is faulty:

      # xfs_repair -n /dev/vdb1

      To recover the file system, run the following command:

      # xfs_repair /dev/vdb1

  10. (Optional) If the message "The super block Cloud no be read or does not describe a correct ext2 filesystem" is displayed, the superblock is damaged. In such a case, use the superblock backup for recovery.
    Figure 2 Damaged superblock

    Run the following command to replace the damaged superblock using the superblock backup:

    # e2fsck -b 8193 Device name

    As shown in Figure 3, the superblock has been replaced.

    Figure 3 Replacing the damaged superblock
    • -b 8193 indicates that the backup of superblock 8193 in the file system is used. The backup is used when the active superblock is damaged. The location of the superblock backup varies depending on the block size of the file system.

      For a file system with a 1 KB block size, locate the backup at superblock 8,193.

      For a file system with a 2 KB block size, locate the backup at superblock 16,384; for a 4 KB block size, locate the backup at superblock 32,768.

    • Device name is the disk name but not the partition name.
  11. Run the following command to restart the ECS:

    # reboot