A volume label can be used by mount(8), fsck(8), and /etc/fstab(5) by specifying UUID=uuid instead of a block special device name like /dev/hda1. To define a Label on a partition: tune2fs -L label /dev/sda1 To define a UUID on a partition: tune2fs -U uuid /dev/sda1 To view a filesystem's Label or UUID: tune2fs -l /dev/sda1 Filesystem volume name: <none> Filesystem UUID: 2ca4d883-c20a-4000-99fa-3fb2ad1abcf1 To use a Label or UUID in /etc/fstab, use the following notation: LABEL= UUID= tune2fs -U uuid The UUID parameter may also be one of the following: clear clear the filesystem UUID random generate a new randomly-generated UUID time generate a new time-based UUID You can use /lib/udev/vol_id (in udev package) to find a swap partion's UUID! /lib/udev/vol_id /dev/sdaN "ls -la /dev/disk/by-uuid/" will link to the actual /dev/sdX partition so you can indirectly figure out the UUID of a swap partition. "For a swap space I don’t know of any tool that can extract the UUID and name." blkid(8) from e2fsprogs does exactly that. -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- http://etbe.coker.com.au/2008/07/08/label-vs-uuid-vs-device/ The UUID is assigned automatically by mkfs or mkswap, so you have to discover it after the filesystem or swap space has been made (or note it during the mkfs/mkswap process). For the ext2/3 filesystems the command "tune2fs -l DEVICE" will display the UUID and label (strangely mke2fs uses the term "label” while the output of tune2fs uses the term "volume name"). One problem with mounting by UUID or label is that it doesn’t work well with snapshots and block device backups. If you have a live filesystem on /dev/sdc and an image from a backup on /dev/sdd then there is a lot of potential for excitement when mounting by UUID or label. Snapshots can be made by a volume manager (such as LVM), a SAN, or an iSCSI server. Another problem is that if a file-based backup is made (IE tar or cpio) then you lose the UUID and label. tune2fs allows setting the UUID, but that seems like a potential recipe for disaster. So this means that if mounting by UUID then you would potentially need to change /etc/fstab after doing a full filesystem restore from a file-based backup, this is not impossible but might not be what you desire. Setting the label is not difficult, but it may be inconvenient. With SCSI disks the naming issue has always been more complex, and which device gets the name /dev/sda was determined by the order in which the SCSI HAs were discovered. So if a SCSI HA which had no disks attached suddenly had a disk installed then the naming of all the other disks would change on the next boot! In this situation the use of UUIDs or LABELS is required for the use of partitions. However a common trend is towards using LVM for all storage, in this case LVM manages labels and UUIDs internally (with some excitement if you do a block device backup of an LVM PV). So LV names such as /dev/vg0/root then become persistent and there is no need for mounting via UUID or label. The most difficult problem then becomes the situation where a FC SAN has the ability to create snapshots and make them visible to the same machine. UUID or label based mounting won’t work unless you can change them when creating the snapshot (which is not impossible but is rather difficult when you use a Windows GUI to create snapshots on a FC SAN for use by Linux systems). -------------------------------------------------------------------------------- http://etbe.coker.com.au/2008/07/08/label-vs-uuid-vs-device/ http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=489865 On Debian (Etch and Unstable) the file command does not display the UUID for swap spaces or ext2/3 filesystems and does not display the label for ext2/3 filesystems. The Debian bug has been fixed in Unstable. Below are /etc/magic entries for displaying the UUID and label on swap spaces and ext2/3 filesystems: The following magic entry will display the UUID of a swap space as well as displaying the label in the same manner as the mkswap program: # according to man page of mkswap (8) March 1999 # volume label and UUID Russell Coker # http://etbe.coker.com.au/2008/07/08/label-vs-uuid-vs-device/ 4086 string SWAPSPACE2 Linux/i386 swap file (new style), >0×400 long x version %d (4K pages), >0×404 long x size %d pages, >1052 string \0 no label, >1052 string >\0 LABEL=%s, >0×40c belong x UUID=%x >0×410 beshort x \b-%x >0×412 beshort x \b-%x >0×414 beshort x \b-%x >0×416 belong x \b-%x >0×41a beshort x \b%x The following magic entry will display the UUID and label (AKA volume name) of an ext2/3/4 filesystem: # ext2/ext3 filesystems - Andreas Dilger <adilger@dilger.ca> # ext4 filesystem - Eric Sandeen <sandeen@sandeen.net> # volume label and UUID Russell Coker # http://etbe.coker.com.au/2008/07/08/label-vs-uuid-vs-device/ 0×438 leshort 0xEF53 Linux >0×44c lelong x rev %d >0×43e leshort x \b.%d # No journal? ext2 >0×45c lelong ^0×0000004 ext2 filesystem data >>0×43a leshort ^0×0000001 (mounted or unclean) # Has a journal? ext3 or ext4 >0×45c lelong &0×0000004 # and small INCOMPAT? >>0×460 lelong <0×0000040 # and small RO_COMPAT? >>>0×464 lelong <0×0000008 ext3 filesystem data # else large RO_COMPAT? >>>0×464 lelong >0×0000007 ext4 filesystem data # else large INCOMPAT? >>0×460 lelong >0×000003f ext4 filesystem data >0×468 belong x \b, UUID=%x >0×46c beshort x \b-%x >0×46e beshort x \b-%x >0×470 beshort x \b-%x >0×472 belong x \b-%x >0×476 beshort x \b%x >0×478 string >0 \b, volume name "%s" # General flags for any ext* fs >0×460 lelong &0×0000004 (needs journal recovery) >0×43a leshort &0×0000002 (errors) # INCOMPAT flags >0×460 lelong &0×0000001 (compressed) #>0×460 lelong &0×0000002 (filetype) #>0×460 lelong &0×0000010 (meta bg) >0×460 lelong &0×0000040 (extents) >0×460 lelong &0×0000080 (64bit) #>0×460 lelong &0×0000100 (mmp) #>0×460 lelong &0×0000200 (flex bg) # RO_INCOMPAT flags #>0×464 lelong &0×0000001 (sparse super) >0×464 lelong &0×0000002 (large files) >0×464 lelong &0×0000008 (huge files) #>0×464 lelong &0×0000010 (gdt checksum) #>0×464 lelong &0×0000020 (many subdirs) #>0×463 lelong &0×0000040 (extra isize)