2

I have an external hard drive connected to my cinema display. I don't use the hard drive every time I connect my laptop to the display. However, I forget to unmount it almost every time I disconnect my laptop.

To avid incorrect disconnecting I disabled automounting in fstab as described here: How to Disable USB Auto-mount

Now it's hard to mount the drive as I have to go to DiskUtility. Is it possible to see the connection but not mounted hard drives in the Finder sidebar and have them mounted when the sidebar entry is selected? (the same way it works with the things shared on network)

2 Answers 2

2

To answer the question, no Finder does not offer that preference or option, however there is a workaround.

I have a similar situation and I use an AppleScript script saved as an application that mounts the unmounted target volume when I want, without having to go into Disk Utility to do it.

I have this app on the Toolbar in Finder, with the same icon as shown on the drive, so it's easy to just click it. It could be placed on the Dock or Desktop, etc. At times I access it from Spotlight too. Lots of options, even using the code in an Automator Service workflow and assigning it a keyboard shortcut if you want.

set theVolumeName to "TOSHIBA EXT"
try
    do shell script "diskutil mount $(diskutil list | awk '/" & theVolumeName & "/{print $NF}')"
on error eStr number eNum
    if eNum is 1 then
        display dialog "The disk containing the\"" & theVolumeName & "\" volume is not available." buttons {"OK"} ¬
            default button 1 with title "Check Disk Connection & Power Status" with icon 0
    else
        display dialog eStr & " number " & eNum buttons {"OK"} default button 1 with title "Error Status" with icon 0
    end if
end try

Notes:

  • Change set theVolumeName to "TOSHIBA EXT" so "TOSHIBA EXT" is the name of the target mounted volume.
  • This script assumes there is and will only be one volume with the target name. If not, then the awk command will need to be modified to accommodate.

Understanding what the do shell script command is doing:

do shell script "diskutil mount $(diskutil list | awk '/" & theVolumeName & "/{print $NF}')"
  • do shell script - Executes a shell script using the sh shell.
  • diskutil mount device - Mount a single volume.
  • $(...) - Command Substitution. - Command substitution allows the output of a command to replace the command name. In this case it will be device in: diskutil mount device
  • diskutil list - List disks. If no argument is given, then all disks and all of their partitions are listed.
  • | - Pipe the output of the previous command to the next command.
  • awk '/" & theVolumeName & "/{print $NF}' - The example will be:
    awk '/TOSHIBA EXT/{print $NF}'
    • awk - Pattern-directed scanning and processing language.
    • /TOSHIBA EXT/ - Search pattern. Outputs the record (line) containing the search pattern. In this example it matched:
      1: Windows_NTFS TOSHIBA EXT 2.0 TB disk1s1
    • {print $NF} - Prints the last field of the record. Which printed: disk1s1

The following is example output in Terminal:

$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *751.3 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            750.4 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *2.0 TB     disk1
   1:               Windows_NTFS TOSHIBA EXT             2.0 TB     disk1s1
$ diskutil list | awk '/TOSHIBA EXT/{print $NF}'
disk1s1
$ diskutil mount $(diskutil list | awk '/TOSHIBA EXT/{print $NF}')
Volume TOSHIBA EXT on disk1s1 mounted
$ 

So it finds the device for the diskutil mount device command regardless of how many disks are attached to the system.

-1

No, but you could use Terminal: diskutil list is the command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .