- Documentation
Elastic Compute Service
Elastic Compute Service
Best Practices
Volume
Setting up automatic mounting of volume partitions upon boot
Volume
Setting up automatic mounting of volume partitions upon boot
Setting up automatic mounting of volume partitions upon boot
In Linux, you can configure the fstab file to automatically mount a volume partition when the ECS instance restarts.
This topic explains how to use UUIDs in the fstab file to set up automatic mounting. We do not recommend specifying device names (e.g., /dev/vdb1) directly in the /etc/fstab file because the order of the names may change when the instance is stopped and restarted. For example, /dev/vdb1 could become /dev/vdb2, which would prevent the instance from starting up normally.
Prerequisites
Background information
A universally unique identifier (UUID) is a unique string that Linux assigns to a volume partition.
Steps
- Run the blkid volume partition command to query the UUID of the partition.
- The following command queries the UUID of the partition, /dev/vdc1:
- You will see output similar to the following:
- This shows the UUID of /dev/vdc1.
- Open the fstab file using the vi editor.
- Press i to enter insert mode. Then, add a new entry similar to the following:
-
- This content is for example purposes only. Use actual values from your environment. The parameters are explained below:
- 1: The UUID of the partition obtained in Step 2.
- 2: The mount directory of the partition. You can find this using the df -TH command.
- 3: The file system format of the partition. You can also find this using the df -TH command.
- 4: Mount options. The defaults are usually fine.
- 5: Linux dump backup option.
- 0 means do not use the dump backup option, which is commonly used now.
- 1 means use the dump backup.
- 6: fsck options, which determine whether fsck checks the volume at boot.
- Enter 1 if the mount point for the partition is the root directory (/).
- For other partitions, the value can start at 2 because the system checks partitions in ascending order.
- Press "Esc", type :wq, and press "Enter" to save and exit the editor.
- Run the umount command to unmount the partition.
- The following command unmounts the partition, /dev/vdc1:
- Run the mount -a command to reload all entries in the /etc/fstab file.
- Run the mount | grep mount directory command to view information about the mounted file system.
- The following command returns information about /dev/vdc1:
- If the output is similar to the following, automatic mounting is working:
Related operations
To disable the automatic mounting of a volume partition upon boot, comment out the relevant command in the /etc/fstab file.
- Run this command to edit the /etc/fstab file.
- Comment out the automatic mounting command by adding a # at the beginning of the line. Then, save and exit /etc/fstab.
Last updated: 2026.06.11 16:26:02