Skip to content

Instantly share code, notes, and snippets.

@un1versal
Last active February 9, 2017 18:10
Show Gist options
  • Save un1versal/cb0ec01b7500f611da77 to your computer and use it in GitHub Desktop.
Save un1versal/cb0ec01b7500f611da77 to your computer and use it in GitHub Desktop.
normal boot and mouting cd/dvd media.
# Rule automount on add|change|remove cd/dvd
ACTION!="add|change|remove", GOTO="cdrom_end"
# Define Device and attributes.
SUBSYSTEM=="block", KERNEL=="sr*", ENV{ID_PATH}=="pci-0000:00:0b.0-scsi-1:0:0:0", ATTRS{type}=="5", ATTR{removable}=="1", ATTR{events}=="media_change eject_request"
# Mount on device attached from cold boot and at device change
ACTION=="add",KERNEL=="sr*", RUN+="/bin/mkdir -p '/media/cd-dvd'"
ACTION=="add",KERNEL=="sr*", RUN+="/bin/mount /dev/sr0 '/media/cd-dvd'"
ACTION=="change",KERNEL=="sr*", RUN+="/bin/mkdir -p '/media/cd-dvd'"
ACTION=="change",KERNEL=="sr*", RUN+="/bin/mount /dev/sr0 '/media/cd-dvd'"
# On remove unmount and remove directories
ACTION=="change",KERNEL=="sr*", RUN+="/bin/rmdir '/media/cd-dvd'"
ACTION=="remove",KERNEL=="sr*", RUN+="/bin/umount -l '/media/cd-dvd'", RUN+="/bin/rmdir '/media/cd-dvd'"
LABEL="cdrom_end"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment