RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1575952 - DVD can be ejected even though it is mounted
Summary: DVD can be ejected even though it is mounted
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: systemd
Version: 7.5
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: systemd-maint
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-08 11:42 UTC by Renaud Métrich
Modified: 2021-09-09 13:58 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-02-18 17:49:58 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3442081 0 None None None 2018-05-14 09:12:47 UTC

Description Renaud Métrich 2018-05-08 11:42:42 UTC
Description of problem:

On RHEL6, when the DVD is mounted, it is not possible to eject it, because the kernel locks it.

On RHEL7, whatever the DVD state is, it is always possible to eject it through pushing the Eject button of the DVD tray.
This leads to the mount point to get a I/O error upon access.

Is this expected? If so, why the behaviour has been changed?


Version-Release number of selected component (if applicable):

systemd


How reproducible:

Always


Steps to Reproduce:
1. Mount a DVD
2. Push the eject button
3. Access the mountpoint

Actual results:

I/O error is returned


Expected results:

DVD not ejected and no I/O error


Additional info:

Digging into the code, we can see that in RHEL7, the DVD is handled by the following udev rule:

-------- 8< ---------------- 8< ---------------- 8< --------
# cat /lib/udev/rules.d/60-cdrom_id.rules
...
# media eject button pressed
ENV{DISK_EJECT_REQUEST}=="?*", RUN+="cdrom_id --eject-media $devnode", GOTO="cdrom_end"

# import device and media properties and lock tray to
# enable the receiving of media eject button events
IMPORT{program}="cdrom_id --lock-media $devnode"
...
-------- 8< ---------------- 8< ---------------- 8< --------

The "cdrom_id" utility is responsible for locking the media, unlocking it and ejecting.

Upon pushing the Eject button, a "DISK_EJECT_REQUEST=1" event is sent by the kernel, causing "cdrom_id --eject-media $devnode" to be executed.
This code does unlock the media, then ejects the tray.

This explains the new behaviour: unlocking the media always works for some reason (likely because the DVD is mounted read-only), hence eject works afterwards, even if the DVD remains mounted, leading to some I/O error upon access, as shown in the scenario below:

-------- 8< ---------------- 8< ---------------- 8< --------
# mount /dev/sr1 /mnt
mount: /dev/sr1 is write-protected, mounting read-only

--> push Eject button

# ls /mnt
ls: reading directory /mnt: Input/output error
-------- 8< ---------------- 8< ---------------- 8< --------

Comment 2 Renaud Métrich 2018-05-08 11:44:09 UTC
A workaround is to subsume the standard udev rule by creating the following script in /usr/local/bin:

-------- 8< ---------------- 8< ---------------- 8< --------
# cat /usr/local/bin/eject_cdrom.sh
#!/bin/bash
# Script locking the CD when mounted.
# For demo purposes only, not supported by Red Hat in any way!!!

DEVICE="$1"

if ! awk "\$1 == \"$DEVICE\" { exit 1 }" /proc/mounts; then
	logger -t "$(basename $0)" "There is a CDROM, ignoring EJECT request."
else
	/usr/lib/udev/cdrom_id --eject-media $DEVICE
fi

# chmod +x /usr/local/bin/eject_cdrom.sh
-------- 8< ---------------- 8< ---------------- 8< --------

Then, copy the /lib/udev/rules.d/60-cdrom_id.rules file into /etc/udev/rules.d so that udev uses the latter as an overload (it will disable the original rules in /lib/udev/rules.d/60-cdrom_id.rules):

-------- 8< ---------------- 8< ---------------- 8< --------
# cp /lib/udev/rules.d/60-cdrom_id.rules /etc/udev/rules.d/
-------- 8< ---------------- 8< ---------------- 8< --------

Finally, edit the /etc/udev/rules.d/60-cdrom_id.rules file to use the /usr/local/bin/eject_cdrom.sh command instead of the original "cdrom_id" command on the DISK_EJECT_REQUEST line:

-------- 8< ---------------- 8< ---------------- 8< --------
ENV{DISK_EJECT_REQUEST}=="?*", RUN+="/usr/local/bin/eject_cdrom.sh $devnode", GOTO="cdrom_end"
-------- 8< ---------------- 8< ---------------- 8< --------

You may now try to monitor the system logs.
If you have a mounted DVD and press the Eject button, nothing will happen, except the log message shown below:

-------- 8< ---------------- 8< ---------------- 8< --------
eject_cdrom.sh[13512]: There is a CDROM, ignoring EJECT request.
-------- 8< ---------------- 8< ---------------- 8< --------

If you have an unmounted DVD and press the Eject button, the button should work.

Comment 3 Lukáš Nykrýn 2018-05-09 07:50:28 UTC
Yep, this change was intentional. Users quite often think that the button on cd-rom is more hardware-ish and were wondering why they can't open it in some cases. So I would even say that the new behaviour matches the behaviour of floppy driver or usb flash drives :-).

Anyway, unless there is a strong push to change this I would like to keep the current state and create a KB article with your workaround as an official suggestion for those that want the opposite.

Comment 6 Kyle Walker 2020-02-18 17:49:58 UTC
Based on the feedback in comment 3, I am closing this as NOTABUG.

Please utilize the guidance in the following article should the alternative described behaviour be needed:

    [RHEL7] How to lock the DVD tray when a DVD is mounted - Red Hat Customer Portal
    https://access.redhat.com/solutions/3442081


Note You need to log in before you can comment on or make changes to this bug.