physical CD-ROM / DVD tactics (auto mount)

Recommended Posts

goal: have CD-ROM / DVD reader working, ready to server files asap without going to terminal, auto mount

hardware: for example Microserver Gen10 with internal USB port and cute thin CD slot, it'd be a shame to leave it empty

software: find cdrom.ko and sr_mod.ko from someone nice who can build


initial setup



insmod /lib/modules/cdrom.ko # lock and load the driver
insmod /lib/modules/sr_mod.ko # --""--
lsmod | grep cdrom # result: cdrom xxxx 1 sr_mod
mknod /dev/sr0 b 11 0 # create scsi device

mknod /dev/cdrom b 11 0 # let's set up this "default" as a working duplicate, to satisfy eject command i.e. not type parameters each time
mkdir /volume1/yourshare/DVD # a subfolder in a share for easy access


here the work can end, if you like to operate it via CLI.

Automount is crippled like on other appliances, we can hook up to udev, e.g. monitor actions here:



udevadm --debug monitor


normally udev would do the job, but here events are limited if not delayed, there's just change action, that's what i put a respective command to /etc/udev/rules.d/99-local.rules:



KERNEL=="sr0", SUBSYSTEMS=="usb", ACTION=="change", RUN+="/bin/sh -c /root/"


load the rules:


udevadm control --reload-rules


then process its events to make sure actions are captured, provide automount (sometimes delayed) and optionally make sound when CD is inserted or ejected via AudioStation (just grab mp3 fast on,



if [[ $(df -t iso9660) ]]; then
    if [[ $(blkid /dev/sr0) ]]; then            #active and mounted -> eject
        eject /dev/cdrom
    else                                        #inactive but mounted -> unmount
        umount /dev/cdrom
    ###OPTIONAL SOUND nohup /volume1/@appstore/AudioStation/bin/mplayer /root/cdejected.mp3 2> /dev/null &
    if [[ $(blkid /dev/sr0) ]]; then            #active and unmounted -> mount
        mount /dev/cdrom && eject /dev/cdrom -i off ###OPTIONAL SOUND  && nohup /volume1/@appstore/AudioStation/bin/mplayer /root/cdinserted.mp3 2> /dev/null &
    else                                        #inactive and unmounted -> nothing
        sleep 0; #no action, chance of double event ("change") is here


however it's even more crippled, the triggers are fired often too late (or only when un/mounting on CLI) and never when doing manual button oepration, so we best periodically launch blkid or eject -a on /dev/cdrom via scheduler. I choose to fire the latter to save some cpu cycles as it's faster and i launch it each 30 seconds. In the end, this way we avoid CLI completely, it gets un/mounted automatically with little delay (~15sec, loading CD alone is 10sec so i think it doesn't matter).


> Some devices prevent manual buttons once mounted but users love them instead of CLI -> this is fixed during mount.

> CD will be inserted with physical tray push

> CD will be ejected with physical eject button OR if you love CLI: umount /dev/cdrom OR eject (no parameters)


Link to post
Share on other sites

nice, thats step one

any one adding automatic audio cd, video dvd and bluray ripping? ;-)


we could add the cd/dvd drivers permanently to the extended extra.lzma, loading them would not hurt any other functionality i guess

Link to post
Share on other sites

yeah :D  so you install transcode in ikpgui an set it up in the script above:




transcode -i /dev/cdrom/ -y ffmpeg -o /volume1/fastrips/$(blkid -o value -s LABEL /dev/cdrom).ext

file -s /dev/cdrom >> /volume1/fastrips/ripped.log




then insert another one...wait... another one...wait... just an example

Link to post
Share on other sites
  • 1 year later...
On 6/12/2020 at 2:30 AM, IG-88 said:

we could add the cd/dvd drivers permanently to the extended extra.lzma, loading them would not hurt any other functionality i guess

due to popular demand, we could really add those tiny files by default:)

On 1/10/2022 at 12:16 PM, gingerbeardman said:

Now to find out how to build or obtain cdrom.ko and sr_mod.ko

i've sent you

  • Thanks 1
Link to post
Share on other sites
  • 2 weeks later...



My system won't boot with this replacement extra.lzma. I did a simple swap of the file and made no other changes. It does not even show up as broadcasting its hostname. Interestingly my USB keyboard lights come on. 


I can get it to boot again by going back to the original extra.lzma.


to summarise...

original extra.lzma = boot

drivers page extra.lzma = boot

drivers page extra.lzma + sr_mod + cdrom = no boot


Any way I can give more detailed and useful debug data?



Edited by gingerbeardman
Link to post
Share on other sites
5 hours ago, gingerbeardman said:

Any way I can give more detailed and useful debug data?

the best way ist to have a serial port on the dsm system and use a null-modem cable and a console like putty on the other side (can be any serial port there even usb2serial will usually work), most people dont have that stuff around or (when younger) never even seen serial port/cable

if it a general problem i guess it should also happen when in install a 3617 on a test hardware (but that most like not happening before the weekend), i have serial port on my test systems so i can see whats going on while booting

  • Like 1
Link to post
Share on other sites
1 hour ago, gingerbeardman said:

i would have to buy usb2serial for my N54L.

just in case, a usb2serial is not working for dsm, that needs a "real" serial port, usb2serial adpter is just for the system receiving the serial output from a dsm system if that receiving system does not have a serial port (most notebooks don't have one nowadays)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.