Live Chat!

fstab with uuid

* * * * * 2 votos

October 10th, 2007 mysurface Posted in Admin, blkid, ls, vol_id | Hits: 24204 |

When linux system starts, auto mounting partition will be done by refering to /etc/fstab. The file /etc/fstab will list down how you like the system to mount your partition. For examples,

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
   /dev/sda1      /media/sda1     vfat    default,umask=077,gid=46  0       0

/dev/sda1 is the device, the number will be change depend on the order of your hard disk that inject to your motherboard. /media/sda1 is the mount point, where the place you access the data of your disk storage. vfat is the file system’s type. Next is the list of mount options, carry on is dump and pass option.

Mount with device path has problems when you have multiple hard disk, and the order of hard disk changed may cause the file system failed to mount. Therefore later days of fstab entries has been modified to identify by uuid,

UUID=4706-0137      /media/sda1     vfat    defaults,umask=007,gid=46         0       0

UUID stands for Universally Unique Identifier, it gives each filesystem a unique identifier. With uuid, you no need to worry about the reordering of hard disk anymore.

So how to check the device’s uuid?

You can find all detected device by uuid with ls

ls -l /dev/disk/by-uuid/
lrwxrwxrwx 1 root root 10 2007-10-10 20:30 4706-0137 -> ../../sda1
lrwxrwxrwx 1 root root 10 2007-10-10 20:30 497c771b-63fe-461f-ad7d-0bef9a6ba718 -> ../../sda5
lrwxrwxrwx 1 root root 10 2007-10-10 20:30 ce7b6c5d-c66a-4fc8-9638-72f62820f422 -> ../../sda3

Or if you wanna check on more details on the device,

sudo vol_id /dev/sda1
ID_FS_USAGE=filesystem
ID_FS_TYPE=vfat
ID_FS_VERSION=FAT32
ID_FS_UUID=4706-0137
ID_FS_LABEL=
ID_FS_LABEL_SAFE=

or this

blkid /dev/sda1
/dev/sda1: UUID="4706-0137" TYPE="vfat"

13 Responses to “fstab with uuid”

  1. Hello there!.. how are you?… I know this is off topic nad I don’t even know what Linux is, but I just want to say thank you for visiting WEBVH1.com :)

    By the way, what is Linux?…

  2. [...] to Linux By Examples for the initial howto. Posted in Linux, Shell, Short Tip, [...]

  3. great tip. I like the idea that you can call mount your root partition with simply: LABEL=Root too.

  4. Thanks for writing this.

    It came in handy today. I upgraded my machine to Ubuntu 7.10 on Friday and had no problems, but this morning, my partner installed Kubuntu 7.10 and had had all kinds of problems because he uses 7 different drives on two different controllers. The problems he ran into was because the new kernel changed the /dev/sd & hd device names.

    We finally got around it by unhooking all but the volume we used for the root file system, and then added the other drives into fstab via the UUID method.

    I remembered reading this a few days ago so I came back to refresh my memory on how to see each device’s UUID.

    So, thanks again!

  5. A word of caution:

    I configured my /etc/fstab to use UUID for the root partition (default with Feisty Fawn install) and the laptop ran out of power during a normal user session, with some file corruption.

    Upon reboot the file system check for the root partition was forced, and this check failed for some reason. I used the Ubuntu Live CD to fsck the root partition and there was no problem, but still on boot the system still forced me to do the same file system check and it would fail yet again, no matter how many times I tried.

    I used the Live CD to look at /etc/fstab and saw the UUID statements. I replaced the line for the root partition with the old-fashioned way (/dev/sda1) - this time the file system check passed and the boot continued ok.

    I am sure that people with less patience would have probably reinstalled or swapped back to an evil OS for this reason alone.

  6. Hi,

    I just wanted how this uuids are assigned? Is this done by linux? What would happen to the uuid if i formatted the drive/partition?

  7. Roonaldo: I have no idea how uuid calculate the id and assigns to your partition. It seems to me that if you format your partition , uuid will stay unchange, but if you RESIZE or add in a new partition, uuid will be different.

  8. What is the advantage of using UUID?

  9. Mount with device with UUID, you do not need to worry about the ordering of your HDD. I can change my HDD that contain MBR from IDE0 to IDE1, and my system will still able to boot up.

  10. There is some info on how to use LABEL/UUID in fstab and howto use uuidgen, tune2fs to put/replace labels/uuids on disks. read the howro on http://www.nslu2-linux.org/wiki/HowTo/MountDisksByLabel
    and the comments on http://liquidat.wordpress.com/2007/10/15/short-tip-get-uuid-of-hard-disks/

    cheers

  11. Thankyou for this. I have 3 internal drives that had been changing and I could not work out how to fix it. I run Ubuntu 7.04, and have learned a lot from the excellent Ubuntu community and sites like this.

  12. Welcome to Ubuntu community and thanks for visiting this page.

  13. Thanks a lot!

    :-)

Leave a Reply