Disk Utility – Command Line Equivalent to Obtain UUID

disk-utilitymacospartition

Following on from the answer to Can you make OSX mount just certain partitions when you connect an external HDD?, all of the sites that I have checked (CNET, OSXDaily, Apple Support community threads) say that you have to use Disk Utility (or the command line diskutil info /dev/disk<X>s<Y>) to find the UUID.

Is there a command line equivalent that will give me this information, which is not diskutil? In particular, one that will work in single user mode?

Why diskutil does not work

In single user mode (at least on Mountain Lion) after running:

/sbin/fsck -fy
/sbin/mount -uw /

running:

diskutil info disk0s5

gives the following error

Unable to run because unable to use the DiskManagement framework.
Common reasons include, but are not limited to, the DiskArbitration
framework being unavailable due to being booted in single user mode.

Background

My issue is that I have a dying partition on my internal disk, which only holds an out of date Snow Leopard OS, but is slowing down my Mac (unbearably), as the console is (repeatedly) reporting:

kernel: disk0s5: I/O error.

I no longer boot into Snow Leopard as I boot Mountain Lion which is on an external FireWire disk, so I would like to leave the Snow Leopard partition unmounted, using the line

UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX none hfs rw,noauto

in /etc/fstab.

However, to obtain the UUID of the faulty partition, I have to open up Disk Utility and have the faulty partition mounted, which is a torturously slow process (it takes Disk Utility about twenty minutes to open).


TL;DR
Can I obtain the UUID of the internal partition, when booting into single user mode of an OS stored on a partition which is on an external FW disk?

Best Answer

Update:

IOReg gives the partition UUID, not the volume UUID, as it operates below the HFS layer. I had incorrectly assumed that the device UUID was required rather than the volume UUID because it was substituting for a device node. To get the volume UUID, use hfs.util. For example:

/System/Library/Filesystems/hfs.fs/Contents/Resources/hfs.util -k disk0s3

Replace "disk0s3" with whatever the "device identifier" of your volume. This is different to the "device node" (which is "/dev/disk0s3" in this case").

Original IOReg details:

You can run ioreg -c IOMedia -r to show the device tree for the disk devices in your system. This should give a manageable amount of output (as compared to ioreg -l, which shows everything).

If you want to just extract UUIDs, you can ioreg -c IOMedia -r | grep UUID, but the downside is that you lose context.

The diskutil information is interesting; it obviously depends on daemons that do not run in single user mode.