Don't try to eject non-ejectable devices
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-
--- casper-
+++ casper-
@@ -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
Related branches
tags: | added: oem-services |
Changed in casper (Ubuntu): | |
importance: | Undecided → High |
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: casper. init'
=== modified file 'debian/
--- 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