Jump to content

Mount Disks — Mount and unmount disk partitions


Recommended Posts

Posted

apologies this is such a pain. That undefined volume is always connected and this all started after a fresh boot. I will reboot, revert, and report back.

Posted
8 minutes ago, sepulchra said:

Apologies this is such a pain.

 

No need to apologise, not your fault!

 

8 minutes ago, sepulchra said:

That undefined volume is always connected and this all started after a fresh boot.

 

Alright, that does suggest something became wonky from macOS’ side. I should’ve started by suggesting the reboot but thought we might get it worked around another way. In retrospect that wouldn’t be desirable, because it would mean you wouldn’t see the drive anyway which wouldn’t be what you want. All this makes it very hard to debug. But again, not your fault, diagnosing hardware by talking over the internet is quite a challenge.

 

8 minutes ago, sepulchra said:

I will reboot, revert, and report back.

 

Also try disconnecting it and connecting it back, or making other interactions in general. It seems that for some reason macOS is not correctly seeing/reporting one or more of the partitions.

Posted

I think I do owe you an apology because this is clearly some kind of edge case. I have another M1 machine running 14.5 and I should have tested that earlier in this process. The workflow from the gallery is working fine on that machine (M1 MBP). Let me do some more investigating on my M1 mac studio and see what I can find. Again. Sorry for making you spin your wheels. 

Posted
3 hours ago, vitor said:

 

No, but that’s to be expected. jq looks to be designed specifically with that in mind and do one thing: handle JSON. So any general solution will have to be more verbose. The advantage being that they’re bundled with macOS instead of being an external dependency like jq.

That's fair.

 

As an example I'd like to remove the dependency on jq in my Moby Games workflow: https://www.alfredforum.com/topic/21983-moby-games-workflow/

 

Posted

That uses jq a lot, so rather than try to make some commands use something else, I’d instead rewrite it in osascript (JavaScript). To replace the curl command, you can use something like this:

 

function curlMoby(gameTitle, apiKey) {
  const task = $.NSTask.alloc.init
  const stdout = $.NSPipe.pipe

  task.executableURL = $.NSURL.fileURLWithPath("/usr/bin/curl")
  task.arguments = [
    "--get",
    "--data-urlencode", "format=normal",
    "--data-urlencode", "limit=9",
    "--data-urlencode", `title=${gameTitle}`,
    "--data-urlencode", `api_key=${apiKey}`,
    "https://api.mobygames.com/v1/games"
  ]
  task.standardOutput = stdout
  task.launchAndReturnError(false)

  const dataOut = stdout.fileHandleForReading.readDataToEndOfFileAndReturnError(false)
  const stringOut = $.NSString.alloc.initWithDataEncoding(dataOut, $.NSUTF8StringEncoding).js

  return JSON.parse(stringOut)
}

 

Which should return an object from the upstream JSON which you can then manipulate normally, construct the Script Filter object from there then JSON.strigify it. It does assume some basic knowledge of JavaScript for the next part (that code uses the Objective-C bridge, which you shouldn’t need to use for the rest of the workflow).


That is, naturally, untested. I don‘t have an API key to confirm, and don’t feel too comfortable that the data has to be sent as a string in that key=value format, but I haven’t checked the API to see if there’s an alternate way to do it.

Posted
2 hours ago, vitor said:

Also try disconnecting it and connecting it back, or making other interactions in general. It seems that for some reason macOS is not correctly seeing/reporting one or more of the partitions.

Well reseating connections didn't work. updating the OS to 14.5 didn't work, but moving that one volume to a different thunderbolt port did the trick.

Posted
48 minutes ago, sepulchra said:

but moving that one volume to a different thunderbolt port did the trick.

 

Huh. Have you tried connecting another disk to that port and seeing what happens?

Posted
6 minutes ago, vitor said:

 

Huh. Have you tried connecting another disk to that port and seeing what happens?

still works as intended with another drive in that port.. Well that is weird one. And know as an audio person who troubleshoots hardware, i did each step "one at a time" to chase it. When i finish my deadline today, i'll move that original volume back and see if it recurs. What an odd one!

Posted (edited)

i'm on day 2 of running back in the original tb port and still no issues so this one is a bit of a mystery. Thanks again for your time, Vitor.

Edited by sepulchra
  • 2 weeks later...
Posted

Hey @vitor!

First, thanks for all of the great work you contribute to Alfred and the community. Second, should this workflow mount encrypted disks and trigger the standard password prompts for the disk as you would get if you mounted the disk through Disk Utility or diskutil in the shell? I ask because in my testing, my encrypted external drives are detected by the workflow, but it silently fails to mount them and encryption seems to be the common factor.  The drives work fine with Disk Utility and diskutil commands. 

  • 2 months later...
  • 2 weeks later...
  • 1 month later...
Posted
On 7/7/2024 at 12:56 AM, Shraden said:

Hey @vitor!

First, thanks for all of the great work you contribute to Alfred and the community. Second, should this workflow mount encrypted disks and trigger the standard password prompts for the disk as you would get if you mounted the disk through Disk Utility or diskutil in the shell? I ask because in my testing, my encrypted external drives are detected by the workflow, but it silently fails to mount them and encryption seems to be the common factor.  The drives work fine with Disk Utility and diskutil commands. 

Hi @vitor. Just wanted to bump my question from earlier. When running /usr/sbin/diskutil mount in Terminal directly it will generate an error that the volume is encrypted and should be mounted with /usr/sbin/diskutil apfs unlockVolume instead. I tried playing around with it a bit, but I wasn't able to get the expected password prompt from the command to trigger. I assume that would require adding another object type in the Alfred workflow I haven't discovered yet. Would you be willing to add a check in the main javascript script to have it check if the volume is encrypted and have it run the apfs unlockVolume command as an alternative path in the workflow? I don't know my way around js at all, so I haven't tried to modify that yet.

Either way, I appreciate this workflow and the many others you provide to the community. I think adding support for encrypted volumes would be a great addition to the utility of this workflow. 

Posted

Thank you for the kind words.

 

Unfortunately, I just double-checked and don’t have any disk I could convert to an APFS encrypted volume to test. However, from your description there may be an easy solution.

 

1 hour ago, Shraden said:

I don't know my way around js at all, so I haven't tried to modify that yet.

 

You don’t need any JavaScript, all the mounting is done in shell, in a single line in the Run Script at the top (second object from the top left). Go there and change the code from:

 

/usr/sbin/diskutil mount "${1}"

 

to

 

/usr/sbin/diskutil mount "${1}" || /usr/sbin/diskutil apfs unlockVolume "${1}"

 

That will make it so that any error on trying to normally mount will then try to do the unlock. Not robust enough to release for everyone but might cover your case. But like I said, I don’t have a way to test. If, e.g., the prompt that it shows is in the terminal and not a GUI, that won’t work. From the documentation (which you can access by running man -P 'less --pattern "unlockVolume | unlock volumeDevice"' diskutil in a terminal) there seems like you can use a specific keychain to do read it, which might work.

 

But again, I can’t test myself and trying to fix these disk oddities over the internet is frustratingly difficult. You don’t see it because I’ve hidden them as they’re no longer relevant, but there’s been more than one page of back and forth and commands and parsing on this thread just to figure out one specific thing previously. I’m not keen to repeat that.

Posted

Just wanted to post a quick "thank you" to @vitor for this. After (once again) forgetting that doing an "eject all" on my system clone will eject the other volumes on the Thunderbolt chain, I thought "there must be a way to re-mount those volumes without having to go to Disk Utility", and found my way here. Alfred remains overwhelmingly a launcher for me, as most of what I do isn't terribly complex or automate-able, but it's nice to have a handy workflow for something like this.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...