Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Hibernate to swapfile
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
GenMed
n00b
n00b


Joined: 05 Apr 2015
Posts: 6

PostPosted: Fri Apr 17, 2015 11:10 am    Post subject: Hibernate to swapfile Reply with quote

Using archwiki I have created swapfile:
Code:
fallocate -l 6G /swap/swapfile
chmod 600 /swap/swapfile
mkswap /swap/swapfile
swapon /swap/swapfile

and added "/swap/swapfile none swap sw 0 0" to fstab.

When I run pm-hibernate screen becomes black for a moment and then resumes to desktop and then shutdown the laptop. Also there are no writings in console.
Also I added "resume=/dev/sda3 resume_offset=419840" to load parameters in bootmanager.
I get resume offset with "filefrag -v /swap/swapfile" which show:
Code:
Filesystem type is: ef53
File size of /swap/swapfile is 6442450944 (1572864 blocks of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..       0:     419840..    419840:      1:           


After rebooting dmesg show:
Code:
[    1.750401] PM: Hibernation image partition 8:3 present
[    1.750405] PM: Looking for hibernation image.
[    1.772558] PM: Image signature found, resuming
[    1.772680] PM: Preparing processes for restore.
[    1.772682] Freezing user space processes ... (elapsed 0.000 seconds) done.
[    1.775171] PM: Loading hibernation image.
[    1.775277] PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
[    1.775279] PM: Marking nosave pages: [mem 0x0009f000-0x000fffff]
[    1.775284] PM: Marking nosave pages: [mem 0x20000000-0x201fffff]
[    1.775298] PM: Marking nosave pages: [mem 0x40004000-0x40004fff]
[    1.775300] PM: Marking nosave pages: [mem 0xbeb91000-0xbeb91fff]
[    1.775302] PM: Marking nosave pages: [mem 0xbeba1000-0xbeba2fff]
[    1.775303] PM: Marking nosave pages: [mem 0xbebb8000-0xbebb8fff]
[    1.775305] PM: Marking nosave pages: [mem 0xbec1c000-0xbec1cfff]
[    1.775306] PM: Marking nosave pages: [mem 0xbec28000-0xbec28fff]
[    1.775308] PM: Marking nosave pages: [mem 0xc9746000-0xc9d49fff]
[    1.775347] PM: Marking nosave pages: [mem 0xc9d60000-0xc9d65fff]
[    1.775349] PM: Marking nosave pages: [mem 0xc9d68000-0xc9d71fff]
[    1.775351] PM: Marking nosave pages: [mem 0xc9f06000-0xc9f09fff]
[    1.775353] PM: Marking nosave pages: [mem 0xc9f53000-0xc9f78fff]
[    1.775355] PM: Marking nosave pages: [mem 0xc9f7c000-0xc9f7dfff]
[    1.775357] PM: Marking nosave pages: [mem 0xc9f95000-0xc9f9afff]
[    1.775359] PM: Marking nosave pages: [mem 0xc9fa3000-0xc9fa3fff]
[    1.775360] PM: Marking nosave pages: [mem 0xc9fb3000-0xc9fb3fff]
[    1.775362] PM: Marking nosave pages: [mem 0xc9fbf000-0xc9fc3fff]
[    1.775364] PM: Marking nosave pages: [mem 0xc9ff0000-0xc9ff0fff]
[    1.775365] PM: Marking nosave pages: [mem 0xca001000-0xca027fff]
[    1.775368] PM: Marking nosave pages: [mem 0xca03b000-0xca03bfff]
[    1.775369] PM: Marking nosave pages: [mem 0xca03d000-0xca03efff]
[    1.775371] PM: Marking nosave pages: [mem 0xca040000-0xca044fff]
[    1.775372] PM: Marking nosave pages: [mem 0xca05c000-0xca884fff]
[    1.775425] PM: Marking nosave pages: [mem 0xca886000-0xca8c8fff]
[    1.775428] PM: Marking nosave pages: [mem 0xcacd8000-0xcaff3fff]
[    1.775449] PM: Marking nosave pages: [mem 0xcb000000-0xffffffff]
[    1.776811] PM: Basic memory bitmaps created
[    2.364090] PM: Using 3 thread(s) for decompression.
PM: Loading and decompressing image data (130403 pages)...
[    2.450448] Switched to clocksource tsc
[    2.546423] random: nonblocking pool is initialized
[    2.780457] PM: Image loading progress:   0%
[    2.838703] PM: 0xbeb91000 in e820 nosave region: [mem 0xbeb91000-0xbeb91fff]
[    2.842036] PM: Read 521612 kbytes in 0.47 seconds (1109.81 MB/s)
[    2.844912] PM: Error -14 resuming
[    2.844959] PM: Failed to load hibernation image, recovering.
[    2.847551] PM: Basic memory bitmaps freed
[    2.847553] Restarting tasks ... done.
[    2.849329] PM: Hibernation image not present or could not be loaded.
[    2.849343] ALSA device list:
[    2.851067]   #0: HDA Intel PCH at 0xf7a10000 irq 29
[    2.853666] Freeing unused kernel memory: 1060K (ffffffff81ede000 - ffffffff81fe7000)
[    2.855429] Write protecting the kernel read-only data: 14336k
[    2.861339] Freeing unused kernel memory: 1692K (ffff880001a59000 - ffff880001c00000)
[    2.864346] Freeing unused kernel memory: 528K (ffff880001f7c000 - ffff880002000000)
[    2.874938] mount (1327) used greatest stack depth: 13976 bytes left
[    2.878849] echo (1334) used greatest stack depth: 13856 bytes left
[    3.234003] EXT4-fs (sda3): INFO: recovery required on readonly filesystem
[    3.234006] EXT4-fs (sda3): write access will be enabled during recovery
[    3.519251] EXT4-fs (sda3): orphan cleanup on readonly fs
[    3.519409] EXT4-fs (sda3): 7 orphan inodes deleted
[    3.519412] EXT4-fs (sda3): recovery complete
[    3.607333] EXT4-fs (sda3): mounted filesystem with ordered data mode. Opts: (null)

What is wrong?
Back to top
View user's profile Send private message
eccerr0r
Advocate
Advocate


Joined: 01 Jul 2004
Posts: 4395
Location: USA

PostPosted: Tue Apr 21, 2015 8:56 pm    Post subject: Reply with quote

I've only used 'dd' to create swap files, unsure if fallocate somehow make sparse files and what happens if you swap to a sparse file.

The data you have here looks right, these are exactly what I use minus the fallocate... and mine seems to be working...

(just to rule out silly stuff, you didn't change or BIOS didn't change your memory configuration before resume?)
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed to be advocating?
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2512
Location: Germany

PostPosted: Wed Apr 22, 2015 10:42 am    Post subject: Reply with quote

It failed to load the hibernation image for some reason, I don't know why. (look up what error -14 means)

The filesystem errors etc. are a consequence of that, after all if you hibernate, stuff is "still mounted" so if resume fails, without restoring the old state, it looks like an unexpected power outage.

Quote:
The data you have here looks right, these are exactly what I use minus the fallocate...


When using swap files you must use fallocate, since otherwise you'd have to mount the already mounted filesystem to get at the swapfile.

I'd avoid swap files in general if possible, they add unnecessary complexity to an already critical task...
Back to top
View user's profile Send private message
eccerr0r
Advocate
Advocate


Joined: 01 Jul 2004
Posts: 4395
Location: USA

PostPosted: Wed Apr 22, 2015 2:39 pm    Post subject: Reply with quote

frostschutz wrote:
When using swap files you must use fallocate, since otherwise you'd have to mount the already mounted filesystem to get at the swapfile.

This is wrong with the word "must" because I have it working without using fallocate. Granted, using fallocate is generally safer than using dd and theoretically either should work. I just am worried about creating sparse files, who knows what the code will do when it encounters them.
Quote:
I'd avoid swap files in general if possible, they add unnecessary complexity to an already critical task...

This is generally good advice but suspending to files does work, and I have multiple installations with it working.

My i7-2700k, 180GB SSD EXT4 -> swap file
My eeePC 32GB SSD EXT3 -> swap file
My USB 30GB bootable external HDD -> swap file
My USB 16GB bootable flash stick with 12GB Gentoo install has a swapfile within... even this, suspend to swap works...

I use custom initramfs for all (the same image, for the most part!), but the first two aren't absolutely necessary. The key advantage to suspend to swapfile is that you can dynamically change the swapfile size easily if you need more for RAM upgrades, and can even delete the swapfile if you need more disk space within the partition.

Looking through the code, error -14 means it could not allocate memory, which is why I'd suspect some configuration changed or there was corruption in the swap image.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed to be advocating?
Back to top
View user's profile Send private message
CaptainBlood
Guru
Guru


Joined: 24 Jan 2010
Posts: 449

PostPosted: Thu Apr 23, 2015 11:39 am    Post subject: Reply with quote

Since hibernate has been working here for a long time, I can hardly expertise your situation.
Still I recall same symptoms appeared on the way to activate HIBERNATION & "SUSPENDING TO RAM" features.

Nevertheless, do you have CONFIG_HIBERTATION & CONFIG_PM_STD_PARTITION set in menuconfig, as it seems advised when not required?
(Here we also have CONFIG_SUSPEND, probably aside of topic)

Thks 4 ur attention.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2512
Location: Germany

PostPosted: Fri Apr 24, 2015 1:36 pm    Post subject: Reply with quote

eccerr0r wrote:
This is wrong with the word "must" because I have it working without using fallocate.


Sorry, my mistake, what I meant was grabbing the file extents with filefrag or whatever.

How you create the file is up to you as long as it ends up allocated at a specific extent w/o fragmentation, so it can be accessed directly without mounting the filesystem.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum