How Do I Change the UUID of a Disk?
Scenarios
If a disk is created from an image, the UUID of the new disk will be the same as that of the original disk. If you attach the new disk to the original Linux server, there will be a UUID conflict between the new and original disks on the server. To address this issue, you need to log in to the server to change the UUID of the new disk and then mount it again. You can run blkid to check the file system type. Then, choose one of the two methods listed below based on which type of filesystem you see.
- For TYPE="ext4", TYPE="ext3", or TYPE="ext2", see Changing a Disk UUID for an Ext2, Ext3, or Ext4 File System.
- For TYPE="xfs", see Changing a Disk UUID for an XFS Filesystem.
Changing a Disk UUID for an Ext2, Ext3, or Ext4 File System
/dev/vdc1 is just an example. You will need to modify the command based on the actual device name.
- Remotely log in to the ECS. For details, see Logging In to a Linux ECS Using VNC.
- Check the disk UUID.
blkid
In the command output shown here, you can see there are two disks with the same UUID.

- Generate a new UUID for the new disk.
uuidgen | xargs tune2fs /dev/vdc1 -U
- Check whether the new UUID has been applied.
blkid
You can see in the output below, the UUID of /dev/vdc1 has been changed.

- Mount the new disk again.
mount /dev/vdc1 /mnt
- Configure the /etc/fstab file to automatically mount the new disk at boot.
For details, see Configuring Automatic Mounting at System Start.
Changing a Disk UUID for an XFS Filesystem
/dev/vde1 is just an example. You will have to modify the command based on the actual device name.
- Remotely log in to the ECS. For details, see Logging In to a Linux ECS Using VNC.
- Check the disk UUID.
blkid
In the command output shown here, you can see there are two disks with the same UUID.

- Generate a new UUID for the new disk.
xfs_admin -U generate /dev/vde1
- Check whether the new UUID has been applied.
blkid
You can see in the output below, the UUID of /dev/vde1 has been changed.

- Mount the new disk again.
mount /dev/vde1 /mnt
- Configure the /etc/fstab file to automatically mount the new disk at boot.
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