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.

5 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

Leave a Reply

TopOfBlogs