Skip to content

Instantly share code, notes, and snippets.

@direvius
Forked from yookoala/90-mac-superdrive.rules
Created January 11, 2022 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save direvius/bfa6dd1904c234d1381779711e5f9f38 to your computer and use it in GitHub Desktop.
Save direvius/bfa6dd1904c234d1381779711e5f9f38 to your computer and use it in GitHub Desktop.
udev rules to use Apple SuperDrive on Linux
#
# Apple SuperDrive initialization rule
#
# See: https://gist.github.com/yookoala/818c1ff057e3d965980b7fd3bf8f77a6
ACTION=="add", ATTRS{idProduct}=="1500", ATTRS{idVendor}=="05ac", DRIVERS=="usb", RUN+="/usr/bin/sg_raw %r/sr%n EA 00 00 00 00 00 01"

Device Rule for Apple SuperDrive

This is for properly using an Apple SuperDrive on Linux.

Why?

Although Linux can detect a SuperDrive being plugged in, the hardware won't do anything until receiving a specific set of Command Descriptor Block (CDB) through USB. If not, you cannot put disc in or take disc out even when the drive was connected correctly.

To use SuperDrive on Linux you can use Linux's SCSI Utilities (sg3_utils) to manually send the CDBs like this:

/usr/bin/sg_raw /dev/sr0 EA 00 00 00 00 00 01

But to do this manually everytime is simply a stupid task not to automate.

What the udev rule file does?

When installed properly into /etc/udev/rules.d, the udev rule file above (90-mac-superdrive.rules) will be triggered the sending of CDBs everytime the drive is plugged. It will even detect the correct device number if multiples are plugged.

Reference:

Prerequsities

Need to have sg3_utils installed on your system.

For Ubuntu:

sudo apt install sg3_utils

For Fedora / RHEL:

sudo dnf install sg3_utils

Installation

To create the file, you may use this command:

cat <<- EOF | sudo tee  /etc/udev/rules.d/90-mac-superdrive.rules > /dev/null
#
# Apple SuperDrive initialization rule
#
# See: https://gist.github.com/yookoala/818c1ff057e3d965980b7fd3bf8f77a6

ACTION=="add", ATTRS{idProduct}=="1500", ATTRS{idVendor}=="05ac", DRIVERS=="usb", RUN+="/usr/bin/sg_raw %r/sr%n EA 00 00 00 00 00 01"
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment