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.
Log on to the ECS instance.
Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.
On the instance details page, click Connect > Workbench. Follow the prompts to log on.
Back up the
/etc/fstabfile to prevent errors from incorrect configuration.sudo cp /etc/fstab /etc/fstab.bakConfigure mount information.
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 -fNAME 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 /testIf the device has a partition, the target device name is the partition name. In this example, for data disk
vdb, the target device name isvdb1, the mount point is/mnt, and the file system type isext4.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 isvdc, the mount point is/test, and the file system type isxfs.
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.ImportantWith 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 isext4:sudo sh -c "echo `sudo blkid /dev/vdb1 | awk '{print \$2}' | sed 's/\"//g'` /mnt ext4 defaults 0 0 >> /etc/fstab"
Verify the mount configuration.
Unmount the device.
Replace
<target_device_name>with the value from Step 2.a.sudo umount /dev/<target_device_name>Mount all entries in
/etc/fstab.Mount all unmounted file systems listed in
/etc/fstab:sudo mount -aIf an error occurs, restore the original
/etc/fstabfile by runningsudo mv /etc/fstab.bak /etc/fstab.Check the mount result.
Run
sudo lsblk. If the output shows a mount point (MOUNTPOINT) for the target device, the configuration is correct.
Run
sudo rebootto restart the operating system and verify that it starts normally.ImportantRebooting 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.