syscl / Fix-usb-sleep

Fix issue of "Diks not ejected properly upon sleep" on macOS
71 stars 20 forks source link

Disk Not Ejected error messages persist after installing from script #7

Open ralexx opened 8 years ago

ralexx commented 8 years ago

First, thank you for working on this.

I use two different drive enclosures connected to USB 3.0 host adapters installed in the PCIe 2.0 x4 slots (3 and 4) in my 5,1 Mac Pro running 10.11.6. Below is the Console log from a wake/sleep cycle that generated "Disk Not Ejected" error messages earlier today after I had installed your script successfully.

It seems that the OS is trying to write to the journal on the logical drive disk8s2 and cannot find it. Could this be the source of the error message? I'm not familiar with how sleepwatch handles such an event.

$ diskutil list
[...]
/dev/disk8 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *3.0 TB     disk8
   1:                        EFI EFI                     209.7 MB   disk8s1
   2:                  Apple_HFS media backup            3.0 TB     disk8s2
11/24/16 7:30:18.000 AM kernel[0]   RTC: Maintenance 2016/11/24 15:30:17, sleep 2016/11/24 13:42:20
11/24/16 7:30:18.000 AM kernel[0]   Previous sleep cause: 5
11/24/16 7:30:18.000 AM kernel[0]   005865.731832 AppleUSB20HubPort@00440000: AppleUSBHostPort::willTerminate: 
11/24/16 7:30:18.000 AM kernel[0]   005865.731838 AppleUSB20HubPort@00440000: AppleUSBHostPort::willTerminateThreadCall: 
11/24/16 7:30:18.000 AM kernel[0]   005865.731840 AppleUSB20HubPort@00440000: AppleUSBHostPort::willTerminateThreadCallGated: 
11/24/16 7:30:18.000 AM kernel[0]   005865.731842 AppleUSB20HubPort@00440000: AppleUSBHostPort::willTerminateThreadCallCompleteGated: 
11/24/16 7:30:18.000 AM kernel[0]   005865.731876 AppleUSB20HubPort@00440000: AppleUSBHostPort::didTerminate: 
11/24/16 7:30:18.000 AM kernel[0]   005865.731901 AppleUSB20HubPort@00440000: AppleUSBHostPort::didTerminateThreadCall: 
11/24/16 7:30:18.000 AM kernel[0]   005865.731904 AppleUSB20HubPort@00440000: AppleUSBHostPort::didTerminateThreadCallGated: 
11/24/16 7:30:18.000 AM syslogd[47] ASL Sender Statistics
11/24/16 7:30:18.000 AM kernel[0]   disk8s2: media is not present.
11/24/16 7:30:18.000 AM kernel[0]   jnl: disk8s2: do_jnl_io: strategy err 0x6
11/24/16 7:30:18.000 AM kernel[0]   jnl: disk8s2: end_transaction: only wrote 0 of 36864 bytes to the journal!
11/24/16 7:30:18.000 AM kernel[0]   hfs: unmount initiated on media backup on device disk8s2
11/24/16 7:30:18.000 AM kernel[0]   jnl: disk8s2: close: journal is invalid.  aborting outstanding transactions
11/24/16 7:30:18.000 AM kernel[0]   005865.900517 AppleUSB20HubPort@00440000: AppleUSBHostPort::stop: 
11/24/16 7:30:18.000 AM kernel[0]   005865.901306 AppleUSB20HubPort@00440000: AppleUSBHostPort::stopThreadCall: 
11/24/16 7:30:18.000 AM kernel[0]   005865.901313 AppleUSB20HubPort@00440000: AppleUSBHostPort::stopThreadCallGated: 
11/24/16 7:30:18.000 AM kernel[0]   005865.901327 AppleUSB20HubPort@00440000: AppleUSBHostPort::stopThreadCallCompleteGated: 
11/24/16 7:30:18.000 AM kernel[0]   USB device 387355AA00440000 - PortLogging ( Disable ) = kIOReturnNotReady.
11/24/16 7:30:18.235 AM fseventsd[51]   disk logger: failed to open output file /Volumes/media backup/.fseventsd/636573ab6115211a (No such file or directory). mount point /Volumes/media backup/.fseventsd
11/24/16 7:30:18.235 AM fseventsd[51]   disk logger: failed to open output file /Volumes/media backup/.fseventsd/636573ab6115211a (No such file or directory). mount point /Volumes/media backup/.fseventsd
syscl commented 8 years ago

syscl

ralexx commented 8 years ago

Thank you 周总. That's already very helpful and I'm pretty sure you have more important things to do than help me troubleshoot hardware issues. I appreciate your thoughtfulness.

syscl commented 8 years ago

I don't think you should close this issue since solving this issue do help others who suffer similar issues.

syscl

ralexx commented 8 years ago

@syscl, I closed the issue because that particular external drive housing has other issues I am working on with the manufacturer. My second external drive housing correctly shows the same disk as external, and anyway the the CPU has stopped sleeping while the external drive is mounted in the second housing.

At your suggestion I will leave this open and update as appropriate. Meanwhile, since you asked, here are sysinfo Storage and USB tabs, diskutil info and ioreg. File names with 'dock' in them refer to the second external drive housing referred to above.

sysinfo-usb-storage-dock.txt diskutil-info-dock.txt ioreg.txt sysinfo-usb-storage-housing.txt diskutil-info-housing.txt ioreg_short.txt

syscl commented 7 years ago

@ralexx thanks for your details, I found a new way to fix your issue, will soon let you know.

Again, I'm very appreciate your detail report.

Thanks, syscl

syscl commented 7 years ago

I have changed to code to try to fix this issue, but I have to go outside now, will upload tonight;)

syscl

syscl commented 7 years ago

@ralexx try the latest update I made.

Wait for your feedback, good luck! syscl

ralexx commented 7 years ago

@syscl,

Now running macOS 10.12.4. Applied your updated script and sleep. Drives on PCIe USB card still show "Disk Not Ejected" error.

Is this log message meaningful? com.apple.xpc.launchd[1] (com.syscl.externalfix.sleepwatcher[54279]): Could not find and/or execute program specified by service: 13: Permission denied: /usr/local/sbin/sleepwatcher

syscl commented 7 years ago

Really appreciate your information, I will look into it these days.

syscl

enjay314 commented 6 years ago

Hi there, I am not sure if you are still working on this awesome script but I also have a PCIe USB card where I get the Disk Not Ejected Properly error. Sometimes your script works flawlessly but other times it doesn't. I am on Sierra 10.12.6 so perhaps something has changed to make the script incompatible? Any way I can help, please let me know. Thanks!

syscl commented 6 years ago

Hi @enjay314

Could you please provide at least your diskutil list and the log from your current PCIe USB, say for example the IDENTIFIER of your PCIe USB is disk3 then type indiskutil info disk3 and diskutil info disk3s[0-9] as well.

Thank you, syscl

enjay314 commented 6 years ago

Sure! Thank you! I just included the additional info for disk1 and disk2, let me know if you need the other disks.

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *120.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Neumega HD              119.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

/dev/disk1 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk1
   1:                        EFI EFI                     209.7 MB   disk1s1
   2:                  Apple_HFS 4                       2.0 TB     disk1s2

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                  Apple_HFS 5                       2.0 TB     disk2s2

/dev/disk3 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk3
   1:                        EFI EFI                     209.7 MB   disk3s1
   2:                  Apple_HFS 3                       2.0 TB     disk3s2

/dev/disk4 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *4.0 TB     disk4
   1:                        EFI EFI                     209.7 MB   disk4s1
   2:                  Apple_HFS 1                       4.0 TB     disk4s2

/dev/disk5 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *6.0 TB     disk5
   1:                        EFI EFI                     209.7 MB   disk5s1
   2:                  Apple_HFS 2                       6.0 TB     disk5s2

Device Identifier:        disk1
   Device Node:              /dev/disk1
   Whole:                    Yes
   Part of Whole:            disk1
   Device / Media Name:      Master DAS

   Volume Name:              Not applicable (no file system)
   Mounted:                  Not applicable (no file system)
   File System:              None

   Content (IOContent):      GUID_partition_scheme
   OS Can Be Installed:      No
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Not Supported

   Disk Size:                2.0 TB (2000398934016 Bytes) (exactly 3907029168 512-Byte-Units)
   Device Block Size:        512 Bytes

   Read-Only Media:          No
   Read-Only Volume:         Not applicable (no file system)

   Device Location:          External
   Removable Media:          Fixed

   Virtual:                  No
   OS 9 Drivers:             No
   Low Level Format:         Not supported

Device Identifier:        disk1s1
   Device Node:              /dev/disk1s1
   Whole:                    No
   Part of Whole:            disk1

   Volume Name:              EFI
   Mounted:                  No

   Partition Type:           EFI
   File System Personality:  MS-DOS FAT32
   Type (Bundle):            msdos
   Name (User Visible):      MS-DOS (FAT32)

   OS Can Be Installed:      No
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Not Supported
   Volume UUID:              0E239BC6-F960-3107-89CF-1C97F78BB46B
   Disk / Partition UUID:    28A6286B-32A0-442D-B97D-17BF0B3AA008

   Disk Size:                209.7 MB (209715200 Bytes) (exactly 409600 512-Byte-Units)
   Device Block Size:        512 Bytes

   Volume Total Space:       0 B (0 Bytes) (exactly 0 512-Byte-Units)
   Volume Available Space:   0 B (0 Bytes) (exactly 0 512-Byte-Units)

   Read-Only Media:          No
   Read-Only Volume:         Not applicable (not mounted)

   Device Location:          External
   Removable Media:          Fixed

Device Identifier:        disk1s2
   Device Node:              /dev/disk1s2
   Whole:                    No
   Part of Whole:            disk1

   Volume Name:              4
   Mounted:                  Yes
   Mount Point:              /Volumes/4

   Partition Type:           Apple_HFS
   File System Personality:  Journaled HFS+
   Type (Bundle):            hfs
   Name (User Visible):      Mac OS Extended (Journaled)
   Journal:                  Journal size 155648 KB at offset 0x3a38000
   Owners:                   Disabled

   OS Can Be Installed:      Yes
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Not Supported
   Volume UUID:              7925296B-AD1D-3984-A8DB-492E7DBCF501
   Disk / Partition UUID:    9BCE5643-C956-41D4-997E-4767487E383F

   Disk Size:                2.0 TB (2000054960128 Bytes) (exactly 3906357344 512-Byte-Units)
   Device Block Size:        512 Bytes

   Volume Total Space:       2.0 TB (2000054960128 Bytes) (exactly 3906357344 512-Byte-Units)
   Volume Used Space:        1.9 TB (1884683186176 Bytes) (exactly 3681021848 512-Byte-Units) (94.2%)
   Volume Available Space:   115.4 GB (115371773952 Bytes) (exactly 225335496 512-Byte-Units) (5.8%)
   Allocation Block Size:    4096 Bytes

   Read-Only Media:          No
   Read-Only Volume:         No

   Device Location:          External
   Removable Media:          Fixed

 Device Identifier:        disk2
   Device Node:              /dev/disk2
   Whole:                    Yes
   Part of Whole:            disk2
   Device / Media Name:      Master DAS

   Volume Name:              Not applicable (no file system)
   Mounted:                  Not applicable (no file system)
   File System:              None

   Content (IOContent):      GUID_partition_scheme
   OS Can Be Installed:      No
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Not Supported

   Disk Size:                2.0 TB (2000398934016 Bytes) (exactly 3907029168 512-Byte-Units)
   Device Block Size:        512 Bytes

   Read-Only Media:          No
   Read-Only Volume:         Not applicable (no file system)

   Device Location:          External
   Removable Media:          Fixed

   Virtual:                  No
   OS 9 Drivers:             No
   Low Level Format:         Not supported

Device Identifier:        disk2s1
   Device Node:              /dev/disk2s1
   Whole:                    No
   Part of Whole:            disk2

   Volume Name:              EFI
   Mounted:                  No

   Partition Type:           EFI
   File System Personality:  MS-DOS FAT32
   Type (Bundle):            msdos
   Name (User Visible):      MS-DOS (FAT32)

   OS Can Be Installed:      No
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Not Supported
   Volume UUID:              3A659C61-576D-35F9-8A4C-3BDD6E36337C
   Disk / Partition UUID:    4C2A310F-F44E-4AA2-B366-726ACB25DD9E

   Disk Size:                209.7 MB (209715200 Bytes) (exactly 409600 512-Byte-Units)
   Device Block Size:        512 Bytes

   Volume Total Space:       0 B (0 Bytes) (exactly 0 512-Byte-Units)
   Volume Available Space:   0 B (0 Bytes) (exactly 0 512-Byte-Units)

   Read-Only Media:          No
   Read-Only Volume:         Not applicable (not mounted)

   Device Location:          External
   Removable Media:          Fixed

Device Identifier:        disk2s2
   Device Node:              /dev/disk2s2
   Whole:                    No
   Part of Whole:            disk2

   Volume Name:              5
   Mounted:                  Yes
   Mount Point:              /Volumes/5

   Partition Type:           Apple_HFS
   File System Personality:  HFS+
   Type (Bundle):            hfs
   Name (User Visible):      Mac OS Extended
   Owners:                   Disabled

   OS Can Be Installed:      No
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Not Supported
   Volume UUID:              508ABAC4-D162-39A7-895D-A3B3FEDBAF45
   Disk / Partition UUID:    B2868ED9-5114-46DF-8DDE-61AB48FFBA34

   Disk Size:                2.0 TB (2000054960128 Bytes) (exactly 3906357344 512-Byte-Units)
   Device Block Size:        512 Bytes

   Volume Total Space:       2.0 TB (2000054960128 Bytes) (exactly 3906357344 512-Byte-Units)
   Volume Used Space:        1.6 TB (1559200817152 Bytes) (exactly 3045314096 512-Byte-Units) (78.0%)
   Volume Available Space:   440.9 GB (440854142976 Bytes) (exactly 861043248 512-Byte-Units) (22.0%)
   Allocation Block Size:    4096 Bytes

   Read-Only Media:          No
   Read-Only Volume:         No

   Device Location:          External
   Removable Media:          Fixed
syscl commented 6 years ago

Got it thank you so much!