fstab with uuid
October 10th, 2007 mysurface Posted in Admin, blkid, ls, vol_id | Hits: 218894 | 31 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
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"







October 11th, 2007 at 6:29 pm
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?…
October 15th, 2007 at 9:00 pm
[...] to Linux By Examples for the initial howto. Posted in Linux, Shell, Short Tip, [...]
October 16th, 2007 at 7:16 pm
great tip. I like the idea that you can call mount your root partition with simply: LABEL=Root too.
October 22nd, 2007 at 5:29 am
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!
October 30th, 2007 at 4:06 am
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.
October 30th, 2007 at 10:04 pm
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?
October 30th, 2007 at 11:32 pm
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.
October 31st, 2007 at 4:58 pm
What is the advantage of using UUID?
October 31st, 2007 at 6:53 pm
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.
December 9th, 2007 at 10:12 pm
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
February 8th, 2008 at 7:29 pm
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.
February 9th, 2008 at 5:43 pm
Welcome to Ubuntu community and thanks for visiting this page.
February 13th, 2008 at 6:39 pm
Thanks a lot!
:-)
August 31st, 2008 at 3:19 am
Hey, I might say, excelent tip! Thanks :)
October 6th, 2008 at 1:10 pm
[...] http://linux.byexamples.com/archives/321/fstab-with-uuid/ [...]
October 22nd, 2008 at 7:39 am
Thanks.. this was a great tip…..
December 28th, 2008 at 3:03 am
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 ..
January 18th, 2009 at 6:46 am
SOS! My car was boken on road. Must IJ cazll to repairs or 911?
January 18th, 2009 at 10:08 pm
and whta do you thhink about gas problem in Ukraine?
January 19th, 2009 at 4:31 am
wonderful post))
January 20th, 2009 at 6:49 pm
Where I may to find blogs n this otpic?
January 21st, 2009 at 5:35 am
It’s difficult to understand..
January 22nd, 2009 at 6:22 pm
Spuer! I’ll make similar post in own blog
February 3rd, 2009 at 8:22 pm
[...] http://linux.byexamples.com/archives/321/fstab-with-uuid/ [...]
February 27th, 2009 at 1:06 am
[...] http://linux.byexamples.com/archives/321/fstab-with-uuid/ [...]
November 4th, 2009 at 8:15 pm
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…
June 15th, 2010 at 2:31 pm
Thanks, this fixed my problem with multiple drives and boot failure!
March 10th, 2011 at 9:43 am
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 !
December 14th, 2011 at 3:12 am
[...] 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 [...]
November 22nd, 2012 at 1:35 pm
[...] Thanks to Linux By Examples for the initial howto. [...]
December 21st, 2012 at 2:23 pm
Thanks bro.