Skip to content

Instantly share code, notes, and snippets.

@yookoala
Last active May 9, 2024 13:45
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yookoala/818c1ff057e3d965980b7fd3bf8f77a6 to your computer and use it in GitHub Desktop.
Save yookoala/818c1ff057e3d965980b7fd3bf8f77a6 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
@rvbgnu
Copy link

rvbgnu commented Apr 5, 2022

Thank you very much for providing these instructions!
Tiny typo for sg3_utils on Ubuntu, it is a dash - not an underscore _ ;-)
sudo apt install sg3-utils

@yookoala
Copy link
Author

yookoala commented Apr 7, 2022

Thank you very much for providing these instructions! Tiny typo for sg3_utils on Ubuntu, it is a dash - not an underscore _ ;-) sudo apt install sg3-utils

@rvbgnu: Thanks for pointing out the mistake. Corrected the typo above.

@Christian-hegeler
Copy link

Works fine, thank you!

@ascpial
Copy link

ascpial commented Mar 13, 2023

Thanks you, helped a lot 👍

@craigmcchesney
Copy link

+1, many thanks

@Oakleafknight06
Copy link

Thanks, this was very helpful!
quick note though, the fedora package is sg3_utils , with an underscore.

@yookoala
Copy link
Author

yookoala commented May 9, 2024

Thanks, this was very helpful! quick note though, the fedora package is sg3_utils , with an underscore.

Made correction in README.md. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment