Tagged and Bagged: , , , ,

NOTE: this tip may be specific to Ubuntu, as far as the command goes…

One thing that I’ve noticed is that many distros are starting to change their partition references in /etc/fstab to a UUID from the more familiar (but no friendlier) reference to the volume in /dev (such as /dev/hdc3, for example).  This might be a sign of things to come, since any distro based on the 2.6 Linux kernel has pretty much dropped the /dev for udev (hot plugging for cold plugging, etc).  After looking into things, its good for situations where drives are being moved or removed now and then (as in when you plug in your USB hard drive).

However, if you’re a constant alpha/beta tester at heart, like I am, you are probably using a main Linux partition or drive to work from and have either a spare drive or partition that you frequently blow away and replace what’s on it with the latest fun toy, as I do.  I don’t know how many distros are doing this with the UUID so far, but I suspect that Fedora does and I know that Ubuntu and Mandriva are now doing it.  So, what happens if you are tired of what you’ve been testing and you want to install something new? As soon as you format the drive, the UUID will change.  How do you reference the drive in your /etc/fstab, so that you can either find it when you want to mount it, or when you want to boot from the new distro? The first “U” is for “unique”, and they are! Here’s what’s currently in my /boot/grub/menu.lst for the Mandrake alpha 2 that I’m playing with: root=UUID=b414e306-0582-4572-926d-a8c113bf34bb.

That’s not exactly the stuff of memorization, and, in a few hours, it’ll be different, as I’m going to hose it and reinstall it with a totally different configuration (I wanna try KDE 4!!!).  So, how do I get the new volume ID to put in /etc/fstab and /boot/grub/menu.lst? With Ubuntu, you have a command called vol_id that you can run as root to determine various things about the volumes that are accessible to your computer.

The command is vol_id.  So, the command to find a volume ID is:

sudo vol_id -u device

where device is the /dev entry for the partition you want to know about.  for example,

sudo vol_id -u /dev/hdc3

would yield the long scary output that you need to enter into your files.

I hope that this helps all you distro hoppers out there as much as it has me.

11 Comments

  1. hari says:

    /etc/fstab can sometimes be a serious pain. I always wish the device naming scheme sticks to one standard. Too many variants cause confusion. Luckily Debian always stays conservative and familiar enough.

    1
  2. Super Jamie says:

    THANK YOU SO MUCH!!! You have no idea how hard this info is to find!

    2
  3. MrCorey says:

    Actually, I do! That’s why I wrote about it. :D I thought that I’d work search bots that constantly infest (hehheh) my site and make something useful pop up in their results. Thanks for stopping by.

    3
  4. Vern says:

    Thanks for taking the time and effort to help fellow *nixers! I just wish taht Google had found this earlier :)
    Actually I find that swap doesn’t have a UUID:
    Device Boot Start End Blocks Id System
    /dev/sda1 * 1 3200 25703968+ 83 Linux
    /dev/sda2 3201 3576 3020220 5 Extended
    /dev/sda5 3201 3576 3020188+ 82 Linux swap / Solaris
    vmc@vmc-desktop:~$ sudo vol_id /dev/sda1
    ID_FS_USAGE=filesystem
    ID_FS_TYPE=ext3
    ID_FS_VERSION=1.0
    ID_FS_UUID=d8533154-cef1-4cce-a823-9f3f74aab65b
    ID_FS_UUID_ENC=d8533154-cef1-4cce-a823-9f3f74aab65b
    ID_FS_LABEL=
    ID_FS_LABEL_ENC=
    ID_FS_LABEL_SAFE=
    vmc@vmc-desktop:~$ sudo vol_id /dev/sda5
    ID_FS_USAGE=other
    ID_FS_TYPE=swap
    ID_FS_VERSION=2
    ID_FS_UUID=
    ID_FS_UUID_ENC=
    ID_FS_LABEL=
    ID_FS_LABEL_ENC=
    ID_FS_LABEL_SAFE=

    4
  5. mrcorey says:

    I responded to your post on LQ, vern. I think that your swap got blasted when you resized your filesystem partition. mkswap should fix it.

    5
  6. marcthenarc says:

    Simple but nice post.

    Cheers.

    6
  7. Pete says:

    I was also looking around for a way just to identify the UUID of a partition.
    This is what worked for me:

    vol_id –uuid /dev/sdc1 –export
    ID_FS_USAGE=raid
    ID_FS_TYPE=linux_raid_member
    ID_FS_VERSION=0.90.0
    ID_FS_UUID=eb0b24ea:01425053:19bbf76a:ff5baf28
    ID_FS_UUID_ENC=eb0b24ea:01425053:19bbf76a:ff5baf28
    ID_FS_LABEL=
    ID_FS_LABEL_ENC=
    ID_FS_LABEL_SAFE=

    7
  8. mrcorey says:

    @Pete -
    Neat thought. I keep forgetting about the power of the export command.

    8
  9. Stephen says:

    I’m having this problem…unfortunately, the UUID’s are the same. I’m running Heron with the eee netbook modules, on an EEE 1000. Thanks for the help!! Here’s what I’m seeing:

    >>> Terminal fsck
    [10:44:58 12] $ fsck
    fsck 1.40.8 (13-Mar-2008)
    fsck.ext3: Unable to resolve ‘UUID=259a3310-b2b8-4b01-bb57-c0efb89768ae’

    >>> Gedit fstab
    # /etc/fstab: static file system information.
    #
    #
    proc /proc proc defaults 0 0
    # /dev/sda1
    UUID=259a3310-b2b8-4b01-bb57-c0efb89768ae / ext3 noatime,errors=remount-ro,commit=15 0 1
    # /dev/sdb1
    UUID=d7729a87-b7e2-49f9-b4ee-85018f5afca7 /home ext2 relatime 0 2
    /dev/sdc1 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
    tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
    tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0

    At startup, my system is always saying bad shutdown, and that fsck died with an exit status of 4.

    9
  10. MrCorey says:

    Stephen, what is the result of the vol_id command? What is the output? fsck is trying to work on the information provided in /etc/fstab, which may not match your actual volume UUID.

    10
  11. Larry Who? says:

    I’m sorry, but I still find /dev/hda1 or /dev/sda1 more user friendly in my fstab. At least that way you know what is what, that UUID is useless when trying to figure which partition it is.

    11

Leave a Reply

TopOfBlogs