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:
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,