Mounting an external APFS volume by name?

I have some old "Execute Shell Script" code that I wrote a long time ago, and it has worked fine for mounting external drives by volume name, like this:

diskutil quiet mount "$KMVAR_mdinDriveName"

Now I have an external drive that has 2 partitions, one APFS and the other APFS Case Sensitive.

When I use my old diskutil code, it doesn't find the volumes. And when I look at them in Disk Utility, they're inside "containers"

Anyone know how I can mount these in a shell script?

To mount a partition on my network drive and other volumes on my network, I use an Execute AppleScript action with the single command:

mount volume "smb://[volume]/[partition]"

To mount an external drive I use the Open action with /Volumes/[name]].

sh to get names

diskutil list

Try

driveName="$KMVAR_mdinDriveName"
volumeID=$(diskutil info -all | awk -v name="$driveName" '
/^   Volume Name:/ {volName = $3; if ($0 ~ name) matched=1}
/^   Device Identifier:/ {if (matched) {print $3; exit}}
{matched=0}')

if [ -n "$volumeID" ]; then
    diskutil quiet mount "$volumeID"
else
    echo "Volume '$driveName' not found"
fi

Still working for me, Dan -- just tested in macOS 15.4.1 with a freshly partitioned external with APFS and APFS Case Sensitive volumes.

Have you tried in Terminal?