通过 UUID 查找卷
我知道卷的 UUID - 可在“磁盘工具”中找到。
如何获取有关该卷的更多信息? 最重要的是,我想知道它的挂载点。
查看 /etc/fstab 并不能解决问题。这不会列出根卷。我至少需要找出根卷的 UUID 来验证我已知的 UUID。
I know the UUID of a volume - as found in Disk Utility.
How can I get additional information on the volume?
Most importantly, I want to know its mount point.
Looking at /etc/fstab doesn't do the trick. This does not list the root volume. I would at least need to figure out the UUID of the root volume to verify my known UUID against it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 diskutil通过 UUID 查找磁盘,并使用 -plist 选项以机器可解析的格式获取输出:
您可以使用 NSTask 和 NSPipe 从程序中运行 diskutil 并捕获输出。
附录:并非所有卷都有 UUID。我的相机有一个内置的只读 MS-DOS 格式卷,根据磁盘工具和 diskutil,该卷没有 UUID。因此,请确保您的程序可以处理上述 diskutil info 的空输出... | grep 管道。
You can use diskutil to look up the disk by its UUID, and the -plist option to get the output in a machine-parseable format:
You can use NSTask and NSPipe to run diskutil from within your program and capture the output.
Addendum: Not all volumes have UUIDs. My camera has a built-in read-only MS-DOS-formatted volume that has no UUID according to Disk Utility and diskutil. So, make sure your program can handle empty output from the above
diskutil info … | grep
pipeline.有几种方法可以做到这一点。如果您想要系统中所有 UUID 的列表,通常可以查看 /dev/disk/by-uuid/ 。
此文件夹包含将 uuid 映射到设备位置的符号链接。在我的系统上,它映射如下:
或者,您可以为每个设备运行“blkid /path/to/dev”,以查找您要查找的设备。同样,在我的系统上它显示为:
希望有帮助。
There are a couple of ways you can do it. If you want a list of all the UUIDs in your system you can typically look at /dev/disk/by-uuid/ .
This folder contains a symbolic link mapping uuids to device locations. On my system it maps as the following:
Alternatively, you can run 'blkid /path/to/dev ' for each of your devices to find which is the one you are looking for. Likewise, on my system it appears as such:
Hope that helps.