Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 269603 - sys-kernel/genkernel: add DWIM magic for swsusp_resume
Summary: sys-kernel/genkernel: add DWIM magic for swsusp_resume
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2009-05-12 18:11 UTC by RB
Modified: 2010-12-10 08:06 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
foo (gk.patch,698 bytes, patch)
2009-07-19 19:48 UTC, Andrew Gaffney (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description RB 2009-05-12 18:11:18 UTC
Currently, swsusp_resume (defaults/initrd.scripts) uses 'ls -l' to discover the major/minor device nodes for REAL_RESUME.  If the user has an LVM swap partition and follows the normal naming conventions, they will pass '/dev/<volumegroup>/<logicalvolume>' as real_resume, which is a link and will not give the expected output, causing the resume to fail.

Adding '-L' to the 'ls' invocation fixes that and does not deviate from the current behavior for normal (non-link) device names.  No other modification is necessary.  Following patch is whitespace-mangled but shows the modification.

#########################
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index ae22dd5..b63568d 100755
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -858,7 +858,7 @@ rundebugshell() {
 
 swsusp_resume() {
        # determine swap resume partition
-       local device=$(ls -l "${REAL_RESUME}" | sed 's/\ */ /g' | cut -d \  -f 6-7 | sed 's/,\ */:/')
+       local device=$(ls -Ll "${REAL_RESUME}" | sed 's/\ */ /g' | cut -d \  -f 6-7 | sed 's/,\ */:/')
        [ -f /sys/power/resume ] && echo "${device}" > /sys/power/resume
        return 0
 }
Comment 1 Andrew Gaffney (RETIRED) gentoo-dev 2009-05-12 22:54:17 UTC
This has been fixed in git.
Comment 2 Raouf Bencheraiet 2009-06-07 21:13:28 UTC
(In reply to comment #1)
> This has been fixed in git.
> 

one thoing though the output of that line regardeless of the -L presence doesn't give the majo/minor number  but r:w (at lease on a live system not in the initramfs)
cerberusi kenshin # ls -lH /dev/vg0/swap | sed 's/\ */ /g' | cut -d \  -f 6-7 | sed 's/,\ */:/'
r w

ls -lL /dev/vg0/swap 
brw-rw---- 1 root disk 254, 1 Jun  5 21:54 /dev/vg0/swap

before dm-crypt/lvm resume worked perfectly but I guess that the result of this line didn't matter as I setup the default resume resume partion in kernel 
Comment 3 Raouf Bencheraiet 2009-06-07 21:51:28 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > This has been fixed in git.
> > 
> 
> one thoing though the output of that line regardeless of the -L presence
> doesn't give the majo/minor number  but r:w (at lease on a live system not in
> the initramfs)
> cerberusi kenshin # ls -lH /dev/vg0/swap | sed 's/\ */ /g' | cut -d \  -f 6-7 |
> sed 's/,\ */:/'
> r w
> 
> ls -lL /dev/vg0/swap 
> brw-rw---- 1 root disk 254, 1 Jun  5 21:54 /dev/vg0/swap
> 
> before dm-crypt/lvm resume worked perfectly but I guess that the result of this
> line didn't matter as I setup the default resume resume partion in kernel 
> 

ls -lH /dev/vg0/swap | sed 's/\ \+/ /g' | cut -d \  -f 5-6 |sed 's/,\ /:/'
works perfectly
Comment 4 RB 2009-06-09 05:14:14 UTC
Are both of you testing this with the busybox binaries that are actually part of the initrd environment?  I started down the path of comment #3, but arrived at my original solution by testing with the generated environment in a chroot.
Comment 5 RB 2009-06-09 05:17:01 UTC
Meh, for some reason I saw two posters.

Regardless, I'm doing dm-crypt/lvm resume right now with this fix with no issue.  Can you elaborate what your setup is and what error you're seeing?
Comment 6 pille 2009-07-18 13:53:55 UTC
i did not read this bug-report before, but ran into the same problem.
my solution was
ls -lL "${REAL_RESUME}" | sed 's/\  */ /g' | cut -d \  -f 5-6 | sed 's/,\ */:/'

tested with busybox ls.
Comment 7 Andrew Gaffney (RETIRED) gentoo-dev 2009-07-19 18:01:01 UTC
I'm confused about what the actual issue is here. I don't use this feature, so I can't test it myself.
Comment 8 pille 2009-07-19 18:29:13 UTC
the actual issue was the missing '-L' option for ls.
resume with /dev/mapper/vg0-swap was possible, while /dev/vg0/swap was not.

it seems that after some time (between comment #1 and #2) the output format of busybox ls changed, so resuming with real_resume=... broke.
this may be a completely new bug-report, but the same line was affected and it is still open ;-)

both the solutions presented in comments #3 and #6 are working on my box.
Comment 9 Andrew Gaffney (RETIRED) gentoo-dev 2009-07-19 19:21:52 UTC
What's the point of this? Is it just getting the "real" device that the symlink points to? Is there any reason we can't use readlink here?
Comment 10 pille 2009-07-19 19:30:45 UTC
you cannot be sure that real_resume is a symlink.
it may be something like /dev/sdb1, too.

the solutions provided above don't care, whether it's a link, or the real device. what's needed is major/minor of the blockdevie to resume from. 
Comment 11 Andrew Gaffney (RETIRED) gentoo-dev 2009-07-19 19:48:23 UTC
Created attachment 198499 [details, diff]
foo

I came up with an alternative solution that's a little "cleaner". I'm attaching the patch, but it's also in git. Please test it by emerging genkernel-9999.
Comment 12 RB 2009-07-19 20:07:35 UTC
I'm indifferent as what work you do to get the actual device name (be that ls -L or get_real_filename), but AFAICT the solution needs to provide the device in the "major:minor" format, which the proposed patch does not yet do.
Comment 13 Andrew Gaffney (RETIRED) gentoo-dev 2009-07-19 22:11:41 UTC
Then I misunderstood what the code was doing. I've reverted to the previous commit, where I applied the solution from comment 6.
Comment 14 Sebastian Pipping gentoo-dev 2010-12-10 08:06:22 UTC
(In reply to comment #13)
> I've reverted to the previous commit, where I applied the solution from comment 6.

Due to the date of the last comment on this bug I assume that feature to be included in 3.4.10.907 or an earlier release of genkernel.

Closing, please re-open as needed.