r/linux_on_mac • • 8h ago

Turning a 2004 Macbook (Snowbook) into a writing station ( a work in progress).

Thumbnail knightwise.com
2 Upvotes

r/linux_on_mac • • 8h ago

IT'S ALIVE! Debian Forky/Sid on 2013 Mac Pro 6,1 with Dual Radeon D700

Thumbnail gallery
3 Upvotes

r/linux_on_mac • • 14h ago

2012 MBP I want to connect my laptop to a TV for watching DVDs what are my best options?

2 Upvotes

So I have a MBP2012 running lubuntu and want to figure out how I can get it to output to the TV. Should I try and use the mini DP to HDMI with an adapter or would I be better off just grabbing a usb A to HDMI output thingy?


r/linux_on_mac • • 18h ago

From Toaster to Scalpel Upgrade: My 12-inch MacBook running Debian 13, a few months later

Thumbnail reddit.com
3 Upvotes

r/linux_on_mac • • 19h ago Heartwarming

Debian 13 on a 2017 12-inch MacBook: I finally got hibernation working

13 Upvotes

I've been running Debian 13 on my 2017 12-inch Retina MacBook for a while now. Most things have been working pretty well, but there was one problem I had practically given up on: sleep and hibernation.

Every time I tried normal suspend, something would go wrong when the machine woke up. Sometimes the keyboard or trackpad wouldn't respond, and other times I had problems with the display or other hardware.

Eventually, I disabled suspend altogether. Closing the lid would turn off the screen, but Debian kept running in the background.

Not exactly ideal for a laptop.

A few days ago, I came across this Debian discussion and the accompanying MacBook8,1 sleep/hibernation guide.

That got me interested in trying again.

My MacBook is a different model, so I couldn't simply copy everything. After several tests, some mistakes, and a fair amount of troubleshooting, I finally have it working.

Here's what I did.

My hardware

  • Apple MacBook Retina 12-inch, 2017
  • Model identifier: MacBook10,1
  • Debian 13 (Trixie)
  • GNOME / Wayland
  • Kernel: 6.12.117+deb13-amd64
  • 8 GB RAM
  • 256 GB Apple SSD
  • Broadcom BCM4350/5 Wi-Fi (brcmfmac)
  • Apple SPI keyboard and trackpad (applespi)

One important difference from the 2015 MacBook8,1 is the SPI controller.

Mine uses:

0000:00:1e.3 Intel Sunrise Point-LP Serial IO SPI Controller
Kernel driver: intel-lpss
SPI device: spi-APP000D:00

I decided not to touch the SPI controller or modify the applespi driver.

Instead of trying to fix normal suspend, I wanted to see whether direct hibernation could avoid the whole problem.

1. Checking hibernation support

First, I checked what the kernel supported:

cat /sys/power/state
cat /sys/power/mem_sleep
cat /sys/power/disk

Results:

freeze mem disk
[s2idle] deep
[platform] shutdown reboot suspend test_resume

So hibernation was available.

My machine already had these kernel parameters from previous troubleshooting:

mem_sleep_default=s2idle i915.enable_psr=0

I left them unchanged. I haven't tested whether removing them affects hibernation.

2. Configuring the swap partition

My Debian installation already had two swap areas:

  • A dedicated swap partition, approximately 7.9 GiB.
  • An additional 8 GiB swap file.

The swap partition was /dev/nvme0n1p3.

I identified its UUID with:

sudo blkid /dev/nvme0n1p3

Then configured /etc/initramfs-tools/conf.d/resume:

RESUME=UUID=<YOUR-SWAP-PARTITION-UUID>

Obviously, replace the placeholder with the UUID of your own swap partition.

After that:

sudo update-initramfs -u -k "$(uname -r)"

For the initial tests, I disabled the additional swap file:

sudo swapoff /swapfile

This left the dedicated swap partition available for hibernation.

A word of caution: my swap partition is only slightly larger than my installed RAM. It worked during my tests, but it may not be sufficient under every memory workload.

3. Enabling hibernation in systemd

This was my first obstacle.

Some time ago, while trying to stop the suspend problems, I had masked the systemd sleep targets.

When I tried:

sudo systemctl hibernate

I got:

Call to Hibernate failed: Access denied

The journal explained why:

Unit hibernate.target is masked, refusing operation.

I fixed that with:

sudo systemctl unmask hibernate.target sleep.target
sudo systemctl mask suspend.target

This allowed hibernation while keeping conventional suspend disabled.

I tried again:

sudo systemctl hibernate

And it worked!

The MacBook powered off and restored my previous desktop session when I turned it back on.

Unfortunately, the built-in Wi-Fi had completely disappeared.

Restarting Debian brought it back, but that obviously wasn't a workable solution.

4. Getting Broadcom Wi-Fi back after hibernation

My wireless chipset uses brcmfmac, along with brcmfmac_wcc.

Initially, I tried unloading and reloading the driver manually, but got:

modprobe: FATAL: Module brcmfmac is in use.

Eventually, I created a systemd sleep hook to handle the driver automatically.

It stops NetworkManager before hibernation, attempts to unload the Broadcom modules, and starts everything again afterward.

First, create the directory:

sudo mkdir -p /usr/lib/systemd/system-sleep

Then create the script:

sudo tee /usr/lib/systemd/system-sleep/macbook-wifi >/dev/null <<'EOF'
#!/bin/bash

LOG=/var/log/macbook-wifi-hibernate.log

log() {
    echo "$(date '+%F %T') $*" >> "$LOG"
}

case "$1/$2" in
    pre/hibernate)
        log "PRE: preparing Broadcom"
        systemctl stop NetworkManager

        for i in {1..10}; do
            modprobe -r brcmfmac_wcc 2>>"$LOG"
            if modprobe -r brcmfmac 2>>"$LOG"; then
                log "PRE: Broadcom unloaded successfully"
                exit 0
            fi
            sleep 1
        done

        log "ERROR: unable to unload Broadcom"
        systemctl start NetworkManager
        exit 1
        ;;

    post/hibernate)
        log "POST: restoring Broadcom"
        modprobe brcmfmac >>"$LOG" 2>&1
        systemctl start NetworkManager
        log "POST: restoration finished"
        ;;
esac
EOF

sudo chmod +x /usr/lib/systemd/system-sleep/macbook-wifi

The script also creates a log at:

/var/log/macbook-wifi-hibernate.log

This was useful because whenever Wi-Fi disappeared, I had to restart the MacBook before I could continue investigating.

With this script installed, the internal Broadcom Wi-Fi started working again after hibernation.

I haven't tested the script with other Broadcom chipsets, so I wouldn't assume it works universally.

5. Another problem: Nautilus

During testing, one hibernation attempt failed with:

Freezing user space processes failed after 20.004 seconds
(5 tasks refusing to freeze)

Looking through the kernel journal, I found blocked processes belonging to Nautilus:

task:pool-38 state:D
task:nautilus state:D

My Debian setup uses GNOME Online Accounts, including Microsoft accounts, and GVFS exposes some remote volumes through Nautilus.

I suspect a remote filesystem operation may have been involved, but I couldn't establish the exact cause.

What I did was close Nautilus before requesting hibernation.

For manual hibernation, I created this small script:

sudo tee /usr/local/bin/macbook-hibernate >/dev/null <<'EOF'
#!/bin/bash

nautilus -q

sleep 2

exec sudo systemctl hibernate
EOF

sudo chmod +x /usr/local/bin/macbook-hibernate

I run it as my normal desktop user:

macbook-hibernate

An important detail: don't run this particular command with sudo. Nautilus needs the user's graphical session environment to close cleanly.

After adjusting that, manual hibernation worked, including restoration of the desktop session and Wi-Fi.

Closing Nautilus is a workaround in my configuration, not proof that Nautilus or GVFS is responsible for every hibernation failure.

6. Hibernating automatically when closing the lid

At this point, hibernation was working, but I still had to run a command.

I wanted the laptop to behave like a laptop again: close the lid, put it away, and continue working when I opened it.

I decided to use acpid.

First:

sudo apt install acpid

My /etc/systemd/logind.conf already contained these settings under [Login]:

HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore

I kept them because I didn't want systemd-logind to trigger conventional suspend when closing the lid.

Then I created the ACPI event:

sudo tee /etc/acpi/events/macbook-lid >/dev/null <<'EOF'
event=button/lid.*
action=/usr/local/sbin/macbook-lid-hibernate
EOF

And the script responsible for handling it:

sudo tee /usr/local/sbin/macbook-lid-hibernate >/dev/null <<'EOF'
#!/bin/bash

# Only act when the lid is closed
grep -qi closed /proc/acpi/button/lid/*/state || exit 0

# Avoid duplicate hibernation requests
exec 9>/run/macbook-lid-hibernate.lock
flock -n 9 || exit 0

# Close Nautilus
pkill -TERM -u 1000 -x nautilus 2>/dev/null || true

sleep 2

# Hibernate
/usr/bin/systemctl hibernate
EOF

sudo chmod +x /usr/local/sbin/macbook-lid-hibernate

The UID 1000 is my desktop user. Anyone adapting this should check their own UID with:

id -u

Finally, I enabled and restarted acpid:

sudo systemctl enable --now acpid
sudo systemctl restart acpid

That was it.

Now closing the lid triggers the hibernation procedure automatically.

One thing worth mentioning: my lid-close script uses pkill instead of nautilus -q, because the ACPI script runs outside the graphical session.

7. The result

After all that, I closed the lid and let the MacBook hibernate.

When I opened it again, it powered on and restored my previous GNOME session.

The keyboard worked. The trackpad worked. The display and audio worked. Even the internal Broadcom Wi-Fi came back.

And there's a nice detail about this particular MacBook: it automatically powers on when you open the lid. You don't need to press the power button.

That behavior works with my Debian installation too.

I also did a real overnight test. I finished working, closed the lid, and left the laptop until the following morning.

When I opened it, Debian restored everything as I had left it.

That's exactly what I wanted.

A few final notes

This isn't a fix for conventional Linux suspend. It's a direct hibernation setup that avoids the suspend/resume problems I experienced on this hardware.

I didn't modify applespi, recompile the kernel, or change the Intel LPSS SPI controller.

My internal audio already worked through a separate MacBook-specific CS4208 DKMS driver, which I left untouched.

My final setup uses three main pieces:

  • Debian's existing hibernation mechanism and swap resume configuration.
  • A systemd sleep hook to handle Broadcom Wi-Fi.
  • An ACPI lid-close handler to close Nautilus and request hibernation.

The scripts above reflect what I installed and tested. They are not a polished general-purpose package, and I would strongly recommend reviewing them before using them on another machine.

In particular, make sure your swap configuration is correct, your user ID matches, and your Wi-Fi uses the same driver. Save your work and have a backup before experimenting with hibernation.

If something fails, these commands can help:

sudo cat /var/log/macbook-wifi-hibernate.log
sudo journalctl -b -1 | grep -Ei 'hibernate|freez|failed|brcmfmac'

Previous-boot journal history needs to be available for the second command.

Finally, thanks to the author of the MacBook8,1 Debian guide for documenting the original investigation. Reading that work convinced me to revisit a problem I had already given up on.

I used ChatGPT to help interpret the logs and work through the configuration, but the installation and testing were done on my own MacBook.

Hopefully this is useful to other people trying to keep these little 12-inch MacBooks running Linux.

For now, I'm leaving mine exactly as it is. It finally works the way I wanted.