How to Change UUID of Linux Partition on CentOS 7

Change UUIDUUID (Universally Unique IDentifier) should be unique and it is used to identify storage devices on a linux system.

If you cloned a virtual machine from vCenter, the metadata containing information of UUID for the filesystem will be identical for the original and cloned copy, therefore the UUID is no longer unique in /etc/fstab.

The following steps will show how to change UUID of linux partition on CentOS 7.

1) Use blkid command-line utility to determine device UUID :

# blkid

Sample output :

/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) Another way to list out uuid by issue below command :

# 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) Verify the mounted partition :

See also  How to Reset the Directory Manager Password on RHEL 7 / CentOS 7

There is mounted /data in the system with UUID=”b100ad2b-ad89-4e2d-ba8e-7eda7d703c40″.

# 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

4. How to change UUID for /dev/mapper/vg_data-centos7_vol which is in /data mounted partition.

a) Generate new UUId using uuidgen utility :

# uuidgen
fb5c697b-d1d6-49ab-afcd-27a22a5007c8

b) Please take note that the UUID may only be changed when the filesystem is unmounted.

# umount /data

c) 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)

d) Mount back the /data partition :

# mount /dev/mapper/vg_data-centos7_vol /data

e) Update /etc/fstab :

See also  How to Install IonCube Loader in CentOS 6 / CentOS 7

Option 1 :

UUID=fb5c697b-d1d6-49ab-afcd-27a22a5007c8 /data                   ext4    defaults        1 2

Option 2 :

/dev/mapper/vg_data-centos7_vol /data                   ext4    defaults        1 2

f) Verify new UUID for /dev/mapper/vg_data-centos7_vol

# blkid

Sample output :

/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"

Source

How to Reset the Directory Manager Password on RHEL 7 / CentOS 7
How to Reset the Directory Manager Password on RHEL 7 / CentOS 7

It is best practice to remember passwords, but because too many passwords, sometimes we forget. We are not encouraged to write the password on any paper or share the password...

How to Find Big Files Size on Linux RHEL/CentOS
How to Find Big Files Size on Linux RHEL/CentOS

As the linux administrator, sometimes we have to identify which files are most take much space in the linux server resulting in low free space. Low disk space can also...

Why Linux users should worry about malware and what they can do about it
Why Linux users should worry about malware and what they can do about it

Don’t drop your guard just because you’re running Linux. Preventing the spread of malware and/or dealing with the consequences of infection are a fact of life when using computers. If...

How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7
How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7

This short howto will explain the steps to reset a lost root password or to reset a forgotten root password on Linux RHEL 7 or CentOS 7. Basically, we will...

How to Update CentOS or Upgrade CentOS to the Latest Version
How to Update CentOS or Upgrade CentOS to the Latest Version

Recently, the latest version of CentOS 7.3 was released. All users of CentOS 7.0, 7.1 and 7.2 can upgrade their system to the most recent. This quick guide will explain...

How to Change your WordPress Username, Nickname and Display Name in MySQL
How to Change your WordPress Username, Nickname and Display Name in MySQL

After you create an account log in WordPress, you may want to change your WordPress username, as appropriate or due to security reason. However, you can not do this from...

How to Enable SSH Root Login on Ubuntu 16.04
How to Enable SSH Root Login on Ubuntu 16.04

As what we wrote in the previous article on how to allow SSH root on Ubuntu 14.04, after installing a fresh new copy of Ubuntu 16.04 LTS, we find that...

How to Change UUID of Linux Partition on CentOS 7
How to Change UUID of Linux Partition on CentOS 7

UUID (Universally Unique IDentifier) should be unique and it is used to identify storage devices on a linux system. If you cloned a virtual machine from vCenter, the metadata containing...

Leave a Reply

Your email address will not be published. Required fields are marked *