Re: To swap or not to swap ;-) (was RE: To lvm or not to l…

Top Page
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Matt Graham
To: Main PLUG discussion list
Subject: Re: To swap or not to swap ;-) (was RE: To lvm or not to lvm)
On 2018-09-21 13:51, Matt Graham wrote:
> On 2018-09-21 13:08, Carruth, Rusty wrote:
>> 2 - swap files work fine, but can't be used for suspend/hibernate.
> /usr/src/linux/Documentation/power/swsusp-and-swap-files.txt says
> that you can do this. I have never tried to do this. I guess it's
> time to run some experiments?

0. Create a swap file somewhere.  I used /mnt/temp/swapfile here.
1. swapon /mnt/temp/swapfile
2. swapoff /dev/sda2 (remove old swap partition)
3. Remember the device where /mnt/temp is is /dev/sdc4.
4. filefrag -v /mnt/temp/swapfile
(snip irrelevant parts)
  ext:     logical_offset:        physical_offset: length:   expected: 
    0:        0..   32767:      34816..     67583:  32768:

5. The thing we want is the first number in the physical_offset: set of
numbers. The 34816 is the block from the start of the filesystem where
"swapfile" has its first block. So, in my /boot/grub/grub.cfg , I would
add the following to my kernel command line:

resume=/dev/sdc4 resume_offset=34816

6. Reboot (maybe not needed)
7. echo disk > /sys/power/state (suspends to disk as normal)
8. Power on (loading... suspend image found... resumes as normal)

You can even do this if your swap file resides on an LV, but that
requires having an initrd and adds complexity. HTH,

Crow202 Blog:
There is no Darkness in Eternity
But only Light too dim for us to see.
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings: