can't reboot when root fs mounted r/o

Bug #206217 reported by ski
2
Affects Status Importance Assigned to Milestone
laptop-mode-tools (Debian)
Fix Released
Unknown
laptop-mode-tools (Ubuntu)
Fix Released
Undecided
Unassigned
Nominated for Hardy by Tormod Volden
sysvinit (Ubuntu)
Invalid
Undecided
Unassigned
Nominated for Hardy by Tormod Volden

Bug Description

Binary package hint: initscripts

Some init script is hanging when you try to execute reboot from a read only root fs.

This is especially problematic if you have errors on your root patition, and have booted to single user mode, where you ro,remount'd root and then fsck'd it (and fsck reported errors).

Details:

root@ganiodayo:/# mount | grep sda6
/dev/sda6 on / type ext3 (ro,relatime,errors=remount-ro)
root@ganiodayo:/# reboot
root@ganiodayo:/# init: rcS-sulogin main process (5525) killed by TERM signal
 * Stopping GNOME Display Manager... [ OK ]
 * Stopping Avahi mDNS/DNS-SD Daemon avahi-daemon [ OK ]
 * Stopping DHCP D-Bus daemon dhcdbd [ OK ]
 * Stopping NFS commom utilities [ OK ]
 * Stopping Postfix Mail Transport Agent postfix [ OK ]
 * Stopping VirtualBox kernel module vboxdrv [ OK ]
Shutting down VirtualBox host networking...done
 * Stopping MySQL database server mysqld [ OK ]
 * Saving the system clock
hwclock: Could not open file with the clock adjstment parameters in it (/etc/adjtime) for writing, errno=30: Read-only file system.
Drift adjustment parameters not updated.
 * Stopping firewall: ufw... [ OK ]
 * Shutting down ALSA...
 * warning: 'alsactl store' failed with error message 'alsactl: save_state:1278: Cannot open /var/lib/alsa/asound.state for writing: Read-only file system'...
                                                                        [fail]
 * Unmounting any overflow tmpfs fro m/tmp... [ OK ]
mktemp: cannot create temp file /tmp/tmp.JCaeUn5935: Read-only file system
 * Disabling laptop mode:
/etc/rc6.d/K99laptop-mode: 81: cannot create : Directory nonexistent

( hang )

Revision history for this message
ski (skibrianski) wrote :

Bump. This is urgent - people can't boot to single user mode, remount r/o, fsck, and then reboot.

Revision history for this message
ski (skibrianski) wrote :

I've done a little more debugging, the results of which I'll post later, but for the moment just wanted to note that this is exacerbated by the fact that magic sysrq keys don't work in single user mode for some reason.

Revision history for this message
ski (skibrianski) wrote :

Here's an image of the freeze I transcribed above (a different run), in case I made any important typos.

Revision history for this message
ski (skibrianski) wrote :

The following is a hackish fix which disables the log_action_end_msg, but fixes the problem. I suspect the problem is in /lib/lsb/init-functions, but I'm not having much luck determining where so far.

Revision history for this message
ski (skibrianski) wrote :

And here's a screenshot of what rebooting from a r/o fs looks like with my hackish patch applied (image attached in case there are any typing errors on my part. I disabled some debug "echo here"s in the patch).

...
* Disabling laptop mode...
/etc/rc6.d/K99laptop-mode: 85: cannot create: Directory nonexistent.
rm: missing operand
Try `rm --help' for more information.
* Terminating all remaining processes... [OK]
...

(and reboot finishes properly without hanging).

I should also note that it might be the filesystem containing /var that is the problem - I have only / and /home on this machine, so I haven't debugged that further.

Revision history for this message
ski (skibrianski) wrote :

This also affects a coworker of mine, marking confirmed.

Changed in laptop-mode-tools:
status: New → Confirmed
Revision history for this message
Tormod Volden (tormodvolden) wrote :

Closing the laptop-mode-tools task, I don't think there's anything to fix there.

Changed in laptop-mode-tools:
status: Confirmed → Invalid
Revision history for this message
ski (skibrianski) wrote :

Seems to me that whomever "owns" /etc/init.d/laptop-mode is the group responsible for this bug, as I have no problems with any other init scripts. If not, do you have any suggestions for what the sysvinit folks need to track down, Tormod? Thanks.

Revision history for this message
ski (skibrianski) wrote :

This is endemic on all hardy machines in our office, some upgraded, some freshly installed. Marking confirmed.

Changed in sysvinit:
status: New → Confirmed
Revision history for this message
Tormod Volden (tormodvolden) wrote :

Sorry, I thought it was just complaining without doing more harm. But actually, if the /tmp filesystem is not writeable, mktemp fails and TEMPFILE is empty. Calling cat with the empty argument makes cat wait for input on stdin.

Changed in laptop-mode-tools:
assignee: nobody → tormodvolden
status: Invalid → In Progress
Changed in sysvinit:
status: Confirmed → Invalid
Revision history for this message
Tormod Volden (tormodvolden) wrote :

ski, can you try this patch? After verification, I'll make a debdiff and we should try to get an SRU for this.

Revision history for this message
Tormod Volden (tormodvolden) wrote :

The previous patch won't apply on the Hardy version, since that one has a dangling LF on line 58.

Revision history for this message
ski (skibrianski) wrote :

Ah ha, good sleuthing Tormod. I just tried the (second) patch - works like a charm. Thanks a bunch.

Changed in laptop-mode-tools:
status: Unknown → New
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package laptop-mode-tools - 1.42-1ubuntu1

---------------
laptop-mode-tools (1.42-1ubuntu1) intrepid; urgency=low

  * Merge from debian unstable (LP: #229579), remaining changes:
    - etc/init.d/laptop-mode: Check if laptop mode is disabled in
      /etc/default/laptop-mode (that's the file laptop_mode looks into, too,
      but it incorrectly evaluates the ENABLE_LAPTOP_MODE setting) as well
      as in /etc/default/acpi-support.
    - /usr/sbin/laptop_mode: Do not parse arguments, ignore "force" and
      "init" and let start/stop mean enable/disable.
    - /usr/sbin/laptop_mode: Do not read $ACTIVATE_WITH_POSSIBLE_DATA_LOSS
      from /var/run/laptop-mode-state to see if state has changed.
    - debian/rules: Do not ship acpi/apm scripts (we handle that ourselves)
    - debian/laptop-mode-tools.preinst: Remove any old acpi/apm scripts
    - debian/laptop-mode-tools.postinst: Create /etc/default/laptop-mode
      (with ENABLE_LAPTOP_MODE=false) if the file does not exist yet and we
      are on ppc.
    - debian/control: Change maintainer
  * Use #DEBHELPER# in .postinst and .preinst (LP: #226788)
  * Avoid using temporary files in init script to avoid hangs on
    shutdown if filesystem is read-only (LP: #206217)
  * Also accept "stop" as second argument since the init script
    calls laptop_mode with "init stop"

laptop-mode-tools (1.42-1) unstable; urgency=low

  * New upstream version 1.42:
    * Remove "echo -e" bashism in lm-profiler. Closes: #480606.
    * Allow different names for AC adapter in /sys/class/power_supply.
      Closes: #478937.
    * Add "hal-polling" module to control HAL polling of CD/DVD drives. (Taken
      from powertop tips.) Closes: #438782.
    * Add "bluetooth" module to disable bluetooth in battery mode. (Taken from
      powertop tips.)

laptop-mode-tools (1.41-1) unstable; urgency=high

  * New upstream version 1.41:
    * Support energy_* in /sys/class/power_supply interface. Closes: #477118.
    * Rename module "core" to "laptop-mode". Closes: #477310.
    * Add missing assignment to ACTIVATE_WITH_POSSIBLE_DATA_LOSS.
      Closes: #477172.

laptop-mode-tools (1.40-1) unstable; urgency=high

  * Upgrade standards version to 3.7.3.
  * Add hal to recommends due to upstream changes.
  * New upstream version 1.40:
    * Add support for getting lid button state from HAL instead of from
      /proc/acpi.
    * Support /sys/class/power_supply interface to determine battery levels.
      Closes: #475926
    * Add generic support for config file swapping. Closes: #475304
    * Add module for iwlwifi power management. Closes: #475407
    * Fully modularized configuration.

laptop-mode-tools (1.36-1) unstable; urgency=low

  * New upstream version 1.36.
  * Init script LSB header: depend on remote_fs instead of local_fs.
    Closes: #468657.
  * Remove ^M from /etc/init.d/laptop-mode. Closes: #459422.
  * Change package description to say "X11" instead of "X Windows".
    Closes: #464066.
  * Get rid of empty /usr/bin directory in package. (lintian warning)

 -- Tormod Volden <email address hidden> Mon, 12 May 2008 16:24:50 +0200

Changed in laptop-mode-tools:
status: In Progress → Fix Released
Changed in laptop-mode-tools:
status: New → Fix Released
Revision history for this message
ski (skibrianski) wrote :

Can you apply this to hardy before 8.04.1? The patch is quite simple, and the problem quite tedious.

Revision history for this message
Tormod Volden (tormodvolden) wrote :

Sorry, it is too late for 8.04.1, but we can try to make an SRU for Hardy anyway. It will need a debdiff against the current Hardy version and the procedure from https://wiki.ubuntu.com/StableReleaseUpdates. Contributions are welcome.

Revision history for this message
Tormod Volden (tormodvolden) wrote :

 laptop-mode-tools (1.35-1ubuntu2) hardy-proposed; urgency=low
 .
   * Avoid using temporary files in init script to avoid hangs on
     shutdown if filesystem is read-only (LP: #206217)

Changed in laptop-mode-tools:
assignee: tormodvolden → nobody
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.