Possible to share the swap partition between two installations if I hibernate?
Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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".
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?
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..
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
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 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
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.