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?

  • Why not install OS X onto a USB drive and then have a faster, non-hobbled by hardware errors OS to do whatever data recovery and data transfer the existing drive allows? – bmike Mar 28 '16 at 22:14
  • @bmike - Sorry, I think my question may be somewhat unclear. I am attempting to do as you suggest - However, I have Mountain Lion on an external FW disk (en lieu of USB), which works perfectly well, but the internal drive partition needs to be unmounted first using the /etc/fstab technique`... hence the requirement for the UUID to be obtained in single user mode. Unless I open up the Mac and physically remove the drive, which I am not willing to do just yet. – Greenonline Mar 28 '16 at 22:21
  • Aah - so where you can't easily get at the drive? If you didn't have a second Mac to run target disk mode or have Disk Arbitrator on the external to block the mounting of the faulty drive this makes more sense. – bmike Mar 28 '16 at 22:25
  • 1
    @bmike - No, unfortunately I am in Thailand, and all my other Macs are in the UK. It is the Thai heat which has killed the disk. – Greenonline Mar 28 '16 at 22:28
  • @bmike - I like the sound of Disk Arbitrator though, in somewhat less unfortunate circumstances, I will certainly give that a try. – Greenonline Mar 28 '16 at 22:53
up vote 3 down vote accepted

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.

  • Yes, diskutil should work in that situation. I have booted from an installation USB key, started terminal and used diskutil to configure disks, examine disks, etc. It doesn't have a requirement for the disk to be mounted. If you did try it, and it failed, post the error. – janm Mar 23 '16 at 7:46
  • @Greenonline No, I haven't tried it from single user mode, and yes, I understand they're different. You say you tried it; did you get an error message? If so, what was it? – janm Mar 27 '16 at 21:38
  • @Greenonline I qualified the diskutil part of response more; I haven't tried it in single user mode and I don't know whether it depends on a daemon. I do know that it works on a disk that isn't mounted. Very curious to know what error message you received. – janm Mar 27 '16 at 21:42
  • ioreg -c IOMedia -r unfortunately still scrolls too much data too quickly, in the same way that as ioreg -l on its own just scrolls streams of unreadable data up the screen, and using it in conjunction with |more just causes illegible binary data to be displayed, for some reason. ioreg -c IOMedia -r | grep UUID followed by ioreg -c IOMedia -r | grep disk fits on screen and one can correlate the two results, thereby linking the disks and the UUIDs. However, strangely, ioreg -l | grep UUID followed by ioreg -l | grep disk has better formatting and is actually easier to read. – Greenonline Mar 28 '16 at 22:39
  • 1
    @Greenonline Indeed -- fstab seems to need a volume UUID rather than a device UUID. Answer updated. – janm Mar 30 '16 at 23:59

Install GPT Fdisk. After booting to Single User Mode enter:

/sbin/fsck -fy
/sbin/mount -uw /
/usr/local/bin/gdisk

In interactive mode first enter the device node (e.g. disk0):

/dev/disk0

then i to show detailed information on a partition.
Finally enter the partition number e.g. 5 to get the Partition unique GUID:

Partition GUID code: 53746F72-6167-11AA-AA11-00306543ECAC (Apple Core Storage)
Partition unique GUID: 7AA0FD56-01BC-4EA1-8CE2-7972E63A2A6D
First sector: 409640 (at 200.0 MiB)
Last sector: 133955543 (at 63.9 GiB)
Partition size: 133545904 sectors (63.7 GiB)
Attribute flags: 0000000000000000
Partition name: ''
  • Unfortunately, I can not install anything as the corrupted partition on the internal disk renders the Mac inoperable. I can, currently, only boot into single user mode. I need a built-in command. However, ioreg -l | grep UUID;ioreg -l | grep disk seems to do the trick. – Greenonline Mar 28 '16 at 2:34

As an aside, I have just discovered that there is no actual need to do any of this, because, en lieu of using the UUID, you can use the volume label instead, in /etc/fstab, like so:

LABEL=Archive none hfs rw,noauto 0 0

This method has the benefit of:

  1. Being much simpler to implement, and more importantly;
  2. The volume label does not change, whereas the UUIDs change as you plug in other FW or USB disks. So, if you are using UUIDs in /etc/fstab then you need to update those UUIDs for the unmounted disks, in /etc/fstab, each time you change the disk configuration.

Note: The use of the LABEL in /etc/fstab, may not always work (i.e. if the disk is very corrupted and the label can not be read). In such cases, you will be obliged to use UUID.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.