UUID (Universally Unique Identifier) is used to identify storage devices on a system. When you add the file system we will add uuid or label.
We can easily generate the UUID in a system using uuidgen command
# uuidgen
d64303a4-2d7d-49ce-b8b4-1fd5db8d444a
How to change the UUID for Logical Volume:
Find out current lvm uuid:
To determine the UUID for the device /dev/mapper/vg01-linux01, can get using blkid command,
# blkid /dev/mapper/vg01-linux01
/dev/mapper/vg01-linux01: UUID="4ed7925b-b35a-43ca-abd1-e9db6fb80364" TYPE="ext4"
The output is device name, label name, UUID and file system type ext4
Generate New UUID.
# uuidgen
45ce9e8c-4993-4247-b08b-e8092b898b7e
Using tune2fs command can be changed the UUID for that specific device name.
# tune2fs /dev/mapper/vg01-linux01 -U 45ce9e8c-4993-4247-b08b-e8092b898b7e
tune2fs 1.42.8 (20-Jun-2013)
After changes you can check it .
# blkid /dev/mapper/vg01-linux01
/dev/mapper/vg01-linux01: UUID="45ce9e8c-4993-4247-b08b-e8092b898b7e" TYPE="ext4"
How to change the UUID for Partition:
For example, do you want to change the device /dev/sda1 follow the steps,
#uuidgen
08ad6121-a3a7-4207-9778-ae17f1d55dc4
# tune2fs /dev/sda1 -U 08ad6121-a3a7-4207-9778-ae17f1d55dc4
tune2fs 1.42.8 (20-Jun-2013)
# blkid /dev/sda1
/dev/sda1: UUID="08ad6121-a3a7-4207-9778-ae17f1d55dc4" TYPE="ext4"
Once you have changed that should be update in file system /etc/fstab
UUID Help:
# uuidgen --help
Usage:
uuidgen [options]
Options:
-r, --random generate random-based uuid
-t, --time generate time-based uuid
-V, --version output version information and exit
-h, --help display this help and exit
To find out uuidgen version,
# uuidgen -V
uuidgen from util-linux 2.20.1
How to generate UUID using PHP code,
<?php
echo exec('uuidgen');
?>
Comments (0)