Results 1 to 8 of 8

Thread: How do I determine the UUID's of hard drive partitions?

  1. #1
    Join Date
    Mar 2007
    Location
    Scotland
    Beans
    1,111
    Distro
    Ubuntu Development Release

    How do I determine the UUID's of hard drive partitions?

    I'm looking for a quick piece of code to look up UUIDs. I want to specify bootable partitions in Grub2. I have found
    Code:
    sudo blkid -o full -s UUID
    but would like the output related to other information such as drive/partition volume, and if possible manufacturer and serial number. At the moment it simply returns a list of UUIDs related to dev (hd0,1 style).
    Code:
    sudo lshw -class disk
    gives me most of what I want, if it could output UUID as well that would be great.
    Last edited by bwallum; January 5th, 2010 at 11:41 AM.
    Itch: Think Hula hoop, positive on top, negative on bottom, roll it. Is it a wave or a particle? Is it a photon? Is a photon a dipole? Are we all made of light!

  2. #2
    Join Date
    Mar 2007
    Location
    Scotland
    Beans
    1,111
    Distro
    Ubuntu Development Release

    Re: How do I determine the UUID's of hard drive partitions?

    Answered my own question, sort of. I used
    sudo blkid
    and got device, label, uuid and TYPE returned. It isn't perfect but it helps. Typical output is
    /dev/sda1: LABEL="Ubuntu0" UUID="5e2f35bf-4894-4586-ad64-8da2ca9c61bd" TYPE="ext4"
    /dev/sda5: UUID="4bde0f88-f4a2-4405-b895-d16c06e01764" TYPE="swap"
    /dev/sdb1: LABEL="VideoHD" UUID="1d278a93-d076-4f66-9d75-d559b9398df5" SEC_TYPE="ext2" TYPE="ext3"
    /dev/sdc1: LABEL="HomeHD" UUID="641b027f-a8c8-4153-a70f-9f5e77490e2e" TYPE="ext3"
    Itch: Think Hula hoop, positive on top, negative on bottom, roll it. Is it a wave or a particle? Is it a photon? Is a photon a dipole? Are we all made of light!

  3. #3
    Join Date
    May 2006
    Location
    Amsterdam
    Beans
    1,731
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How do I determine the UUID's of hard drive partitions?

    Quote Originally Posted by bwallum View Post
    I'm looking for a quick piece of code to look up UUIDs. I want to specify bootable partitions in Grub2. I have found
    Code:
    sudo blkid -o value -s UUID
    but would like the output related to other information such as drive/partition volume, system reference (hd0,1) style and if possible manufacturer and serial number. At the moment it simply returns a list of UUIDs.
    Code:
    sudo lshw -class disk
    gives me most of what I want, if it could output UUID as well that would be great.
    Think you should write something yourself to get all the information needed. Probably only a few lines of shell in a function will do the trick.
    Upgrade Ubuntu | Upgrade unsupported Ubuntu versions | Always backup | Howto upgrade flash
    Minimal CD install | Remove old kernels | My blog | Linux user #462801 | Conscience doth make cowards of us all. -- Shakespeare

  4. #4
    Join Date
    Apr 2008
    Location
    Australian in Germany
    Beans
    4,010
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How do I determine the UUID's of hard drive partitions?

    Hi.
    Those two commands give your what you need, I think. You just need to put it together.

    Here is what I get from the first one:
    Code:
    mick@ubuntu-desktop:~$ sudo blkid -o full -s UUID
    [sudo] password for mick: 
    /dev/sda1: UUID="97201036-c514-47b5-aeb1-7ce98a8711ff" 
    /dev/sda3: UUID="a8b6c85c-65da-4ffa-9d2e-8356e5c26bd2" 
    /dev/sda5: UUID="e7d97bbe-adf2-4ad8-8d3e-c9f56adeed60" 
    /dev/sda6: UUID="aafe7a68-6945-48cf-b28a-f22b963d5fa6" 
    /dev/sda7: UUID="4772ec87-6f08-40b9-a274-64e930e7c336" 
    /dev/sdb1: UUID="aa6c721e-d06e-4756-bac9-b3849e1a9195" 
    /dev/sdb2: UUID="96004184-5efc-490d-9280-0e1ab845a142"
    and from the second one
    Code:
    mick@ubuntu-desktop:~$ sudo lshw -class disk
      *-cdrom                 
           description: DVD-RAM writer
           product: DVD-RAM GSA-H58N
           vendor: HL-DT-ST
           physical id: 0.0.0
           bus info: scsi@4:0.0.0
           logical name: /dev/cdrom
           logical name: /dev/cdrw
           logical name: /dev/dvd
           logical name: /dev/dvdrw
           logical name: /dev/scd0
           logical name: /dev/sr0
           version: 1.00
           serial: [HL-DT-STDVD-RAM GSA-H58N1.0007/08/17 7U02
           capabilities: removable audio cd-r cd-rw dvd dvd-r dvd-ram
           configuration: ansiversion=5 status=nodisc
      *-disk
           description: ATA Disk
           product: SAMSUNG HD082GJ
           physical id: 0.0.0
           bus info: scsi@0:0.0.0
           logical name: /dev/sda
           version: JE10
           serial: S0VPJ9CPA13399
           size: 74GiB (80GB)
           capabilities: partitioned partitioned:dos
           configuration: ansiversion=5 signature=c3f8aac4
      *-disk
           description: ATA Disk
           product: SAMSUNG HD501LJ
           physical id: 0.0.0
           bus info: scsi@2:0.0.0
           logical name: /dev/sdb
           version: CR10
           serial: S0MUJ1EPC25858
           size: 465GiB (500GB)
           capabilities: partitioned partitioned:dos
           configuration: ansiversion=5 signature=63eba0e6
    I have coloured the info that you have to match up. In the second block you can see the disc at /dev/sda1, in the first the partitions on it, and like wise for the second disc.

    Another command, that gives a slightly different result, is
    Code:
    sudo blkid -c /dev/null
    That will give you the partition name and file system type as well as the UUID.
    Last edited by audiomick; January 5th, 2010 at 11:58 AM.
    Michael

  5. #5
    Join Date
    May 2006
    Location
    Amsterdam
    Beans
    1,731
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How do I determine the UUID's of hard drive partitions?

    lshw -short gives the same information, but more compact:

    Code:
    $ sudo lshw -short | egrep "disk"
    /0/100/1f.1/0.0.0      /dev/cdrom  disk        CDRW/DVD GCCT10N
    /0/100/1f.2/0.0.0      /dev/sda    disk        80GB ST980310AS
    Upgrade Ubuntu | Upgrade unsupported Ubuntu versions | Always backup | Howto upgrade flash
    Minimal CD install | Remove old kernels | My blog | Linux user #462801 | Conscience doth make cowards of us all. -- Shakespeare

  6. #6
    Join Date
    Mar 2007
    Location
    Scotland
    Beans
    1,111
    Distro
    Ubuntu Development Release

    Re: How do I determine the UUID's of hard drive partitions?

    Quote Originally Posted by slakkie View Post
    Think you should write something yourself to get all the information needed. Probably only a few lines of shell in a function will do the trick.
    Could you help me a bit with this. Very interested but have no idea what 'a few lines of shell' and 'in a function' mean.

    I'm assuming I write some kind of script and name it but pretty much lost from there on.
    Itch: Think Hula hoop, positive on top, negative on bottom, roll it. Is it a wave or a particle? Is it a photon? Is a photon a dipole? Are we all made of light!

  7. #7
    Join Date
    May 2006
    Location
    Amsterdam
    Beans
    1,731
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How do I determine the UUID's of hard drive partitions?

    Upgrade Ubuntu | Upgrade unsupported Ubuntu versions | Always backup | Howto upgrade flash
    Minimal CD install | Remove old kernels | My blog | Linux user #462801 | Conscience doth make cowards of us all. -- Shakespeare

  8. #8
    Join Date
    Mar 2007
    Location
    Scotland
    Beans
    1,111
    Distro
    Ubuntu Development Release

    Re: How do I determine the UUID's of hard drive partitions?

    This is the definitive map of hard drives and UUIDs it seems, really good if you are having Grub2 problems too.

    http://ubuntuforums.org/showthread.php?t=1291280
    Itch: Think Hula hoop, positive on top, negative on bottom, roll it. Is it a wave or a particle? Is it a photon? Is a photon a dipole? Are we all made of light!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •