LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Possible to share the swap partition between two installations if I hibernate? (https://www.linuxquestions.org/questions/linux-desktop-74/possible-to-share-the-swap-partition-between-two-installations-if-i-hibernate-685980/)

Stuart Morrow 11-25-2008 09:10 AM

Possible to share the swap partition between two installations if I hibernate?
 
This is just a question out of curiousity and daydreaming, rather than seeking help to a problem, so there's no urgency to respond.

I know that if you have two Linux distros installed on the same computer you can share the swap between them, since obviously only one of them would be active at a given time.
I know that you can share a swap partition between Linux and Hurd dual boot the same way as between two Linuxes, and I know that you can share a swap partition between Linux and BSD if you do a mkswp in the Linux's startup or the BSD's shutdown.

But I was wondering, can you share a swap partition between two Linux installations if you do hibernation (to disk) on one or both, rather than shutting down? And, does it depend on which implementation of hibernation you're using in either or both?

Just wondering,
Stuart.

Junior Hacker 11-25-2008 11:48 AM

I like using Bootitng as a boot manager, it makes compressed images of the partitions. This comes in handy for answering questions like this by trial and error. If it doesn't work and I can't re-boot, I spend under ten minutes zeroing out the affected OS/partition and re-load the image I made before I screwed it up without breaking a sweat or raising my stress level.
But I'm too lazy at the moment, and it's not something I desire to know at this particular time.
Just showing you how to figure it out on your own, "trial & error".

salasi 11-26-2008 04:36 AM

Quote:

Originally Posted by Stuart Morrow (Post 3353834)
But I was wondering, can you share a swap partition between two Linux installations if you do hibernation (to disk) on one or both, rather than shutting down? And, does it depend on which implementation of hibernation you're using in either or both?

I think that should break things, although maybe in slightly subtle ways. If distro 2 wakes up and distro 1's resume file is using up the swap partition, what's it supposed to do? Maybe it detects that the resume file is its own and that's not what you want, or maybe it detects it as a 'foreign' resume file and just doesn't use that part or all of the swap and that probably isn't what you want, either.

So, I can't really see a good outcome, unless you had way more swap that you needed, in which case why not divide it into two?

mikey99 11-27-2008 11:16 AM

I might be wrong, but if you hibernate one OS, then GRUB will only start that OS up again. You won't be given the opportunity to boot to the other OS.

Mike.

wificraig 11-28-2008 03:35 AM

More than one swap
 
I did that one time, not intentionally, but the other distro tried to resume from the previous disto's hibernation. It froze on the boot, but when I rebooted, it seemed as though the swap had been cleared out. I think that if you intend to hibernate frequently with both (or more) distros, you might want to consider creating more than one swap partition. The problem that arises is that when you install a distro, many will mount both swap partitions, and will make the first one recognised as the default one. This will require you editing the menu.lst, fstab, as well as configuration files for the resume to swap (disk) functions. Just make sure when you install and customize the partitioning, you unmount the swap partitions you do not want the system to recognise or format them with a live cd as something other than swap, and change it back after install formatting it to a swap partition..

undoIT 01-02-2009 11:31 PM

Shared Swap and Hibernation
 
I have experimented with this. I have a laptop hard drive and have installed seven different distros. The first primary partition is for grub and I am able to boot to all the distros. The second partition is swap. The third partition is an extended partition and each of the distros is installed into their own logical partitions.

All of the distros are booting and can hibernate. I just need to make sure and select the correct distro after resuming from hibernation. So, yes. This is possible :)

nileshkumar 11-30-2014 01:34 AM

Quote:

Originally Posted by undoIT (Post 3395304)
I have experimented with this. I have a laptop hard drive and have installed seven different distros. The first primary partition is for grub and I am able to boot to all the distros. The second partition is swap. The third partition is an extended partition and each of the distros is installed into their own logical partitions.

@undoIT can you please explain what do you mean for "The first primary partition is for grub", is it the /boot partition or something else, as I am planning to install the same way you have done.

undoIT 11-30-2014 01:40 AM

Yes, the first partition was /boot. But, it has been a long time since I did this and things may have changed a bit since then.

EDDY1 11-30-2014 08:04 PM

Quote:

Originally Posted by nileshkumar (Post 5276941)
@undoIT can you please explain what do you mean for "The first primary partition is for grub", is it the /boot partition or something else, as I am planning to install the same way you have done.

If you plan on putting multiple distro's you may be limited as to how many OS you can put on drive.
Some of the limiting factors:
Sata hdd's if MBR are limited to 15 partitions.
Ide 63
GPT 128

jefro 12-01-2014 03:02 PM

2008 post.

Lsatenstein 12-02-2014 07:17 PM

Quote:

Originally Posted by Stuart Morrow (Post 3353834)
This is just a question out of curiousity and daydreaming, rather than seeking help to a problem, so there's no urgency to respond.

I know that if you have two Linux distros installed on the same computer you can share the swap between them, since obviously only one of them would be active at a given time.
I know that you can share a swap partition between Linux and Hurd dual boot the same way as between two Linuxes, and I know that you can share a swap partition between Linux and BSD if you do a mkswp in the Linux's startup or the BSD's shutdown.

But I was wondering, can you share a swap partition between two Linux installations if you do hibernation (to disk) on one or both, rather than shutting down? And, does it depend on which implementation of hibernation you're using in either or both?

Just wondering,
Stuart.

No! The hybernate information is stored in thw swap file, and the contents therein include information about what was running where in memory at that moment.

The 2nd system knos not about the first, and will clobber the swap file contents


All times are GMT -5. The time now is 09:14 PM.