Since macOS 10.15 (Catalina), a volume, as the user sees it, may actually be comprised of multiple volumes, such as the System and the Data volume.
I'm writing a tool that needs to identify these volumes separately because when using specific file operations, such as searchfs
and fts_read
, which do not cross such volume boundaries, I need to understand which volumes belong together, so that, when the user wants to search a system volume, I know to include both the "System" and its "Data" volumes in the file operations.
How do I safely determine which volumes belong together?
Using [NSFileManager mountedVolumeURLsIncludingResourceValuesForKeys:options:]
is not much help alone because it won't include the root system's Data volume at /System/Volumes/Data
(but may include the hidden /System/Volumes/Data/home
volume). Same goes for using command line tools such as df
.
I need to consider other system volumes that are not currently booted. E.g, if I have both a BigSur and a Catalina system, and have started up from the former, I want to be able to identify these four volumes:
/ BigSur System volume
/System/Volumes/Data BigSur Data volume
/Volumes/Catalina Catalina System volume
/Volumes/Catalina - Daten Catalina Data volume (created on a German system)
How would I tell that the two volumes containing "Catalina" actually belong to the same group? I don't like to match them up by partial names as this seems rather random and unreliable to me. And the fact that the data volume is not even using "Data" in the name if it's not created on an English system makes this already much too difficult to get right.
Is there perhaps some other volume property that would help identify these volume groups?
Use
diskutil list
to check the Volumes and their names.system_profiler
display much information but you must parse the ouput for the Volume information, usingsystem_profiler -xml > output.xml
will create a file for understanding the available values for specific queries.