Ubuntu, as with other distributions, is using UUIDs in the /etc/fstab. The Universally Unique Identifier number is configured for each standard partition in /etc/fstab. The UUID is a 16-byte (128-bit) number that is unique to the partition. The purpose of the UUID is to allow you to add, move and remove drives and still maintain the integrity of the partitions and their purpose is the file system. Without UUID the use of USB or hotswap disks may change the partition numbers and impact the file system. For example if you had a disk sdd with a partition /dev/sdd1 mounted as /db in the file system and then you removed disk sdc, it would change the partition numbers of all of the partitions moving them down a drive letter and not allowing the /db to mount from the correct partition.
You can view all of the current UUIDs with this command:
ls -l /dev/disk/by-uuid
lrwxrwxrwx 1 root root 10 2009-04-18 00:22 4968c0c1-cca3-466a-9197-0850e7e1be6a -> ../../sda5
lrwxrwxrwx 1 root root 10 2009-04-18 00:22 83c65844-291f-47e0-b74b-ae1eea89d1fe -> ../../sda1
lrwxrwxrwx 1 root root 10 2009-04-18 00:22 8800d1d1-2914-4f3f-9f61-30d65d9efe25 -> ../../sdb1
lrwxrwxrwx 1 root root 10 2009-04-18 00:22 994b64a0-2e44-4771-8903-dff3cf24f871 -> ../../sda6
lrwxrwxrwx 1 root root 10 2009-04-18 00:22 a37ce594-e86d-4344-81b6-6fe630ba5c2a -> ../../sda2
lrwxrwxrwx 1 root root 10 2009-04-18 00:22 b663440e-fe9b-4d6d-ba35-1aaf02e0b5bd -> ../../sda3
Note that these are links to the device files.
If you create a new partition, you may want to generate a UUID.
uuidgen /dev/sdb2 > uuidsdb2
This will create a file with the UUID.
Now you can apply the UUID to the device since the command does not do that automatically.
sudo tune2fs -U `cat uuidsdb2` /dev/sdb2
tune2fs 1.41.4 (27-Jan-2009)
Now you need to create an entry in the /etc/fstab. You may want to back up /etc/fstab first.
echo “UUID=`cat uuidsdb2` /data ext3 defaults 0 0″ >> /etc/fstab
Run this command to mount:
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# / was on /dev/sda2 during installation
UUID=a37ce594-e86d-4344-81b6-6fe630ba5c2a / ext4 relatime,errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=83c65844-291f-47e0-b74b-ae1eea89d1fe /boot ext3 relatime 0 2
# /home was on /dev/sda3 during installation
UUID=b663440e-fe9b-4d6d-ba35-1aaf02e0b5bd /home ext4 relatime 0 2
# /var was on /dev/sda5 during installation
UUID=4968c0c1-cca3-466a-9197-0850e7e1be6a /var ext4 relatime 0 2
# swap was on /dev/sda6 during installation
UUID=994b64a0-2e44-4771-8903-dff3cf24f871 none swap sw 0 0
# swap was on /dev/sdb1 during installation
UUID=8800d1d1-2914-4f3f-9f61-30d65d9efe25 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
UUID=393b8c11-d47d-4e05-aec9-6ef9e4f7561f /data ext3 defaults 0 0
If you get an error message you can link the UUID to the disk.
ln -s /dev/sdb2 /dev/disk/by-uuid/`cat uuidsdb2`
Now you can verify that it is mounted
/dev/sdb2 on /data type ext3 (rw)
Understanding the /etc/fstab
The /etc/fstab is where the mount points for the operating system will be mounted. Here is a description of some of the terms.
file system – device to be mounted
mount point – where the filesystem will be mounted
type – labels the filesystem
dump – data to be automatically saved to disk using hte dump command, 0 for none, 1 for save
pass order for filesystem checks
There are a number of Options that are available when mounting a drive.
Mount Option Description
async read and write data asynchronously
atime update inodes when file is accessed
auto normal formats for floppy or removable drive
dev allows accesses to devices (consoles or drives)
exec permit binaries to execute
noatime inode is not updated when accessed
noauto must mount manually
nodev devices not read
noexec binaries cannot be run
nosuid disallows setuid and segid
nouser only root can mount filesystem
remount filesystem can be remunted
ro read only
rw read and write
suid allows setuid and setgid
sync read and write done at same time
user allows noroot users to mount filesystem
The Dump Order is important for backups. Place a 1 for local devices so dump can backup. The example shows a 1.
LABEL=/home /home ext3 defaults 1 2
This allows you to set priorities for which device gets checked by fsck first in case of a system crash. Usually a 0 is placed for devices that do not need to be checked like swap and a 1 is placed for the / directory to be checked first and a 2 on all other devices. The example is a 2.
LABEL=/home /home ext3 defaults 1 2