Comment 8 for bug 42299

Revision history for this message
Nick_Hill (nick-nickhill) wrote : Re: Hibernating corrupts swap partition

Given that a machine can have multiple swap partitions and files, it is important to know that the machine will try to resume from the same swap partition or file where the hibernation image was saved.

It is therefore advisable that the same code / interface which informs the hibernation mechanism where to save the image to also determines where the kernel resumes from. I am not sure whether the current implementation does this. Maybe something for the longer term.

Given that in kernel 2.6 there is no performance penalty using swap files as opposed to swap partitions (according to Ted Ts'o), any possible hibernation dependency on a swap partition should be cut.

In the longer term, we therefore need a more flexible approach to informing the booting kernel whether it is coming out of hibernation, and where it can find the hibernation image.

Perhaps a module associated with init should be involved in this.
1) Before hibernation, signal init to return a location where the hibernation mechanism should write the hibernation data. Init can make it's own arrangements. location passed to hibernation mechanism, and control passed to hibernation mechanism.
2) At boot, init checks file system flags or whatever to determine whether it is waking from hibernation. if so, passes the location of the hibernation data to the hibernation mechanism. Passes control to hibernation mechanism.
3) After wake from hibernation, hibernation code signals init that system woken from hibernation. Init can then run scripts to restore stateful hardware and remove any flags init uses to determine that it is to wake from hibernation.

This system has several advantages:
1) No swap file or partition necessary
2) Flexibility- separate hibernation files can be used if necessary. Init can make any necessary decision how to handle the hibernation request.
3) Can eliminate uncertainty when using multiple swap partitions and files.
4) Removes dependency on kernel boot arguments. Prevents system brakage when swap partitions are re-assigned and removes need to tightly integrate boot managers lilo/ grub with hibernation system.

Disadvantage
Makes system slightly more complex; Init will need additional configuration parameters to determine how and where hibernation occurs.