Don't try to eject non-ejectable devices

Bug #600740 reported by Michael Terry
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
casper (Ubuntu)
Fix Released
High
Stéphane Graber

Bug Description

Binary package hint: casper

I was debugging a shutdown issue on a system where there was a ntfs recovery partition on the disk. That is, a casper system and a ubiquity install on, say, /dev/sda1.

During shutdown, the machine would just stop and not finish shutting down. I didn't see any error or message why. It turns out that casper was trying to tell me to eject the machine and press Enter. But the message wasn't getting to the console (not sure why) and I didn't know what it was waiting for.

The no-message issue is a separate bug, but not a useful one for me to report because my setup is weird and I didn't debug it further.

But, I did add a workaround for why we were even trying to eject in the first place. It seems to me that casper shouldn't try to eject a non-ejectable device like my /dev/sda1. So I added the hacky solution below. It should be possible to write something really sexy using udisks or such, that asks if something is ejectable, right?

diff -Nru casper-1.236/debian/casper.init casper-1.236test1/debian/casper.init
--- casper-1.236/debian/casper.init 2010-04-12 15:57:54.000000000 +0100
+++ casper-1.236test1/debian/casper.init 2010-07-01 02:02:58.000000000 +0100
@@ -93,6 +93,12 @@
         cache_path "$path"
     done

+ cddev=$(mount | grep /cdrom | cut -d' ' -f1 | tr -d 0-9)
+ # ideally we'd check if device is non-ejectable, but for now just check if it's sda
+ if [ "$cddev" = "/dev/sda" ]; then
+ return
+ fi
+
     eject -p -m /cdrom >/dev/null 2>&1

     [ "$prompt" ] || return 0

Tags: oem-services

Related branches

Michael Terry (mterry)
tags: added: oem-services
Changed in casper (Ubuntu):
importance: Undecided → High
Revision history for this message
Stéphane Graber (stgraber) wrote :

I commited (to the packaging branch) a similar change using udisks (when present), checking for the "removable" flag.
If set to 0 for the device we're about to eject, it skips the eject call and the prompt.

Diff below:
=== modified file 'debian/casper.init'
--- debian/casper.init 2011-12-14 18:28:01 +0000
+++ debian/casper.init 2011-12-14 20:35:12 +0000
@@ -93,6 +93,14 @@
         cache_path "$path"
     done

+ # If the device isn't marked as removable, skip the prompt
+ if which udisks > /dev/null; then
+ device="$(grep " /cdrom " /proc/mounts | cut -d' ' -f1)" || device=
+ if [ -n "$device" ] && [ "$(udisks --show-info $device | grep removable | awk '{print $NF}')" = "0" ]; then
+ return 0
+ fi
+ fi
+
     eject -p -m /cdrom >/dev/null 2>&1

     [ "$prompt" ] || return 0

Changed in casper (Ubuntu):
status: New → Fix Committed
assignee: nobody → Stéphane Graber (stgraber)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package casper - 1.295

---------------
casper (1.295) precise; urgency=low

  * Convert keys from gconf to gsettings:
    - 22gnome_panel_data: disable_lock_screen (LP: #610345)
    - 15autologin: suppress-logout-menuitem (indicator)
  * Syntax cleanup in debian/casper.init (replacing tabs by spaces)
  * Base the hostname and username on the media name (LP: #290351)
  * If udisks is present and considers a device has non-removable
    then don't call eject and don't show the prompt. (LP: #600740)
 -- Stephane Graber <email address hidden> Wed, 14 Dec 2011 15:50:44 -0500

Changed in casper (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.