Score:0

System Crash after laptop sleep

pf flag

The Issue

A few months ago I installed Ubuntu on an unused Mac Book Pro (13" late 2016 model). The install works fine for the most part except when the computer sleeps. Upon waking, I cannot open any applications, getting the error:

Failed to launch <application_name>
Failed to execute the child process "/bin/sh" (Input/output error)

This is then followed by application icons disappearing and eventually a system crash, requiring a hard reset. Before the reset the kernel spams messages similar to:

EXT4-fs error (device nvme0n1p2): __ext4_find_entry:1663: inode #12583047: comm gmain: reading directory lblock 0

What I have tried to fix the issue

Given the output above I suspected two causes: a broken file system or a faulty drive.

After booting a live usb I ran fsck on the root file system and found no issues. I also ran smartctl which indicated the drive was healthy. I also performed the check outlined in this post, which passed.

After the above did not work I stumbled upon this post, which seemed to be similar to what I was experiencing. The cause of the issue was an APST issue, which could be overcome by modifying some settings in the grub file. After attempting the two solutions outlined in the post, the issue persisted.

System Info

Laptop Model: Late 2016 13" MacBook Pro

Ubuntu Version:

Kernel Version:

Logs

Relevant log files are difficult to obtain as the system goes into Read Only mode once the computer has woken from sleep i.e. the error messages aren't available to me once I reboot the system (if there is a workaround to this I am happy to try it and update the post).

What I have been able to do is run dmesg -w to see the results displayed to the terminal in the short time the computer is running after waking from sleep. I was able to snap the below pictures from that output.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Let me know if there is any more output that I can supply.

Any help would be greatly appreciated as I am relatively new to Linux. I have learned a lot from this so far but am a little unsure as to how to proceed next.

Score:0
in flag

Generally the MacBook puts the NVMe storage to sleep via the UEFI monitor. If the drive is not given the command to power up again, then anything that is not already in memory is inaccessible. This is also why there are no logs being written. That said, there is an ugly hack workaround for your particular MacBook that will allow the machine to resume.

There is one caveat, though: waking from sleep will take 10~20 seconds rather than the 0~1 that might be expected.

So long as you can live with this, here is the solution:

  1. Open Terminal (if it’s not already open)

  2. Create a small file called something like wakey-wakey.sh:

    sudo {editor of choice} /use/sbin/wakey-wakey.sh
    

    Note: Be sure to replace {editor of choice} with your editor of choice.

    Paste the following content in the new file:

    #!/bin/bash
    /bin/echo 0 > /sys/bus/pci/devices/0000\:01\:00.0/d3cold_allowed
    

    Then save the file and exit the text editor.

  3. Create a .service file which will be called every time the system wakes from sleep:

    sudo {editor of choice} /etc/systemd/system/wake_storage.service
    

    Paste the following into the new file:

    # Service to reset sleep boolean on Apple MacBook Pro internal storage devices
    
    [Unit]
    Description=Disable NVMe from hard power down on sleep
    
    [Service]
    ExecStart=/sbin/wakey-wakey.sh
    Type=oneshot
    RemainAfterExit=yes
    
    [Install]
    WantedBy=multi-user.target
    

    Save the file and exit.

  4. Reboot

If you wish to undo this behaviour later, simply delete the .service file and reboot.

Please also note that there will be a 10~20 delay after waking before the Lock Screen appears. This is just the way it is. The only solution to this is to never let the machine sleep.

Maxim Hehir avatar
pf flag
Thanks for the quick response. I tried implementing the above solution, although am still receiving errors (now I no longer get to the login screen after sleep). I did make some modifications though 1) I have no "use" directory and assumed you meant usr (where I put the wakey-wakey.sh) file. 2) I tried to modify the full ExecStart file path to /usr/sbin/<the_same> (only after trying what you wrote first).
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.