How to retrieve UUID
On some unix systems a hard drives partition is referred by to as UUID instead of the location of the it relevant block device file for example like in /etc/fstab:
UUID=03136e34-6187-4720-8594-b27508ef978f /boot ext3 defaults,noatime 1 2
In this case it would be harder to find which partition is mounted behind /boot. Here are some ways how to retrieve relevant partition UUID.
1. blkid
1 | # blkid |
/dev/mapper/VolGroup00-LogVol01: UUID="8bd5ec66-b842-4e43-98d1-d717520e025f" TYPE="ext3"
/dev/mapper/VolGroup00-LogVol00: UUID="c7b0bb1f-ea78-46fc-a3f2-f7f4ca79358a" TYPE="ext3"
/dev/sda1: UUID="03136e34-6187-4720-8594-b27508ef978f" TYPE="ext3"
/dev/VolGroup00/LogVol00: UUID="c7b0bb1f-ea78-46fc-a3f2-f7f4ca79358a" TYPE="ext3"
/dev/VolGroup00/LogVol02: TYPE="swap"
Or you can specify an argument to retrieve a single partition UUID:
1 | # blkid /dev/sda1 |
2. udevinfo
1 | # udevinfo -q all -n /dev/sda1|grep uuid |
3. vol_id
1 | # vol_id /dev/sda1 | grep UUID |
ID_FS_UUID_ENC=03136e34-6187-4720-8594-b27508ef978f
4. /dev/disk/by-uuid/
1 | # ls -l /dev/disk/by-uuid/ |
lrwxrwxrwx 1 root root 10 Aug 1 03:42 03136e34-6187-4720-8594-b27508ef978f -> ../../sda1
5. /dev/.udev/db/
1 | # cat /dev/.udev/db/*sda1|grep uuid |
6. hwinfo
another way on how to access a UUID and the hardrives/block devices is to use hwinfo command. hwinfo is not installed by default so you may need to install it first.
1 | # hwinfo --block |
How to set or change UUID
Now let's talk about how to change a partition's UUID. We'll use uuidgen to generate uuid string:
1 | # uuidgen |
Now we use tune2fs command to change /dev/sda1 partition's UUID:
1 | # tune2fs /dev/hdb1 -U `uuid` |
No comments:
Post a Comment