Bug#565225: Resume device should be detected when creating initramfs, or not at all

2011-11-23 Thread Michael Prokop
* Sebastian Leske [Mon Nov 29, 2010 at 01:38:21 +0100]:

 I got bitten by this bug as well, similarly to Michael Conner above:
 I installed uswsusp to be able to hibernate/resume.
 s2disk worked flawlessly, but on booting the system simply did not
 bother to resume, booting normally instead.

 My analysis:

 After digging through the initramfs scripts, I discovered that this is
 because on booting resume is only triggered if $resume is set.

 As far as I understand, the initramfs takes $resume from the kernel
 command line (if set), and from /etc/initramfs-tools/conf.d/resume
 otherwise.

 In my case /etc/initramfs-tools/conf.d/resume did not exist.
 It should have been created by the preinst of initramfs-tools; however
 the preinst ( /var/lib/dpkg/info/initramfs-tools.preinst ) uses vol_id:
[...]
 This will always fail, because vol_id is no longer part of Debian (it was
 removed from udev for version 146-1, see 
 /usr/share/doc/udev/changelog.Debian.gz ).

This is no longer true for current versions of initramfs-tools,
JFYI.

 In summary:

 * Resume from hibernation will only work if /etc/initramfs-tools/conf.d/resume
   sets RESUME
 * However, there is no (working) code to write
   /etc/initramfs-tools/conf.d/resume, and no documentation explaining that it
   needs to be set manually to make resume work

 Thus, resume will probably fail to work in most cases.

 I believe there are actually several bugs here:

 1) The code in the preinst of initramfs-tools to detect the swap partition 
 does
not work, because it uses vol_id.

Fixed nowadays.

 2) Even if 1) were fixed, there may be cases where the swap partition is
incorrectly detected at installation time, or later changes. So fixing
preinst is not enough.
I agree with bug submitter jidanni that the swap partition should be 
 detected
when building the initramfs, not during preinst.
 3) Additionally, I don't quite understand why uswsusp refuses to resume if
$resume is not set (in 
 /usr/share/initramfs-tools/scripts/local-premount/uswsusp ). 
The script does not actually use the value of $resume, it just aborts if 
 it is not set :-(.
I guess this could be considered a bug in uswsusp; I can report it against
uswsusp if discussion of this bug indicates that this makes sense.


 To fix this, I would propose the following:

 * Drop the code in initramfs-tools.preinst which tries to write RESUME to
   /etc/initramfs-tools/conf.d/resume , which does not work anyway.

Sounds reasonable too me.
maximilian, what do you think of it?

 * Document (e.g. in /usr/share/doc/initramfs-tools/README.Debian ) that
   /etc/initramfs-tools/conf.d/resume can be used to set the resume device.
 * When building the initramfs, use the value from 
 /etc/initramfs-tools/conf.d/resume
   if it exists; otherwise try to find it yourself:
   - if /etc/uswsusp.conf exists, it probably makes sense to read it (resume 
 device =)
   - otherwise grab the current swap device (the config script from uswsusp
 already has code for that)
   This is still problematic if there is 1 swap device. Even better probably
   would be to use debconf to prompt for the resume device, if this is 
 practical...

 I am willing to help implement / test this, but first I'll wait for some
 feedback if I'm even on the right track :-).

Sorry that no one seemed to care about it for so long.

What could be a proper way to resolve that nowadays, taking uswsusp,
hibernate,... into account? dracut has some code in
modules.d/95resume/. IMHO we should find a way which avoids
duplicated code.

Related bug reports:

  http://bugs.debian.org/574653
  https://bugs.launchpad.net/ubuntu/+source/initramfs-tools/+bug/50437

regards,
-mika-


signature.asc
Description: Digital signature


Bug#565225: Resume device should be detected when creating initramfs, or not at all

2010-11-28 Thread Sebastian Leske
Hi,

I got bitten by this bug as well, similarly to Michael Conner above:
I installed uswsusp to be able to hibernate/resume.
s2disk worked flawlessly, but on booting the system simply did not
bother to resume, booting normally instead.

My analysis:

After digging through the initramfs scripts, I discovered that this is
because on booting resume is only triggered if $resume is set.

As far as I understand, the initramfs takes $resume from the kernel
command line (if set), and from /etc/initramfs-tools/conf.d/resume
otherwise.

In my case /etc/initramfs-tools/conf.d/resume did not exist.
It should have been created by the preinst of initramfs-tools; however
the preinst ( /var/lib/dpkg/info/initramfs-tools.preinst ) uses vol_id:
---snip
# First time install.  Can we autodetect the RESUME partition?
if [ -r /proc/swaps ]; then
RESUME=$(tail -n $(($(wc -l /proc/swaps | awk ' { print 
$1 } ') - 1)) /proc/swaps | sort -rk3 | head -n 1 | awk ' { print $1 } ')
if command -v vol_id /dev/null 21; then
UUID=$(vol_id -u $RESUME || true)
elif [ -x /lib/udev/vol_id ]; then
UUID=$(/lib/udev/vol_id -u $RESUME || true)
fi
if [ -n $UUID ]; then
RESUME=UUID=$UUID
fi
fi
---snap---

This will always fail, because vol_id is no longer part of Debian (it was
removed from udev for version 146-1, see 
/usr/share/doc/udev/changelog.Debian.gz ).

In summary:

* Resume from hibernation will only work if /etc/initramfs-tools/conf.d/resume
  sets RESUME
* However, there is no (working) code to write
  /etc/initramfs-tools/conf.d/resume, and no documentation explaining that it
  needs to be set manually to make resume work

Thus, resume will probably fail to work in most cases.

I believe there are actually several bugs here:

1) The code in the preinst of initramfs-tools to detect the swap partition does
   not work, because it uses vol_id.
2) Even if 1) were fixed, there may be cases where the swap partition is
   incorrectly detected at installation time, or later changes. So fixing
   preinst is not enough.
   I agree with bug submitter jidanni that the swap partition should be detected
   when building the initramfs, not during preinst.
3) Additionally, I don't quite understand why uswsusp refuses to resume if
   $resume is not set (in 
/usr/share/initramfs-tools/scripts/local-premount/uswsusp ). 
   The script does not actually use the value of $resume, it just aborts if it 
is not set :-(.
   I guess this could be considered a bug in uswsusp; I can report it against
   uswsusp if discussion of this bug indicates that this makes sense.


To fix this, I would propose the following:

* Drop the code in initramfs-tools.preinst which tries to write RESUME to
  /etc/initramfs-tools/conf.d/resume , which does not work anyway.
* Document (e.g. in /usr/share/doc/initramfs-tools/README.Debian ) that
  /etc/initramfs-tools/conf.d/resume can be used to set the resume device.
* When building the initramfs, use the value from 
/etc/initramfs-tools/conf.d/resume
  if it exists; otherwise try to find it yourself:
  - if /etc/uswsusp.conf exists, it probably makes sense to read it (resume 
device =)
  - otherwise grab the current swap device (the config script from uswsusp
already has code for that)
  This is still problematic if there is 1 swap device. Even better probably
  would be to use debconf to prompt for the resume device, if this is 
practical...

I am willing to help implement / test this, but first I'll wait for some
feedback if I'm even on the right track :-).

Greetings,

S.Leske



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org