24 lines
885 B
Bash
Executable File
24 lines
885 B
Bash
Executable File
#!/bin/sh
|
|
# requires swapfile at /swap be setup
|
|
|
|
# ensure no dupes by removing any old hooks
|
|
sed -Ei 's/resume//' /etc/mkinitcpio.conf
|
|
|
|
# setup hooks
|
|
sed -Ei 's/filesystems/filesystems resume/' /etc/mkinitcpio.conf
|
|
echo "Enabled hooks - note /etc/mkinicpio.conf's comments are messed up due to this"
|
|
mkinitcpio -p linux
|
|
|
|
# ensure no dupes by removing any old kernel params
|
|
sed -Ei 's/resume=UUID=.{36} *//' /etc/default/grub
|
|
sed -Ei 's/resume_offset=[[:digit:]]* *//' /etc/default/grub
|
|
|
|
# write patamaters
|
|
uuid="$(findmnt -no UUID -T /swap)"
|
|
offset="$(filefrag -v /swap | awk '$1=="0:" {print substr($4, 1, length($4)-2)}')"
|
|
echo "Setting kernel paramaters"
|
|
sed -Ei 's/^GRUB_CMDLINE_LINUX="/GRUB_CMDLINE_LINUX="resume=UUID='"$uuid"' resume_offset='"$offset"'/' /etc/default/grub
|
|
grub-mkconfig -o /boot/grub/grub.cfg
|
|
|
|
echo "Hibernation setup - changes will take affect after reboot."
|