This is an old revision of the document!
Hibernation with LVM, LUKS and a Swapfile
With this How To you can use a swapfile instead a swap partition as described here: http://slackware.osuosl.org/slackware-14.0/README_CRYPT.TXT
First create a swapfile: (you can choose another name and / or size if you want)
dd if=/dev/zero of=/swapfile bs=1M count=4096 mkswap /swapfile
Activate the Swap:
swapon /swapfile
Check if the Swapfile is recognized by the system:
cat /proc/swaps Filename Type Size Used Priority /swapfile file 4194300 0 -1
Add to the fstab
/swapfile none swap defaults 0 0
For suspend/resume you need to append 2 kernel Parameter in /etc/lilo.conf resume and resume_offset.
resume is the partition where the swapfile is located (e.g /dev/sda, /dev/cryptslack/root) resume_offset is the beginning of the swapfile on the resume partition, you can get the offset with
sudo /sbin/filefrag -v /swapfile | head -n -3 | tail -n 1 | awk ' {print $3 }'
your lilo entry should look like this:
# Append any additional kernel parameters: append="vt.default_utf8=1 resume=/dev/cryptslack/root resume_offset=1134591"
You need to patch the initrd to recognize the resume_offset parameter
mkdir patched_initrd cd patched_initrd cp -r /boot/initrd-tree . echo "1134591" > resoffset patch < init-swapfile.patch
after successfull patching ,pack the initrd to /boot/initrd-swapfile.gz
find . -print0 | cpio -ov -0 --format=newc | gzip -9 > /boot/initrd-swapfile.gz
image = /boot/vmlinuz initrd = /boot/initrd-swapfile.gz root = /dev/cryptslack/root label = "Linux Swapfile" read-only
then you need to run lilo to save the changes
lilo
after a reboot you can suspend to your swapfile as with your swap partition
Sources