Answers:
以下命令显示有关已安装卷的信息:
mount
,显示例如/dev/disk5s3
安装在/Volumes/Foo
diskutil list
显示所有磁盘和卷的概述diskutil info /dev/disk5s3
显示有关该卷的信息,包括Volume UUID
可用于唯一标识该卷的信息。您可以diskutil info
使用卷的UUID 进行查询:
$ diskutil info DEC8759E-F77D-3EAE-B3EB-B6438F1AA428 | grep 'Mount Point'
Mount Point: /Volumes/DroboOne
我的系统上的示例命令输出:
$ mount
/dev/disk1 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
localhost:/bNqIvVr1ZdFBdf19Io81Q4 on /Volumes/MobileBackups (mtmfs, nosuid, read-only, nobrowse)
/dev/disk4 on /Volumes/MyBook (hfs, local, nodev, nosuid, journaled)
/dev/disk5s3 on /Volumes/DroboOne (hfs, local, nodev, nosuid, journaled, noowners)
/dev/disk7s3 on /Volumes/DroboTwo (hfs, local, nodev, nosuid, journaled, noowners)
/dev/disk6s3 on /Volumes/DroboThree (hfs, local, nodev, nosuid, journaled, noowners)
$ diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *256.1 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_CoreStorage 240.0 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: Apple_HFS Servus10 HD *239.7 GB disk1
/dev/disk2
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *3.0 TB disk2
1: EFI 209.7 MB disk2s1
2: Apple_CoreStorage 3.0 TB disk2s2
3: Apple_Boot Boot OS X 134.2 MB disk2s3
/dev/disk4
#: TYPE NAME SIZE IDENTIFIER
0: Apple_HFS MyBook *3.0 TB disk4
/dev/disk5
#: TYPE NAME SIZE IDENTIFIER
0: Apple_partition_scheme *2.2 TB disk5
1: Apple_partition_map 32.3 KB disk5s1
2: Apple_HFS DroboOne 2.2 TB disk5s3
/dev/disk6
#: TYPE NAME SIZE IDENTIFIER
0: Apple_partition_scheme *2.2 TB disk6
1: Apple_partition_map 32.3 KB disk6s1
2: Apple_HFS DroboThree 2.2 TB disk6s3
/dev/disk7
#: TYPE NAME SIZE IDENTIFIER
0: Apple_partition_scheme *2.2 TB disk7
1: Apple_partition_map 32.3 KB disk7s1
2: Apple_HFS DroboTwo 2.2 TB disk7s3
$ diskutil info /dev/disk5s3
Device Identifier: disk5s3
Device Node: /dev/disk5s3
Part of Whole: disk5
Device / Media Name: Untitled
Volume Name: DroboOne
Escaped with Unicode: DroboOne
Mounted: Yes
Mount Point: /Volumes/DroboOne
Escaped with Unicode: /Volumes/DroboOne
File System Personality: Journaled HFS+
Type (Bundle): hfs
Name (User Visible): Mac OS Extended (Journaled)
Journal: Journal size 172032 KB at offset 0x4001000
Owners: Disabled
Partition Type: Apple_HFS
OS Can Be Installed: No
Media Type: Generic
Protocol: FireWire
SMART Status: Not Supported
Volume UUID: DEC8759E-F77D-3EAE-B3EB-B6438F1AA428
Total Size: 2.2 TB (2198888927232 Bytes) (exactly 4294704936 512-Byte-Blocks)
Volume Free Space: 169.4 GB (169412173824 Bytes) (exactly 330883152 512-Byte-Blocks)
Device Block Size: 512 Bytes
Read-Only Media: No
Read-Only Volume: No
Ejectable: Yes
Whole: No
Internal: No
man diskutil
会有所帮助的。
diskutil
未本地化。
我在一个变量中检索它:
media=\`df | grep "media" | awk '{print $6}'\`
要么
media=$(df | awk '/media/ {print $6}')
该df
命令列出了分区,结果输出通过管道传递到grep命令的输入,该命令过滤并仅保留包含单词media的行,然后将管道通过管道传递给awk
仅保留其一行输入的第六列的命令。
/media/
参数化的正则表达式并不清楚。尝试media=$(df | awk -v regex="$regex" '$1 ~ regex { print $6 }')
将shell变量$regex
作为要搜索的内容传递。
我只会为此使用fstab。在超级用户:Mac Lion上,有一个与此主题相关的主题:fstab已弃用。那么什么替代它以防止安装分区?
fstab
这个,到底是什么?
我最终使用了这个bash脚本:
#!/bin/sh
#
# Retrieves the mount point of an OSX volume name or UUID.
# @param $1 Name of the volume or UUID of the volume.
# @return returns the mount path or an empty string if the volume is not mounted.
#
diskutil info $1 | grep 'Mount Point' | cut -d : -f 2 | sed 's/^ *//g' | sed 's/ *$//g';
/Volumes/…
,这是每个人都在谈论的内容,如果我正确阅读此问题。