Page 1 of 1
[SOLVED] Release swap after botched hibernation

Posted:
Aug 4th, '16, 23:38
by jimg
I powered up after hibernating, and accidentally selected a different kernel from the one I hibernated from. Now I apparently have an image in my swap partition, and when I boot up (from shutdown, haven't tried hibernate again), I can't load the swap partition. Presumably there's a hibernation image written to swap that's being protected. When booting, I get a lengthy "start job is running" pause while the system tries in vain to load swap.
There's nothing of value in the hibernation image, if in fact it's still there. Is there a simple way to make swap available again upon next reboot?
Thanks,
Jim Garrett
Re: Release swap after botched hibernation

Posted:
Aug 5th, '16, 10:06
by jiml8
Presuming swap is a partition, from the command line, as root:
swapoff /dev/swappartitionname
mkswap /dev/swappartitionname
swapon /dev/swappartitionname
Re: Release swap after botched hibernation

Posted:
Aug 5th, '16, 10:17
by Bequimao
jiml8 wrote:Presuming swap is a partition, from the command line, as root:
swapoff /dev/swappartitionname
mkswap /dev/swappartitionname
swapon /dev/swappartitionname
You should preserve the UUID.
- Code: Select all
## Get partitionname and UUID
# blkid | grep swap
## Formatting
# mkswap -U <old_uuid> <partitionname>
Greetings,
Bequimão
Re: Release swap after botched hibernation

Posted:
Aug 6th, '16, 01:06
by jiml8
Yes, default mageia installation uses UUID to identify swap in fstab. I eliminated all of that stuff from my installation long ago and had completely forgotten about it.
Re: Release swap after botched hibernation

Posted:
Aug 6th, '16, 01:56
by jimg
Thanks. Yes, this is a swap partition that should be named "swap".
Unfortunately neither of these suggestions quite worked. It seems not to know of the existence of the partition.
I was able to look up the UUID from /etc/fstab.
- Code: Select all
swapoff /dev/swap
swapoff: /dev/swap: swapoff failed: No such file or directory
swapoff -U b9...d6
swapoff: cannot find the device for b9...d6
mkswap -U b9...d6 /swap
/swap: No such file or directory
Thoughts?
-Jim
Re: Release swap after botched hibernation

Posted:
Aug 6th, '16, 02:16
by jiml8
In my original post, "swappartitionname" refers to the identifier of your swap partition, not the name "swap".
All partitions will be identified as /dev/sdXN where X will be A..Z and N will be 1..9 (could be greater than 9, but most people don't have that many partitions on one device).
Thus, my system has two swap devices, and one of these is a partition, specifically /dev/sdd1. I would disable this swap with the command "swapoff /dev/sdd1".
My other swap is a file located on partition /dev/sda1 with the name .swapfile. I would disable this one with the command: "swapoff /mnt/sda1/.swapfile" because /dev/sda1 is mounted at /mnt/sda1.
[Solved] Release swap after botched hibernation

Posted:
Aug 6th, '16, 03:42
by jimg
Thanks for the clarification. With this, I was able to figure it out.
For the benefit of anyone else....
I used gparted to get information about the partitions, and was able to infer which one was swap by its size, and by elimination (sda5).
swapoff didn't do anything because there was no swap active. Once I knew the device, I was able to make swap space with the specified UUID, as suggested:
- Code: Select all
mkswap -U <old-uuid> /dev/sda5
And that did it. And I learned something!
Thanks for your help!
Re: Release swap after botched hibernation

Posted:
Aug 6th, '16, 04:39
by jiml8
The command "blkid | grep swap" gives you the partition identifier directly, without having to resort to gparted and inferences and conclusions.
Try entering blkid on its own and see what it gives you. You do not have to be root, but if you are not root, enter /sbin/blkid .
Re: [SOLVED] Release swap after botched hibernation

Posted:
Aug 10th, '16, 04:09
by jimg
Thanks, that's handy.
It appears that if I submit /sbin/blkid not as root nothing is returned, but blkid as root works fine.
-Jim