Changing Disk Identifiers in the fstab File to UUID
Scenarios
To ensure that Linux can correctly identify disks when mounting the file system, you need to change the disk identifier in the fstab file of the ECS to UUID before creating a Linux private image.
Procedure
Run blkid to obtain the UUIDs of all partitions. Modify the /etc/fstab file and use the UUIDs of the partitions to configure automatic partition mounting.
- Log in to an ECS as user root.
- List all types of mounted file systems and their device UUIDs.
blkid
The command output is as follows:/dev/vda2: UUID="4eb40294-4c6f-4384-bbb6-b8795bbb1130" TYPE="xfs" /dev/vda1: UUID="2de37c6b-2648-43b4-a4f5-40162154e135" TYPE="swap"
The displayed information may vary depending on the distribution. You only need to pay attention to the UUID.
- Query the fstab file.
cat /etc/fstab
The command output is as follows:[root@CTU1000028010 ~]# cat /etc/fstab /dev/vda2 / xfs defaults 0 0 /dev/vda1 swap swap defaults 0 0
- Check whether the disk identifier in the fstab file is the device name.
- If the disk is represented by a UUID, no further operation is required.
- If the disk is represented by a device name, go to the next step.
- Open the fstab file.
vi /etc/fstab
- Press i to enter insert mode and change the disk identifier in the fstab file to UUID. Before the change:
[root@CTU1000028010 ~]# cat /etc/fstab /dev/vda2 / xfs defaults 0 0 /dev/vda1 swap swap defaults 0 0
After the change:
[root@CTU1000028010 ~]# cat /etc/fstab UUID=4eb40294-4c6f-4384-bbb6-b8795bbb1130 / xfs defaults 0 0 UUID=2de37c6b-2648-43b4-a4f5-40162154e135 swap swap defaults 0 0
- Press Esc, enter :wq, and press Enter. The system saves the configuration and exits the vi editor.
- Verify the change.
cat /etc/fstab
The change is successful if information similar to the following is displayed:
[root@CTU1000028010 ~]# cat /etc/fstab UUID=4eb40294-4c6f-4384-bbb6-b8795bbb1130 / xfs defaults 0 0 UUID=2de37c6b-2648-43b4-a4f5-40162154e135 swap swap defaults 0 0
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot