Linux HowTo: Is there any way to re-mount an ejected USB device on a Mac?

Original Source Link

I wanted to know if is possible to mount a USB device after it has been removed from the Finder, without having to re-insert it into the USB port.

On my Mac I connected a USB device, but sometimes after putting the Mac suspended, the USB is no longer detected, and then I take it out and insert it again.

Is there any command line to reactivate? I tried with diskutil mountDisk but it does not work, as if the USB device is removed physically from Mac.

I wanted to know if is possible to mount a USB device after it has
been removed from the Finder, without having to re-insert it into the
USB port.

If you are talking about USB devices in general? The answer is yes and no depending on the type of device ejected: Yes if it is a mounted hard drive—or SSD drive—but no if it is a USB flash drive. Details below.

Works for USB Hard Disk Drives

Ejecting a USB hard disk drive and attempting to remount it with diskutil mountDisk.

For example, here is example diskutil list output from my Mac OS X 10.9.5 (Mavericks) machine with one USB external hard drive connected and one USB flash drive connected:

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Hard Drive              499.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                  Apple_HFS External Hard Drive     2.0 TB     disk2s2
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *8.0 GB     disk3
   1:                        EFI EFI                     209.7 MB   disk3s1
   2:                  Apple_HFS USB Flash Drive         7.7 GB     disk3s2

Okay, so now I go ahead and eject the “External Hard Drive” and check diskutil list again and the output looks 100% the same as mounted:

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Hard Drive              499.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                  Apple_HFS External Hard Drive     2.0 TB     disk2s2
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *8.0 GB     disk3
   1:                        EFI EFI                     209.7 MB   disk3s1
   2:                  Apple_HFS USB Flash Drive         7.7 GB     disk3s2

So now if I wanted to remount “External Hard Drive” I would just need to note the partition identifier for “External Hard Drive” (disk2s2) and run this command:

diskutil mountDisk /dev/disk2s2

Wait for the process to complete and the volume will be mounted as expected.

Doesn’t Work for USB Flash Drives

Ejecting a USB flash drive and attempting to remount it with diskutil mountDisk.

But if I go ahead and eject the “USB Flash Drive” and then run diskutil list again, “USB Flash Drive” is removed from the list:

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Hard Drive              499.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                  Apple_HFS External Hard Drive     2.0 TB     disk2s2

And even if I attempt to mount that USB flash drive knowing the mount point from the previous list like this:

diskutil mountDisk /dev/disk3s2

The system says:

Unable to find disk for /dev/disk3s2

What explains this discrepancy in behavior? Unsure. But what it boils down to is if the USB device is a hard disk drive or SSD and it shows up in the list returned by diskutil list, then you should have no problems remounting the USB device. But if it is a USB flash drive and doesn’t show up in that list? It can’t be remounted unless the USB flash drive is physically unplugged and replugged-in again.

Works for USB Flash Drives

Unloading and reloading the USB mass storage kernel extension (IOUSBMassStorageClass.kext).

All of that said, the comment on this answer by Jannis Linxweiler explains how if you unload and reload the USB mass storage kernel extension (IOUSBMassStorageClass.kext) you can effectively get the USB flash drive to remount without physically unplugging it.

Tested this on my Mac OS X 10.9.5 (Mavericks) machine and it works as expected.

First, eject the USB flash drive and then run this command to unload IOUSBMassStorageClass.kext:

sudo kextunload /System/Library/Extensions/IOUSBMassStorageClass.kext

Then run this command to reload the IOUSBMassStorageClass.kext:

sudo kextload /System/Library/Extensions/IOUSBMassStorageClass.kext

Did that and my USB flash drive came back up without physically touching it. Neat trick! And it does not impact connected USB hard disk drives from what I can tell.

Tagged : / /

Leave a Reply

Your email address will not be published. Required fields are marked *