Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[gentoo-user] hibernate... /bin/echo: write error: No such device

136 views
Skip to first unread message

Walter Dnes

unread,
Jul 27, 2022, 6:00:04 PM7/27/22
to
One of the last few items on the laptop setup. I emerged hibernate
and copied over the /etc/hibernate/ directory from my desktop. When I
try to hibernate the laptop, I get...

[thimk][root][~] hibernate
/bin/echo: write error: No such device

...with a beep, and the machine comes back. Grepping for the "echo"
command, I get...

[thimk][root][~] grep -r echo /etc/hibernate/
/etc/hibernate/common.conf:# OnSuspend 20 echo "Good night!"
/etc/hibernate/common.conf:# OnResume 20 echo "Good morning!"

The latest entries in /var/log/hibernate.log are...

Starting suspend at Wed Jul 27 05:00:47 PM EDT 2022
hibernate: [01] Executing CheckLastResume ...
hibernate: [01] Executing CheckRunlevel ...
hibernate: [01] Executing LockFileGet ...
hibernate: [01] Executing NewKernelFileCheck ...
hibernate: [10] Executing EnsureSysfsPowerStateCapable ...
hibernate: [11] Executing XHacksSuspendHook1 ...
hibernate: [59] Executing RemountXFSBootRO ...
hibernate: [89] Executing SaveKernelModprobe ...
hibernate: [91] Executing ModulesUnloadBlacklist ...
hibernate: [95] Executing XHacksSuspendHook2 ...
hibernate: [98] Executing CheckRunlevel ...
hibernate: [99] Executing DoSysfsPowerStateSuspend ...
hibernate: Activating sysfs power state disk ...
hibernate: [90] Executing ModulesLoad ...
hibernate: [89] Executing RestoreKernelModprobe ...
hibernate: [85] Executing XHacksResumeHook2 ...
hibernate: [70] Executing ClockRestore ...
hibernate: [59] Executing RemountXFSBootRW ...
hibernate: [11] Executing XHacksResumeHook1 ...
hibernate: [01] Executing NoteLastResume ...
hibernate: [01] Executing LockFilePut ...
Resumed at Wed Jul 27 05:00:50 PM EDT 2022


--
Walter Dnes <walt...@waltdnes.org>
I don't run "desktop environments"; I run useful applications

Adam Carter

unread,
Jul 27, 2022, 7:00:04 PM7/27/22
to
On Thu, Jul 28, 2022 at 7:53 AM Walter Dnes <walt...@waltdnes.org> wrote:
  One of the last few items on the laptop setup.  I emerged hibernate
and copied over the /etc/hibernate/ directory from my desktop.  When I
try to hibernate the laptop, I get...

[thimk][root][~] hibernate
/bin/echo: write error: No such device

Is the device there?

FYI,

$ ls -l /bin/echo
-rwxr-xr-x 1 root root 51256 May  5 11:58 /bin/echo*
$ file /bin/echo
/bin/echo: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, stripped
$ qfile /bin/echo
sys-apps/coreutils: /bin/echo

 echo is also a bash built in, but that wont be used since you're calling echo with the full path

Walter Dnes

unread,
Jul 27, 2022, 7:50:04 PM7/27/22
to
On Thu, Jul 28, 2022 at 08:57:35AM +1000, Adam Carter wrote
> On Thu, Jul 28, 2022 at 7:53 AM Walter Dnes <walt...@waltdnes.org> wrote:
>
> > One of the last few items on the laptop setup. I emerged hibernate
> > and copied over the /etc/hibernate/ directory from my desktop. When I
> > try to hibernate the laptop, I get...
> >
> > [thimk][root][~] hibernate
> > /bin/echo: write error: No such device
> >
>
> Is the device there?

I get the exact same diagnostic output as you. My interpretation is
not about the existance of "/bin/echo". I wonder if a script says
something like...

/bin/echo "something" > /sys/fubar

...and /sys/fubar is missing. The error message is not helpful.

Neil Bothwick

unread,
Jul 27, 2022, 7:50:04 PM7/27/22
to
On Wed, 27 Jul 2022 17:53:08 -0400, Walter Dnes wrote:

> One of the last few items on the laptop setup. I emerged hibernate
> and copied over the /etc/hibernate/ directory from my desktop. When I
> try to hibernate the laptop, I get...
>
> [thimk][root][~] hibernate
> /bin/echo: write error: No such device
>
> ...with a beep, and the machine comes back. Grepping for the "echo"
> command, I get...
>
> [thimk][root][~] grep -r echo /etc/hibernate/
> /etc/hibernate/common.conf:# OnSuspend 20 echo "Good night!"
> /etc/hibernate/common.conf:# OnResume 20 echo "Good morning!"

It's not coming from the config file because that isn't using the full
path, and these echo commands are commented out anyway.

I suspect one the modules hibernate calls is the culprit, possible the
last one mentioned in the logs. If the hibernate package is al scripts, I
don't use it myself, you could grep them to see what is calling /bin/echo
and where it is redirecting the output.

A missing device like this could be down to a missing kernel config item,
or a module not loaded.


--
Neil Bothwick

I'm not a complete idiot - several parts are missing.

J. Roeleveld

unread,
Aug 1, 2022, 6:10:04 AM8/1/22
to
I wonder at which point it actually shows that message.
I assume you are using:
# eix hibernate
* sys-power/hibernate-script
Available versions: 2.0-r6 {vim-syntax}
Homepage: https://gitlab.com/nigelcunningham/Hibernate-Script
Description: Hibernate script supporting multiple suspend methods


If yes, then try it with the verbose-option, maybe then you get to see where
that is generated.

Does suspend itself work? Or is the script failing as well?
Do you have hibernate configured in the kernel?

To check, you can try forcing hibernate manually by:

# echo disk > /sys/power/state

To resume, you will need to inform the kernel where to resume from.

Kernel command line option: resume="/path/to/swap/device"

If your swap-partition is a LV (eg, using LVM), you'll need to use an initrd
that will find the correct device-ID to pass to the resume-functionality.

I created my own init-ramfs for this and use the "hibernate" option provided
by kde/plasma. I can't remember when I last used a third-party script to get
this to work as it's generally quite simple to get working.

--
Joost

Jack

unread,
Aug 3, 2022, 7:00:03 PM8/3/22
to
On 2022.08.03 17:30, Walter Dnes wrote:
> Checking the obvious; "make menuconfig"...
>
> > Power management and ACPI options
> [ ] Suspend to RAM and standby
> [*] Hibernation (aka 'suspend to disk')
> [*] Userspace snapshot device
> (/dev/sda2) Default resume partition
>
> Checking where/how it'll suspend...
>
> cat /sys/power/state
> disk
>
> So far, so good. I was ssh'd in and I shrank the font size to
> "unreadable" and ran "hibernate --verbosity=4", to get debug level
> output. It captured "only" the last 519 lines of output, attached as
> errlog.txt.gz which I copy/pasted to vim on my desktop.
>
> Line 305 is where "DoSysfsPowerStateSuspend" starts
> Line 317 is the "/bin/echo -n disk" statement
>
> Next we look at file
> /usr/share/hibernate/scriptlets.d/sysfs_power_state
> which has a short function DoSysfsPowerStateSuspend(). Anyone
> remember
> ye old dayes of FORTRAN, where you'd throw in print statements to
> debug
> errors? I've added a few debug statements, like so...
>
> DoSysfsPowerStateSuspend() {
> if [ -z "$SYSFS_POWER_STATE_NO_SUSPEND" ] ; then
> vecho 1 "$EXE: Activating sysfs power state
> $USING_SYSFS_POWER_STATE ..."
> echo "1 ==> $USING_SYSFS_POWER_STATE"
> echo "2 ==> $SYSFS_POWER_STATE_POWERDOWN_METHOD"
> echo "3 ==> $SYSFS_POWERDOWN_METHOD_FILE"
> echo "4 ==> $SYSFS_POWER_STATE_FILE"
> [ -n "$SYSFS_POWER_STATE_POWERDOWN_METHOD" ] && \
> [ -f "$SYSFS_POWERDOWN_METHOD_FILE" ] && \
> /bin/echo $SYSFS_POWER_STATE_POWERDOWN_METHOD >
> $SYSFS_POWERDOWN_METHOD_FILE
> /bin/echo -n $USING_SYSFS_POWER_STATE >
> $SYSFS_POWER_STATE_FILE
> else
> vecho 1 "$EXE: Not actually suspending (--no-suspend given)"
> fi
> return 0
> }
>
> The output from hibernate is...
>
> 1 ==> disk
> 2 ==>
> 3 ==> /sys/power/disk
> 4 ==> /sys/power/state
> /bin/echo: write error: No such device
>
> No powerdown method? I added "resume=/dev/sda2" to lilo.conf and
> re-ran lilo. And now we cross the boundary from the ridiculous to the
> totally utterly sublime.
>
> [thimk][root][~] cat /sys/power/state
> disk
> [thimk][root][~] echo disk > /sys/power/state
> -bash: echo: write error: No such device
> [thimk][root][~] cat /sys/power/state
> disk
>
> WTF!!!
>
> --
> Walter Dnes <walt...@waltdnes.org>
> I don't run "desktop environments"; I run useful applications
No answers, but some thoughts. Remember the files in /sys/power are
not real files, they are created by sysfs (or something relying on
sysfs.) I wonder if something in the sysfstools package will let you
dig into why /sys seems or claims not to be there. The other
possibility is that whatever actual program is trying to do that write
has a bug and is recognizing some other condition as a "no such device"
error, but I suppose your last test disproves that.

Neil Bothwick

unread,
Aug 3, 2022, 7:20:05 PM8/3/22
to
> /bin/echo: write error: No such device

Which call to /bin/echo is failing? Instead of filling the script with
echo statements, add "set -x" near the top, then it will output each line
before executing it. That way you will not only see which echo call has
failed, but you will also see the values of the environments variables in
the call.


--
Neil Bothwick

Nothing is foolproof to a sufficiently talented fool.

Walter Dnes

unread,
Oct 11, 2022, 11:20:03 PM10/11/22
to
On Wed, Jul 27, 2022 at 05:53:08PM -0400, Walter Dnes wrote
> One of the last few items on the laptop setup. I emerged hibernate
> and copied over the /etc/hibernate/ directory from my desktop. When I
> try to hibernate the laptop, I get...
>
> [thimk][root][~] hibernate
> /bin/echo: write error: No such device
>
> ...with a beep, and the machine comes back.

PEBKAC++. Multiple facepalm. I outdid myself here. I got lazy on
the laptop install by copying config files from another machine... and
it came back to bite me. Here was my /etc/fstab ...

/dev/sda1 /boot vfat defaults,noatime 1 2
/dev/sda2 / ext3 noatime,nodiratime,async,user_xattr 0 1
/dev/sda3 none swap sw 0 0

...but, but, but... this is a used Lenovo laptop, too old for UEFI, with
only 75 gigs of disk and I've only got two partitions on it. I
corrected fstab to the proper...

/dev/sda1 / ext3 noatime,nodiratime,async,user_xattr 0 1
/dev/sda2 none swap sw 0 0

I'm surprised that LILO booted at all with the bad fstab. There were
only some error message lines that scrolled by really fast at bootup.
Otherwise a perfectly normal bootup. I finally got around to stopping
the laptop in mid-bootup tonight, and looking at the error message.
Something about fsck.ext3 not finding a magic superblock on /dev/sda2.
This prompted me to dig through the system and find the problem.

And, oh yeah, hibernate now works with one quirk. I assume hibernate
was reading the swap partition name from /etc/fstab for hibernation. Of
course it got "write error: No such device" when trying to save to a
non-existant swap partition /dev/sda3. The one quirk is that bootup
comes from the first menu item in LILO, unless I manually over-ride. I
can parse the boot image name from /proc/cmdline and feed it into "lilo -R".
Then I'll have to insert it into the hibernate shutdown scripts.

--
I've seen things, you people wouldn't believe; Gopher, Netscape with
frames, the first Browser Wars. Searching for pages with AltaVista,
pop-up windows self-replicating, trying to uninstall RealPlayer. All
those moments, will be lost in time like tears in rain... time to die.
0 new messages