View volume using UUID

I know the volume UUID - how it is installed in Disk Utility.

How to get additional volume information? Most importantly, I want to know its mount point.

Looking at / etc / fstab, it does not do the trick. This list does not have a root volume. At the very least, I would need to calculate the UUID of the root volume in order to check my known UUID for it.

+4
source share
2 answers

You can use diskutil to search for a drive by its UUID, and the -plist option to get output on a machine is a transparent format:

% diskutil info /Volumes/RAM\ Disk | grep -F UUID Volume UUID: EA20BE94-5F3C-3C02-901D-A213B5AB6831 % diskutil info -plist EA20BE94-5F3C-3C02-901D-A213B5AB6831 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <!--snip--> <key>MountPoint</key> <string>/Volumes/RAM Disk</string> <!--snip--> </dict> </plist> 

You can use NSTask and NSPipe to start diskutil from your program and capture output.

Appendix: not all volumes have a UUID. My camera has a built-in read-only MS-DOS format that does not have a UUID according to Disk Utility and diskutil. So make sure your program can handle empty output from the diskutil info … | grep pipeline above diskutil info … | grep diskutil info … | grep .

+8
source

There are several ways to do this. If you need a list of all the UUIDs on your system, you can usually look at / dev / disk / by -uuid /.

This folder contains symbolic links that map uuids to device locations. On my system, it displays as follows:

 [ sean@vladimir ~]$ ls -al /dev/disk/by-uuid/ total 0 drwxr-xr-x 2 root root 300 2010-02-02 22:42 . drwxr-xr-x 6 root root 120 2010-02-02 22:42 .. lrwxrwxrwx 1 root root 10 2010-02-02 22:42 02123883-6538-4c74-bc74-362eb2588d2b -> ../../sdc4 lrwxrwxrwx 1 root root 10 2010-02-02 22:42 1ce37cd8-52b0-4442-98b5-3702194644f2 -> ../../dm-5 lrwxrwxrwx 1 root root 10 2010-02-02 22:42 1d718419-8175-446c-a01b-51e895d59467 -> ../../sdc7 lrwxrwxrwx 1 root root 10 2010-02-02 22:42 382a64d7-68fe-45a3-87d3-ae7b7a861067 -> ../../dm-1 lrwxrwxrwx 1 root root 10 2010-02-02 22:42 47ab8e51-4023-4bec-a888-576879fba2dd -> ../../sdc1 lrwxrwxrwx 1 root root 10 2010-02-02 22:42 5b4e6b94-f7c7-40c1-a4ee-ca555efc97df -> ../../dm-4 lrwxrwxrwx 1 root root 10 2010-02-02 22:42 6d1df3de-b408-4942-a2e3-78244a68cece -> ../../dm-0 lrwxrwxrwx 1 root root 10 2010-02-02 22:42 c7f841db-8b38-403e-9bcc-926c18deadfc -> ../../sdc6 lrwxrwxrwx 1 root root 10 2010-02-02 22:42 db3f2c47-e29d-4b33-a462-6230ed2bcea8 -> ../../dm-2 lrwxrwxrwx 1 root root 10 2010-02-02 22:42 e5bd9df3-65f7-4815-839f-8b5fad82bc50 -> ../../sdc5 lrwxrwxrwx 1 root root 10 2010-02-02 22:42 ea28833b-fa7b-465d-992b-c333b288233b -> ../../sda1 lrwxrwxrwx 1 root root 10 2010-02-02 22:42 ebb72c56-8776-4e7d-ace9-fc727239f999 -> ../../sda2 lrwxrwxrwx 1 root root 10 2010-02-02 22:42 fd75f53b-6058-467b-9e0f-0a725e7bc83e -> ../../dm-3 

Alternatively, you can run "blkid / path / to / dev" for each of your devices to find what you are looking for. Similarly, on my system, it looks like this:

 [ sean@vladimir ~]$ blkid /dev/sda1 /dev/sda1: LABEL="restore" UUID="ea28833b-fa7b-465d-992b-c333b288233b" TYPE="ext4" 

Hope this helps.

-3
source

Source: https://habr.com/ru/post/1301537/


All Articles