The UUID of a Linux partition is the Universally Unique IDentifier of that partition. I would say with a fair bit of confidence that in this and most scenarios, the Linux partition UUID has more of a local machine scope. This ID is used in a few places to identify the partition. The most notable being your /etc/fstab file, which manages the mounting of partitions at boot time.
UUID should be unique and it is used to identify storage devices on a Linux system.
In this article I will show how to change UUID of Linux partition.
Change UUID of Linux Partition
Follow the below steps to change the UUID of Linux Partition.
1. Run the below command to find out UUID of the devices.
# blkid /dev/mapper/centos_centos71-root: UUID="2bc8e0d4-64b5-4dc8-bf4a-024fc980d98a" TYPE="ext4" /dev/mapper/centos_centos71-swap: UUID="577f9541-8d2a-4666-ac8f-ff84b584eeca" TYPE="swap" /dev/mapper/vg_data-centos7_vol: UUID="b100ad2b-ad89-4e2d-ba8e-7eda7d703c40" TYPE="ext4"
2. Alternatively you can also use the below command to find out the UUID of devices.
# ls -l /dev/disk/by-uuid total 0 lrwxrwxrwx 1 root root 10 Dec 20 23:16 2bc8e0d4-64b5-4dc8-bf4a-024fc980d98a -> ../../dm-1 lrwxrwxrwx 1 root root 10 Dec 20 23:16 577f9541-8d2a-4666-ac8f-ff84b584eeca -> ../../dm-0 lrwxrwxrwx 1 root root 10 Dec 20 23:19 b100ad2b-ad89-4e2d-ba8e-7eda7d703c40 -> ../../dm-2
3. Check the mounted partitions.
# df -lh Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos_centos71-root 24G 3.1G 19G 15% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 25M 1.9G 2% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup tmpfs 500M 0 500M 0% /etc/nginx/cache /dev/sda1 477M 230M 218M 52% /boot tmpfs 380M 0 380M 0% /run/user/0 /dev/mapper/vg_data-centos7_vol 9.8G 37M 9.2G 1% /data
There is mounted /data in the system with UUID=”b100ad2b-ad89-4e2d-ba8e-7eda7d703c40″.
4. Change UUID for /dev/mapper/vg_data-centos7_vol which is in /data mounted partition.
- 1.Create the new UUID using below command.
# uuidgen fb5c697b-d1d6-49ab-afcd-27a22a5007c8
- 2. Please take note that the UUID may only be changed when the filesystem is unmounted.
# umount /data
- 3. Now change UUID for LVM /dev/mapper/vg_data-centos7_vol with new generated UUID.
# tune2fs /dev/mapper/vg_data-centos7_vol -U fb5c697b-d1d6-49ab-afcd-27a22a5007c8 tune2fs 1.42.9 (28-Dec-2013)
- 4. Mount back the /data partition.
# mount /dev/mapper/vg_data-centos7_vol /data
- 5. Update /etc/fstab.
UUID=fb5c697b-d1d6-49ab-afcd-27a22a5007c8 /data ext4 defaults 1 2
- 6. Verify new UUID for /dev/mapper/vg_data-centos7_vol.
# blkid /dev/mapper/centos_centos71-root: UUID="2bc8e0d4-64b5-4dc8-bf4a-024fc980d98a" TYPE="ext4" /dev/mapper/centos_centos71-swap: UUID="577f9541-8d2a-4666-ac8f-ff84b584eeca" TYPE="swap" /dev/mapper/vg_data-centos7_vol: UUID="fb5c697b-d1d6-49ab-afcd-27a22a5007c8" TYPE="ext4"
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Leave a Comment