All Products
Search
Document Center

Elastic Compute Service:Auto-mount a data disk with UUID in /etc/fstab

Last Updated:Jun 02, 2026

Add a data disk's UUID to /etc/fstab so the disk mounts automatically at startup instead of requiring manual remount after each reboot.

Procedure

Ensure your data disk is In Use, initialized, and has a mounted file system.

  1. Log on to the ECS instance.

    1. Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.

    2. On the instance details page, click Connect > Workbench. Follow the prompts to log on.

  2. Back up the /etc/fstab file to prevent errors from incorrect configuration.

    sudo cp /etc/fstab /etc/fstab.bak
  3. Configure mount information.

    1. Get the target disk information.

      Run sudo lsblk -f. Record the target device name, mount point, and file system type for the disk.

      sudo lsblk -f
      NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
      vda                                                      
      └─vda1 ext4   root  33b46ac5-7482-4aa5-8de0-60ab4c3a4c78 /
      vdb    ext4         3d7a3861-da22-484e-bbf4-b09375894b4f                                                         
      └─vdb1 ext4         f1645951-134f-4677-b5f4-c65c71f8f86d /mnt
      vdc    xfs          3d7a3861-da22-484e-bbf4-b09375894b4f /test
      • If the device has a partition, the target device name is the partition name. In this example, for data disk vdb, the target device name is vdb1, the mount point is /mnt, and the file system type is ext4.

      • If the device has no partition, the target device name is the device name itself. In this example, for data disk vdc, the target device name is vdc, the mount point is /test, and the file system type is xfs.

    2. Add mount information to /etc/fstab.

      Replace <target_device_name>, <mount_point>, and <file_system_type> with values from the previous step, then run the command. See fstab man-pages for parameter descriptions.

      Important

      With options set to defaults,nofail, the instance starts normally even with an incorrect mount configuration, but no error is reported. Verify that the automatic mount succeeded to avoid writing data to the wrong device.

      sudo sh -c "echo `sudo blkid /dev/<target_device_name> | awk '{print \$2}' | sed 's/\"//g'` <mount_point> <file_system_type> defaults 0 0 >> /etc/fstab"
      For example, if the target device name is vdb1, the mount point is /mnt, and the file system type is ext4:
      sudo sh -c "echo `sudo blkid /dev/vdb1 | awk '{print \$2}' | sed 's/\"//g'` /mnt ext4 defaults 0 0 >> /etc/fstab"

  4. Verify the mount configuration.

    1. Unmount the device.

      Replace <target_device_name> with the value from Step 2.a.

      sudo umount /dev/<target_device_name>
    2. Mount all entries in /etc/fstab.

      Mount all unmounted file systems listed in /etc/fstab:

      sudo mount -a

      If an error occurs, restore the original /etc/fstab file by running sudo mv /etc/fstab.bak /etc/fstab.

    3. Check the mount result.

      Run sudo lsblk. If the output shows a mount point (MOUNTPOINT) for the target device, the configuration is correct.

  5. Run sudo reboot to restart the operating system and verify that it starts normally.

    Important

    Rebooting can impact live services. Proceed with caution.

    After the instance starts, run sudo lsblk. If the output shows a mount point (MOUNTPOINT) for the target device, the configuration is correct.

    If the instance fails to start, see Troubleshoot system startup failures on a Linux instance caused by an /etc/fstab configuration error.

FAQ

What should I do if my instance fails to start after a reboot due to an /etc/fstab configuration error?

See Troubleshoot system startup failures on a Linux instance caused by an /etc/fstab configuration error to connect via VNC and correct the mount information in emergency mode.

Why is using a UUID recommended over a partition name (such as /dev/vdb1) when configuring /etc/fstab?

  • Using a disk partition name: If the disk mount order changes, partition names may also change. This can cause fstab entries to point to the wrong partition or fail, preventing data access and causing service disruptions.

  • Using a UUID: A UUID uniquely identifies a disk regardless of mount order, ensuring the system always mounts the correct partition.