Why this page?

Before starting

This hardware can be used with i386 or amd64 architecture.

Always make a backup of your system before such an operation.

It is possible to boot directly in EFI mode with rEFInd installed and also to load grub-efi from rEFInd. This is my setup.

For installation, it is advised to read the Debian Installation Guide. Have it next to you during installation.

Installation is preferably made in a multiboot setup which permits to install Debian next to Mac OS X. That was you can choose at boot time which OS to load. It is always handy to have mac OS still installed.

Install an alternative EFI boot manager

iMac has a EFI v1 firmware that can load the Mac OS X installations on your disk. It can also load any EFI boot manager that is installed on <efi_partiton>:\EFI\Boot\Bootx64.efi whether it is on your internal hard disk, or on an optical device (CD/DVD reader) or external device (Firewire external disk, USB key...). To show up a menu allowing one to select the OS to boot with the built-in EFI firmware, one has to keep the 'option' key pressed (ie. alt key) at boot time, before the chime.

The built-in EFI firmware cannot load linux directly though. For this you need an alternative boot manager that supports that.

grub2 is the default boot manager of Debian. It is able to load linux but it can't load Mac OS X directly (at least I haven't found an easy way to do so).

`rEFInd` is a boot manager that supports booting Mac OS X, linux, but also any other installed efi program. It detects automatically the available OS's & kernel that can be launched. It can be installed from within Mac OS X.

I suggest to install rEFInd. It can be installed from Mac OS X and once installed it will show up at boot time and let you choose the OS to boot.

Install rEFInd from within Mac OS X

Follow the installation instructions on rEFInd's website.

If you are running El Capitan (OS X 10.11) or later, some extra steps are required.

Prepare target drive for Debian

You also have to prepare your disk so that it has space for the installation of Debian. If you wish to install Debian next to your OS X on the internal hard disk drive, you need to repartition it. I suggest to do this with GParted tool. It can be found on some live CD, for example on GParted live CD or SystemRescue.

Always make a backup of your system before such an operation.

Download the liveCD of your choice. Burn it to a CD/DVD or to a USB key.

Then boot on it. rEFInd should present it to you in its menu, or with the built-in EFI firmware (press the 'option' key at boot time).

Once the live CD is loaded, launch GParted.

in GParted free some space by shrinking your current HFS+ partition (where Mac OS X resided). Then add to that free space a partition with ext4 filesystem and also a swap partition. I use 40GB for the ext4 partition. But the required space will depend on what you want to use Debian for. You may want to have a look at Memory and Disk Space Requirements from the bookworm installation guide.

Once done, restart to your Mac OS X to check that it still works fine. I suggest to also launch "Disk Utility" and perform a check of your partition.

Install Debian

Now that you have prepared the disk to host an installation of Debian, we can consider installing it.

All steps are detailed in the Debian Installation Guide. Have it next to you during installation.

Download the installation medium (CD or DVD for example) of Debian and boot from that medium by inserting it into your iMac.

Boot on installer

Booting on the installation medium is similar to what was described in the step to boot on GParted medium. You may have to press the "option" key (which is the left "alt" key for me) at the time of startup (before the chime) and select the optical drive in the list of bootable drives. It should boot in EFI mode (and note bios/mbr mode).

Alternatively, you could also copy all files from a ISO image of debian an put it on a USB key. Press the "option" key at boot time and in the list of OS's to boot you should have a value "EFI Boot" for an external device. Select it, it should boot grub from the debian installer.

You have to set "tsc=unstable" as kernel parameter. This is done when your are in GRUB. Highlight the boot option that you want and edit it (press 'E' key), and add "tsc=unstable" to the line that starts with "linux". Then proceed with booting (press "F10" key). More details on why this parameters is required is below in this article (mainly to avoid being stuck with a black scree for a few minutes during boot).

About network access during installation

Be aware that with iMac 9.1, access to network with wifi will not be available because it requires some firmware that is not shipped by Debian. It recommended to install either in the "offline" mode by using an installation medium CD/DVD/USB. If you still want to install and use the network to download the packages, then connect to your network with the wire. It is possible to load the wireless firmware during setup if you could prepare it on an external device that you can insert during installation, however this is a bit more difficult and requires more technical skills.

Using wired network

Should work without issues.

Using wireless network

Built-in kernel driver for the wireless network adapter (WiFi) is b43. It is mandatory to provide additional firmware so that the driver loads properly. The firmware is not directly available as a Debian package. It is not in the installer either. However during installation, the installer gives the possibility to add firmware by means of a USB stick for example on which you have put the firmware files.

To get the firmware files, you need to take them from a system that already runs Debian. Install the package firmware-b43-installer which downloads and installs the firmware needed by the b43 kernel driver for some Broadcom 43xx wireless network cards. The files will be installed to /lib/firmware/b43.

The installation guide says to then copy the 'b43' directory to a USB stick either at the root of the filesystem, or inside "/firmware" directory. However because of bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1088295 (confirmed on bookworm 12.8 installer) this could fail because the installer will stop searching as soon as it can find a device/drive or partition that is mountable.

If the USB stick is not partitioned the installer will be able to mount the USB stick before the partitions (the installer first tries to mount devices, and only then the partitions). In that case it will only search on the USB stick, and it is likely it will find the firmware there. So you have to put the b43 drivers on the USB stick into the "/firmware" directory.

On EFI systems, the ESP partition is usually the first one that can be mounted. This is also the case of the iMac. So if your USB stick is partitioned, the USB stick comes after the ESP partition (the is the built-in the order used by the installer). So you should create the "/firmware" into the ESP partition and put the "b43" dir into that directory.

Please, note that the installer will ask you a few times (3 times in my case) if you want it to check for firmware on the external media. This is normal, every time the list of requested files will differ slightly.

After installation

After installation it is likely that the installer created a "Debian" entry in the EFI boot manager and that it set it as 1st entry in the Boot Order. Because of this, the iMac will not load rEFInd anymore but GRUB. We have to restore rEFInd and set the bootorder from within Debian.

Run as root:

efibootmgr -v

Check the values of the ?BootOrder entry. The first entry should correspond to "Mac OS X". If it is not, you have to set the new boot order with the "Mac OS X" entry first. Command would be (as root):

efibootmgr --bootorder XXXX,YYYY,ZZZZ

On my system the correct ?BootOrder would be "80,0".

Configuring support for the hardware of iMac 9.1

Hardware details

This guide was written for Apple iMac "Core 2 Duo" 2.66 24" (Early 2009). But there are other iMac 9.1 devices which might have a similar hardware.

lspci -nn

00:00.0 Host bridge [0600]: NVIDIA Corporation MCP79 Host Bridge [10de:0a82] (rev b1)
00:00.1 RAM memory [0500]: NVIDIA Corporation MCP79 Memory Controller [10de:0a88] (rev b1)
00:03.0 ISA bridge [0601]: NVIDIA Corporation MCP79 LPC Bridge [10de:0aae] (rev b2)
00:03.1 RAM memory [0500]: NVIDIA Corporation MCP79 Memory Controller [10de:0aa4] (rev b1)
00:03.2 SMBus [0c05]: NVIDIA Corporation MCP79 SMBus [10de:0aa2] (rev b1)
00:03.3 RAM memory [0500]: NVIDIA Corporation MCP79 Memory Controller [10de:0a89] (rev b1)
00:03.4 RAM memory [0500]: NVIDIA Corporation MCP79 Memory Controller [10de:0a98] (rev b1)
00:03.5 Co-processor [0b40]: NVIDIA Corporation MCP79 Co-processor [10de:0aa3] (rev b1)
00:04.0 USB controller [0c03]: NVIDIA Corporation MCP79 OHCI USB 1.1 Controller [10de:0aa5] (rev b1)
00:04.1 USB controller [0c03]: NVIDIA Corporation MCP79 EHCI USB 2.0 Controller [10de:0aa6] (rev b1)
00:06.0 USB controller [0c03]: NVIDIA Corporation MCP79 OHCI USB 1.1 Controller [10de:0aa7] (rev b1)
00:06.1 USB controller [0c03]: NVIDIA Corporation MCP79 EHCI USB 2.0 Controller [10de:0aa9] (rev b1)
00:08.0 Audio device [0403]: NVIDIA Corporation MCP79 High Definition Audio [10de:0ac0] (rev b1)
00:09.0 PCI bridge [0604]: NVIDIA Corporation MCP79 PCI Bridge [10de:0aab] (rev b1)
00:0a.0 Ethernet controller [0200]: NVIDIA Corporation MCP79 Ethernet [10de:0ab0] (rev b1)
00:0b.0 SATA controller [0106]: NVIDIA Corporation MCP79 AHCI Controller [10de:0ab9] (rev b1)
00:0c.0 PCI bridge [0604]: NVIDIA Corporation MCP79 PCI Express Bridge [10de:0ac4] (rev b1)
00:10.0 PCI bridge [0604]: NVIDIA Corporation MCP79 PCI Express Bridge [10de:0aa0] (rev b1)
00:15.0 PCI bridge [0604]: NVIDIA Corporation MCP79 PCI Express Bridge [10de:0ac6] (rev b1)
00:16.0 PCI bridge [0604]: NVIDIA Corporation MCP79 PCI Express Bridge [10de:0ac7] (rev b1)
03:00.0 VGA compatible controller [0300]: NVIDIA Corporation C79 [GeForce 9400] [10de:0867] (rev b1)
04:00.0 Network controller [0280]: Broadcom Inc. and subsidiaries BCM4322 802.11a/b/g/n Wireless LAN Controller [14e4:432b] (rev 01)
05:00.0 FireWire (IEEE 1394) [0c00]: LSI Corporation FW643 [TrueFire] PCIe 1394b Controller [11c1:5901] (rev 07)

lsusb

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 003: ID 05ac:8215 Apple, Inc. Built-in Bluetooth 2.0+EDR HCI
Bus 004 Device 002: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 05ac:8502 Apple, Inc. Built-in iSight
Bus 001 Device 005: ID 05ac:0221 Apple, Inc. Aluminum Keyboard (ISO)
Bus 001 Device 003: ID 05ac:1006 Apple, Inc. Hub in Aluminum Keyboard
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 05ac:8242 Apple, Inc. Built-in IR Receiver
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Network

Wired

00:0a.0 Ethernet controller [0200]: NVIDIA Corporation MCP79 Ethernet [10de:0ab0] (rev b1)

Bookworm

Nothing to do. "forcedeth" module is loaded automatically by the kernel.

forcedeth: Ethernet driver for NVIDIA nForce media access controllers

Wi-Fi

04:00.0 Network controller [0280]: Broadcom Inc. and subsidiaries BCM4322 802.11a/b/g/n Wireless LAN Controller [14e4:432b] (rev 01)

Bookworm

By default wifi is automatically detected and uses the open-source "b43" module (it requires to install its firmware, though), but you can also use the "wl" module which I found faster on my system.

open source `b43` driver

Ensure that you have added the "non-free" component (archive area) to your sources.list

You must install the firmware-b43-installer package to have the appropriate firmware installed.

apt-get install firmware-b43-installer

Note that on https://wireless.docs.kernel.org/en/latest/en/users/drivers/b43.html the [14e4:432b] device is marked as "partially" supported.

More info: https://wiki.debian.org/bcm43xx

proprietary `wl` driver

Ensure that you have added the "non-free" component (archive area) to your sources.list

apt-get install broadcom-sta-dkms

Unload conflicting modules:

modprobe -r b44 b43 b43legacy ssb brcmsmac bcma

Remove the b43 firmware (

apt-get purge firmware-b43-installer

Load the wl module:

modprobe wl

You may have to restart the system so that wl is properly loaded & configured. It seems it doesn't load properly when b43 was used before (even when unloaded). Kernel log reports:

ERROR @wl_notify_scan_status : 
wlan0 Scan_results error (-22)

So a restart would fix that.

More info: https://wiki.debian.org/wl

Bluetooth

Bus 004 Device 003: ID 05ac:8215 Apple, Inc. Built-in Bluetooth 2.0+EDR HCI
Bus 004 Device 002: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)

Bookworm

Nothing to do. "btusb" module is loaded automatically by the kernel.

You may need to install package bluetooth.

Ensure that bluetooth service is enabled and started with:

systemctl enable bluetooth
systemctl start bluetooth

Firewire

05:00.0 FireWire (IEEE 1394) [0c00]: LSI Corporation FW643 [TrueFire] PCIe 1394b Controller [11c1:5901] (rev 07)

Bookworm

Nothing to do. "firewire_core" module is loaded automatically by the kernel.

iSight (integrated Webcam)

Bus 001 Device 004: ID 05ac:8502 Apple, Inc. Built-in iSight

Bookworm

Nothing to do. "uvcvideo" module is loaded automatically by the kernel.

isenkram suggests to install package cheese but this is not mandatory. The webcam works without it.

Audio

00:08.0 Audio device [0403]: NVIDIA Corporation MCP79 High Definition Audio [10de:0ac0] (rev b1)

Bookworm

Nothing to do. "snd_hda_intel" module is loaded automatically by the kernel.

Graphics/Video/Display

03:00.0 VGA compatible controller [0300]: NVIDIA Corporation C79 [GeForce 9400] [10de:0867] (rev b1)

ICC Profile

ICC Profiles can be found on you Mac OS X drive at any of these paths:

/Library/ColorSync/Profiles
/Users/USER_NAME/Library/ColorSync/Profile

You can copy them to any of

/usr/share/color/icc
/usr/local/share/color/icc
/home/USER_NAME/.color/icc
~/.local/share/color/icc

Install these packages:

apt-get install icc-profiles xcalib

To load a color profile:

xcalib /path/to/Library/ColorSync/Profiles/Displays/iMac-serial.icc

On KDE, you may want to configure it inside KDE/Plasma:

Install

apt-get install colord-kde

In the kde system settings, go to the "Color correction" section and choose the profile you want for each device.

Sources:

Bookworm

There are 2 options for the driver/module:

I found that the "nouveau" driver is sometimes buggy and can lead to system freeze, especially when trying to play a video with VDPAU acceleration enabled, or simply on KDE with kate as text editor.

My experience is that it is more stable to work with the "nvidia" driver. However the package for the nvidia driver is not distributed in bookworm. Nevertheless it can be found in "sid" and rebuilding it for bookworm is easy.

nouveau (open-source driver)

As reported by dmesg, nouveau driver requires some firmware files:

firmware: failed to load nouveau/nvac_fuc084 (-2)
firmware: failed to load nouveau/nvac_fuc084d (-2)

To install them, follow the steps detailed on the nouveau driver page. The script has been updated to support both python2 & python3.

mkdir /tmp/nouveau
cd /tmp/nouveau
wget https://raw.github.com/envytools/firmware/master/extract_firmware.py
wget http://us.download.nvidia.com/XFree86/Linux-x86/325.15/NVIDIA-Linux-x86-325.15.run
sh NVIDIA-Linux-x86-325.15.run --extract-only
python extract_firmware.py
mkdir /lib/firmware/nouveau
cp -d nv* vuc-* /lib/firmware/nouveau/

The system will boot even if the files are not found, but given that the kernel searches for them it is better if you have them.

disable acceleration (only if required)

Depending on your usage, if nouveau freezes sometimes (video playback, firefox, suspend/resume), you may want to disable video acceleration. This can be done by adding kernel parameter nouveau.noaccel=1.

In /etc/default/grub add nouveau.noaccel=1 to the GRUB_CMDLINE_LINUX_DEFAULT variable.

Then update grub with update-grub2.

nvidia (proprietary closed-source driver)

I personally prefer to use the nvidia driver because I don't face the freeze, and still can have video acceleration. However, with nvidia you won't have any display when switching to the console mode.

On Debian, nvidia driver for the GPU of this iMac is packaged in nvidia-legacy-340xx-driver source package. This package is not available in bookworm, but it is still maintained in "sid/unstable".

Last stable distribution that had it is "buster" (Debian 10). Package has been removed because of these two bug reports:

It is up to you to decide if you want to use it or not.

It is possible to build the package for bookworm by taking the source package.

Building the package for bookworm

nvidia-legacy-340xx-driver version 340.108-21 works with kernel 5.10, 6.1 and up to 6.6. Later versions may add support for newer kernels. Tracking information for the package is also availabe.

To /etc/apt/sources.list add the line:

deb-src http://deb.debian.org/debian/ unstable main non-free contrib

Then run as root:

apt-get update
apt-get install build-essential devscripts local-apt-repository
apt-get build-dep nvidia-graphics-drivers-legacy-340xx
apt-get build-dep nvidia-settings-legacy-340xx

Then run as regular user:

apt-get source nvidia-graphics-drivers-legacy-340xx
apt-get source nvidia-settings-legacy-340xx
cd nvidia-graphics-drivers-legacy-340xx-340.108
dch --local=~local "local build for $(lsb_release -cs)"
dpkg-buildpackage -us -uc
cd ..
cd nvidia-settings-legacy-340xx-340.108
dch --local=~local "local build for $(lsb_release -cs)"
dpkg-buildpackage -us -uc

If you have enabled other architectures on your system (like i386) you may have to build the package also for them. Check the foreign arch with:

dpkg --print-foreign-architectures

In that case, repeat the build operation above for nvidia-graphics-drivers-legacy-340xx and add --host-arch i386 -Pcross to dpkg-buildpackage. You may need to also install these before:

apt-get install gcc-12-i686-linux-gnu patchelf:i386 linux-headers-686

As root, create the dir that will contain the *.deb that were built

mkdir -p /srv/local-apt-repository

As root, copy the generated deb to /srv/local-apt-repository. They will be available to apt for easy installation.

cd nvidia-graphics-drivers-legacy-340xx-340.108
dcmd cp -v ../$(dpkg-parsechangelog -S Source)*.changes /srv/local-apt-repository
cd ../nvidia-settings-legacy-340xx-340.108
dcmd cp -v ../$(dpkg-parsechangelog -S Source)*.changes /srv/local-apt-repository

Add apt-pinning for these packages by creating this file /etc/apt/preferences.d/50_local-apt-repository_nvidia-graphics-drivers-legacy-340xx.pref .

Explanation: ### Install nvidia driver & related packages from local-apt-repository ###
Package: src:nvidia-graphics-drivers-legacy-340xx:any src:nvidia-settings-legacy-340xx:any
Pin: release o=local-apt-repository
Pin-Priority: 991

You may want to remove the packages we installed for building purposes (except local-apt-repository):

apt-get remove build-essential devscripts gcc-12-i686-linux-gnu patchelf patchelf:i386 linux-headers-686
apt autoremove

Installing the package for bookworm

Finally, install the nvidia driver:

apt-get install nvidia-legacy-340xx-driver

Configuration

There is no need to make any special configuration for Xorg, and blacklisting of nouveau module is also managed by the package for nvidia driver.

By rebooting your system should use with nvidia driver.

You have access to nvidia settings pannel in your desktop environment, or by running nvidia-settings.

So that the backlight keys of the keyboard work with the nvidia driver, add the option "?RegistryDwords" "?EnableBrightnessControl=1" to the device configuration in your /etc/X11/xorg.conf file. See https://wiki.debian.org/InstallingDebianOn/Apple/MacBookPro/5-5#Re-enable_Display_Brightness. This page also says how to Disable Logo Display at Boot. I haven't tried these.

Switch between `nouveau` & `nvidia`

It is possible to have both nouveau & nvidia installed on the system and switch between them at boot time. However it requires to run a few commands before reboot so that it works.

from nvidia to nouveau

from nouveau to nvidia

Keyboard

Bus 001 Device 005: ID 05ac:0221 Apple, Inc. Aluminum Keyboard (ISO)
Bus 001 Device 003: ID 05ac:1006 Apple, Inc. Hub in Aluminum Keyboard

bookwom

Nothing to do. "hid_apple" module is loaded automatically by the kernel.

Special keys:

You may configure some aspects of your keyboard through hid_apple parameters:

Some references:

Apple Infrared Remote

bookworm

Todo. See page for other Apple models.

Sensors (applesmc module)

bookworm

Nothing to do. "applesmc" module is loaded automatically by the kernel.

To display information on the senors, run sensors (from package lm-sensors).

sensors configuration file

So that the output of sensors is more human readable, you may create a sensors configuration file, which will map the label to a human understandable one according to mapping values from jBot-42.

# cat /etc/sensors.d/applesmc-isa-0300.conf

# applesmc-isa-0300
chip "applesmc-isa-0300"
# Adapter: ISA adapter
# ODD :
#   fan1_input: ...
#   fan1_min: ...
#   fan1_max: ...
# HDD :
#   fan2_input: ...
#   fan2_min: ...
#   fan2_max: ...
# CPU :
#   fan3_input: ...
#   fan3_min: ...
#   fan3_max: ...
# TA0P:
#   temp1_input: ...
label "temp1" "Airflow 1"
# TC0D:
#   temp2_input: ...
label "temp2" "CPU 1 Package"
# TC0H:
#   temp3_input: ...
label "temp3" "CPU 1 Heatsink"
# TC0P:
#   temp4_input: ...
label "temp4" "CPU 1 Proximity"
# TG0D:
#   temp5_input: ...
label "temp5" "GPU Die"
# TG0H:
#   temp6_input: ...
label "temp6" "GPU Heatsink"
# TH0P:
#   temp7_input: ...
label "temp7" "HDD Bay 1"
# TL0P:
#   temp8_input: ...
label "temp8" "LCD Proximity"
# TN0D:
#   temp9_input: ...
label "temp9" "Northbridge Die"
# TN0H:
#   temp10_input: ...
label "temp10" "MCH Heatsink"
# TN0P:
#   temp11_input: ...
label "temp11" "Northbridge Proximity 1"
# TO0P:
#   temp12_input: ...
label "temp12" "Optical Drive"
# Tm0P:
#   temp13_input: ...
label "temp13" "Mainboard Proximity"
# Tp0P:
#   temp14_input: ...
label "temp14" "Powerboard Proximity"

Output sample:

$ sensors
applesmc-isa-0300
Adapter: ISA adapter
ODD :                     799 RPM  (min =  800 RPM, max = 4800 RPM)
HDD :                    1598 RPM  (min = 1600 RPM, max = 5900 RPM)
CPU :                    1200 RPM  (min = 1200 RPM, max = 3600 RPM)
Airflow 1:                +20.5°C  
CPU 1 Package:            +35.8°C  
CPU 1 Heatsink:           +34.2°C  
CPU 1 Proximity:          +40.0°C  
GPU Die:                 -127.0°C  
GPU Heatsink:            -127.0°C  
HDD Bay 1:                +43.2°C  
LCD Proximity:            +40.0°C  
Northbridge Die:          +63.0°C  
MCH Heatsink:             +59.8°C  
Northbridge Proximity 1:  +47.0°C  
Optical Drive:            +35.2°C  
Mainboard Proximity:      +39.8°C  
Powerboard Proximity:     +49.5°C  

coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +37.0°C  (high = +105.0°C, crit = +105.0°C)
Core 1:       +38.0°C  (high = +105.0°C, crit = +105.0°C)

To manage fan speed

# echo "1" > /sys/devices/platform/applesmc.768/fanX_manual
# echo "1200" > /sys/devices/platform/applesmc.768/fanX_output

Where X could be 1 (ODD fan), 2 (HDD fan) or 3 (CPU fan).

Power management

bookworm

Suspend

According to this script the iMac doesn't support S0ix.

tmpdir=$(mktemp -d /tmp/S0ix.XXX)
cd "$tmpdir"
acpidump -b
iasl -d *.dat
lp=$(grep "Low Power S0 Idle" facp.dsl | awk '{print $(NF)}')

if [ "$lp" -eq 1 ]; then
        echo "Low Power S0 Idle is" $lp
        echo "The system supports S0ix!"
else
        echo "Low Power S0 Idle is" $lp
        echo "The system does not support S0ix!"
fi
rm -r "$tmpdir"

Output:

Low Power S0 Idle is 0
The system does not support S0ix!

Se we can't use s2idle for the suspend mode. Instead, we will use deep by default. The shallow mode is not availabe on this iMac.

First, set ?SuspendState to mem, which permits to use the deep mode.

if [! -d /etc/systemd/sleep.conf.d ]; then mkdir /etc/systemd/sleep.conf.d; cp -a /etc/systemd/sleep.conf /etc/systemd/sleep.conf.d/sleep.conf; fi
editor /etc/systemd/sleep.conf.d/sleep.conf
SuspendState=mem

To enable deep mode, if the system runs systemd < 256 (which is the case for bookworm) add this line to /etc/default/grub:

editor /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT mem_sleep_default=deep"

then run update-grub2.

For systemd >= 256 (ie. after bookworm):

if [! -d /etc/systemd/sleep.conf.d ]; then mkdir /etc/systemd/sleep.conf.d; cp -a /etc/systemd/sleep.conf /etc/systemd/sleep.conf.d/sleep.conf; fi
editor /etc/systemd/sleep.conf.d/sleep.conf

MemorySleepMode=deep

Hibernate / Suspend to disk

To debug why it doesn't work well: https://www.kernel.org/doc/html/latest/power/basic-pm-debugging.html#testing-hibernation-aka-suspend-to-disk-or-std

I found that on my system, it is unreliable, so I disabled it.

To disable hibernation add these lines to /etc/systemd/sleep.conf.d/sleep.conf:

if [! -d /etc/systemd/sleep.conf.d ]; then mkdir /etc/systemd/sleep.conf.d; cp -a /etc/systemd/sleep.conf /etc/systemd/sleep.conf.d/sleep.conf; fi
editor /etc/systemd/sleep.conf.d/sleep.conf

AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no

For those wanting to try anyway, some nice doc is at: https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Pass_hibernate_location_to_initramfs

System clock

On iMac, the system clock is stored in UTC (and not local time)

bookworm

In bookworm, system clock is managed by systemd-timesyncd.

Check that RTC is in UTC (value below should be "no"):

# LC_ALL=C timedatectl status | grep TZ
          RTC in local TZ: no

To set system clock to UTC:

timedatectl set-local-rtc 0

Kernel configuration

This section mentions some configurations that might be required to fix issues/oddities.

Kernel 5.15 (bullseye)

tsc & trace_clock

Same as for Kernel 6.1 (bookworm), except that boot is not delayed by a few minutes with kernel 5.15.

Kernel 6.1 (bookworm), kernel 6.9

tsc & trace_clock

With kernel 6.1 on bookworm (and linux 6.9 as well) boot time can be blocked for a few minutes. It seems it is blocked on the USB stage if we look at the log on screen, but when looking at the kernel logs, we can see:

clocksource: Long readout interval, skipping watchdog check: cs_nsec: 512010551 wd_nsec: 39243763320
clocksource: timekeeping watchdog on CPU0: Marking clocksource 'tsc' as unstable because the skew is too large:
clocksource:                       'hpet' wd_nsec: 537773520 wd_now: 3f0f7632 wd_last: 3e425140 mask: ffffffff
clocksource:                       'tsc' cs_nsec: 511996079 cs_now: 18b0866e6a cs_last: 185f8d68ba mask: ffffffffffffffff
clocksource:                       'tsc' is current clocksource.
tsc: Marking TSC unstable due to clocksource watchdog
TSC found unstable after boot, most likely due to broken BIOS. Use 'tsc=unstable'.
sched_clock: Marking unstable (3765559657, 1276001)<-(3775071370, -8235646)
clocksource: Checking clocksource tsc synchronization from CPU 1 to CPUs 0.
clocksource: Switched to clocksource hpet

When pressing the power off/power on button on the iMac, boot continues when it is in that 'frozen' stage, without doing it, at some time, boot continues itself.

So we have to set tsc=unstable as kernel parameter.

When booting with tsc=unstable, kernel log report:

Unstable clock detected, switching default tracing clock to "global"
If you want to keep using the local clock, then add:
  "trace_clock=local"
on the kernel command line

So we add that parameter trace_clock=global to the kernel command as well.

So on my system, I had to add both tsc=unstable trace_clock=global to the kernel parameters. Do this by adding them to /etc/default/grub the line GRUB_CMDLINE_LINUX.

# editor /etc/default/grub

GRUB_CMDLINE_LINUX="tsc=unstable trace_clock=global"

Then run:

update-grub2

Software configuration

Access to Mac OS X partitions

Can be done with linux built in driver, or Paragon's NTFS for linux driver, which also supports HFS+ filesystem. TODO...


CategoryMacintoshComputer