fstab with uuid

October 10th, 2007 mysurface Posted in Admin, blkid, ls, vol_id | Hits: 238146 | 34 Comments »

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

or this

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

34 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/


  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!


  14. Hey, I might say, excelent tip! Thanks :)

  15. Thanks.. this was a great tip…..

  16. ok, err, i dessire to knwon what package are the resposable for write the fstab, can be possible change this by use uuid even the device naming, currently lenny used scsi device names now, every device now are handle as scsi device, whell see ..

  17. SOS! My car was boken on road. Must IJ cazll to repairs or 911?

  18. and whta do you thhink about gas problem in Ukraine?

  19. wonderful post))

  20. Where I may to find blogs n this otpic?

  21. It’s difficult to understand..

  22. Spuer! I’ll make similar post in own blog

  23. Thanks, I never remember how to find the UUID. Note that on RHEL4 (yes, I know, but our IT department ‘standardised’ on it) it seems that neither /dev/disk/by-uuid/ nor vol_id exist (it’s an ancient kernel), but fortunately /sbin/blkid does. And you have to run it as root to show some of the disks (but not others). But I got there eventually…

  24. Thanks, this fixed my problem with multiple drives and boot failure!

  25. Everything has its 2 sides: I had to install RAID1 on a running hardy-heron server. I switched over to good old /dev/sdx etc. and RAID was running in no time.

    Even more: if you have to change disks its much easier !

  26. [...] it seems much better, but I couldn't find anything. UUID's can be used for mounting (fstab): Linux by examples – fstab with uuid (search with fstab uuid and get a ton of hits) And although I never tried using UUID's and grub [...]

  27. [...] Thanks to Linux By Examples for the initial howto. [...]

  28. Thanks bro.

  29. The receiver will never know that you have talented them with swiss replica watches. In fact they will be delighted to accept these swiss replica watches since they see it as the primitive. Go out today and get by payment a pair of these swiss replica watches. Do not confine yourself to just one and let your fancy run wild while you are purchasing these swiss replica watches. You can be rest assured that these watches will serve you for many years to come and that they will never let you down. However do not overdo it. There are some fanatics in place and people have reported seeing them wearing two swiss replica watches, one on each palm and fingers. Now this is taking things too far.

  30. [...] I don't know the answer to your question, but would mounting using UUID rather than LABEL be a viable alternative? fstab with uuid [...]

  31. Hey there! I just want to give you a huge thumbs up for your great info you’ve got right here on this post.
    I’ll be returning to your website for more soon.

Leave a Reply