News | About | Get Frugalware | Packages | Documentation | Discussion Forums | Bug Tracker | Wiki | Community | Development

UUID

From FrugalWiki

Jump to: navigation, search


UUID is Universal Unique IDentifier

This article describes how to use persistent names by UUID for your block devices. This has been made possible by the introduction of udev and has some advantages over bus-based naming. If your machine has more than one SATA, SCSI or IDE disk controller, the order in which their corresponding device nodes are added is random. This may result in device names like /dev/sda and /dev/sdb switching around randomly on each boot, culminating in an unbootable system, kernel panic, or a block device disappearing. Persistent naming solves these issues.

Note that if you are using LVM, this article is not relevant as LVM takes care of this automatically.

UUID is a mechanism to give each filesystem a unique identifier. It is designed so that collisions are unlikely. All GNU/Linux filesystems (including swap) support UUID. FAT and NTFS filesystems do not support UUID, but are still listed in /dev/disk/by-uuid with a unique identifier:

$ ls -lF /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 25 sept. 07:55 81cd4d68-d5c8-4d44-8c24-ea373f47ef88 -> ../../sda3
lrwxrwxrwx 1 root root 10 25 sept. 07:55 8414A2DB14A2D00A -> ../../sda1
lrwxrwxrwx 1 root root 10 25 sept. 07:55 9fc23edc-2022-47bf-93a8-4c4f6c5eed85 -> ../../sda4
lrwxrwxrwx 1 root root 10 25 sept. 07:55 c9a51692-575a-4087-a1a7-125404b52b7a -> ../../sda2

Or you can use blkid with blkid /dev/$DEVICE


$ blkid /dev/sda1
/dev/sda1: UUID="8414A2DB14A2D00A" TYPE="ntfs" 
$ blkid /dev/sda2
/dev/sda2: UUID="c9a51692-575a-4087-a1a7-125404b52b7a" TYPE="ext4" 
$ blkid /dev/sda3
/dev/sda3: UUID="81cd4d68-d5c8-4d44-8c24-ea373f47ef88" TYPE="ext3"  
$ blkid /dev/sda4
/dev/sda4: UUID="9fc23edc-2022-47bf-93a8-4c4f6c5eed85" TYPE="swap" 

Fstab

To enable persistent naming in /etc/fstab replace the device kernel name in the first column with the persistent name path as follows:

Example:

$ cat /etc/fstab/
/dev/sda4        swap             swap        defaults         0   0
/dev/sda2        /                ext4        defaults         1   1
/dev/sda3        /home            ext3        defaults         1   1

Remember previously we had:


$ ls -lF /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 25 sept. 07:55 81cd4d68-d5c8-4d44-8c24-ea373f47ef88 -> ../../sda3
lrwxrwxrwx 1 root root 10 25 sept. 07:55 8414A2DB14A2D00A -> ../../sda1
lrwxrwxrwx 1 root root 10 25 sept. 07:55 9fc23edc-2022-47bf-93a8-4c4f6c5eed85 -> ../../sda4
lrwxrwxrwx 1 root root 10 25 sept. 07:55 c9a51692-575a-4087-a1a7-125404b52b7a -> ../../sda2

So, our new /etc/fstab will be

UUID=9fc23edc-2022-47bf-93a8-4c4f6c5eed85       swap             swap        defaults         0   0
UUID=c9a51692-575a-4087-a1a7-125404b52b7        /                ext4        defaults         1   1
UUID=81cd4d68-d5c8-4d44-8c24-ea373f47ef88       /home            ext3        defaults         1   1

Grub

Same thing with /boot/grub/menu.lst

Example:

Once again, for this example, we use the previous example of UUID.


$ cat /boot/grub/menu.lst
#
# /boot/grub/menu.lst - configuration file for GRUB
# This file is generated automatically by grubconfig
#

default=0
timeout=5
gfxmenu (hd0,1)/boot/grub/message

title Frugalware 1.5 (Mores) - 3.0-fw3
    kernel (hd0,1)/boot/vmlinuz root=/dev/sda2 ro quiet resume=/dev/sda4 splash
    initrd (hd0,1)/boot/initrd.img.xz


So the new menu.lst with UUID will be:

#
 # /boot/grub/menu.lst - configuration file for GRUB
 # This file is generated automatically by grubconfig
 #
 
 default=0
 timeout=5
 gfxmenu (hd0,1)/boot/grub/message
 
 title Frugalware 1.5 (Mores) - 3.0-fw3
     kernel (hd0,1)/boot/vmlinuz root=UUID=c9a51692-575a-4087-a1a7-125404b52b7a ro quiet 
resume=UUID=9fc23edc-2022-47bf-93a8-4c4f6c5eed85 splash
     initrd (hd0,1)/boot/initrd.img.xz
 
 

Sources

Personal tools
Namespaces
Variants
Actions