Using shared swap files

Would it cause any problems to use a shared swap partition?
Example:
sda1 = swap partition 50 meg
sda2 = / of OpenSuse installation 200 meg
sda3 = / of Fedora installation 200 meg
sda4 = / of Slackware installation 200 meg

How about:
sdb1 = / of Gentoo installation with swap pointed at sda1
sdb2 = / of Ubuntu installation with swap pointed at sda1

Obviously, only one system will be running at any particular time.

Is the swap file re-created each time a system is started?
Is it written to only when needed?
Is swap information “remembered” during shut down and accessed at startup?

You only need One swap partition and it can be used by all OS’s

On 07/09/2010 07:46 AM, caf4926 wrote:
>
> You only need One swap partition and it can be used by all OS’s

The only thing you will not be able to do is hibernate one distro and boot
into another. That could leave your mounted file systems in a faulty state.

The bootloader won’t let you do that anyway, it doesn’t give you a chance to choose the OS, it resumes whatever was suspended. However with sufficient ingenuity, I suppose this safety measure could be circumvented, but what would be the point?

Problems: Well, even having a small swap file is probably better than not having a swap file, but have you considered whether you might allocate a bit more than 50 meg?

If you have a whole load of ram and you don’t use suspend to disk, maybe you don’t actually need swap for day-to-day usage.

And 200 meg, what do you want to install in that?

You’ll be doing this because you have a cheap 0.65 G disk drive, of course :open_mouth:

markone wrote:

>
> Problems: Well, even having a small swap file is probably better than
> not having a swap file, but have you considered whether you might
> allocate a bit more than 50 meg?

With todays disk sizes, I rarely allocate less than 1G. For systems
with lots of memory, often 4G or more.


Per Jessen, Zürich (31.2°C)
http://en.opensuse.org/User:Pjessen

200 meg for root. Maybe you might be able to cram a no GUI CL only configuration into such a small space but I really doubt it.

On 2010-07-09 13:16 GMT ken yap wrote:

>
> The bootloader won’t let you do that anyway, it doesn’t give you a
> chance to choose the OS, it resumes whatever was suspended. However
> with sufficient ingenuity, I suppose this safety measure could be
> circumvented, but what would be the point?

Yes, it can be done. I did that to leave linux momentarily and boot to
windows, do whatever I needed, and return to my desktop.

This is relatively safe as the partitions involved are “closed” on
hibernation. Doing the same with linux systems is like playing with
nitroglycerin.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Elessar))

That’s probably because you were using a different bootloader. The standard GRUB setup detects that a Linux OS was hibernated and doesn’t go to the menu in that case.

On 2010-07-09 12:36 GMT montana suse user wrote:

>
> Would it cause any problems to use a shared swap partition?
> Example:
> sda1 = swap partition 50 meg
> sda2 = / of OpenSuse installation 200 meg
> sda3 = / of Fedora installation 200 meg
> sda4 = / of Slackware installation 200 meg

Two hundred megabytes for root? Is that correct? :open_mouth:

Fifty megabytes of swap?

Sure, you can share it. But linux will laugh at those ridiculous amounts
of disk space. It may refuse to format that…

> Is the swap file re-created each time a system is started?

No, it is reused. Marked clean and used.

> Is it written to only when needed?

After it is marked, yes.

> Is swap information “remembered” during shut down and accessed at
> startup?

Remembered? The configuration is writen to disk, as for any other
partition, in /etc/fstab.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Elessar))

On 2010-07-10 00:16 GMT ken yap wrote:

> That’s probably because you were using a different bootloader. The
> standard GRUB setup detects that a Linux OS was hibernated and doesn’t
> go to the menu in that case.

No, it is not grub. I mean, yes, I use the standard grub that suse
supplies, but it does no magic.

It is the script “/usr/lib/pm-utils/sleep.d/99Zgrub”, which does some
magic and then runs “grubonce” with the appropriate parameters, which
does what you say, deactivating the menu to boot one of the entries
directly . When it comes back, it
uses /var/run/suspend.grubonce.default to restore the original settings.

There is no automatic detection.

You only have to deactivate or remove that 99Zgrub in order to get back
the menu during hibernation.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Elessar))

Ok, thanks that might be useful info if I ever have to do that. :slight_smile:

Actually, I have four 1 terabyte disks. I didn’t want to brag so I used megs as an example. Sorry.

All right, that’s the end of sympathy for you then. Anyone who can afford 4 1TB disks can afford one swap partition per distro. lol!

Thanks all for the replies. I did make a mistake using megs as an example. Having been properly spanked, I won’t do that again! However, I got the answer I wanted. I understand that one swap partition may be shared by all Linux systems, one at a time.

On 2010-07-10 12:06 GMT montana suse user wrote:

>
> Thanks all for the replies. I did make a mistake using megs as an
> example. Having been properly spanked, I won’t do that again!
> However, I got the answer I wanted. I understand that one swap
> partition may be shared by all Linux systems, one at a time.

Exactly :slight_smile:

By the way, as you have several disks, you can define one on each disk,
with the same priority, and the kernel will swap faster.

And, if you intend to hibernate, then (at least the one declared in
grub) must be as big as your ram or larger.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Elessar))

ken yap wrote:

>
> All right, that’s the end of sympathy for you then. Anyone who can
> afford 4 1TB disks

At http://www.digitec.ch a 2Tb Samsung is only CHF139 …


Per Jessen, Zürich (32.9°C)
http://en.opensuse.org/User:Pjessen

On 07/10/2010 08:27 AM, Carlos E. R. wrote:
>
> And, if you intend to hibernate, then (at least the one declared in
> grub) must be as big as your ram or larger.

Not quite true. The hibernation image is compressed and will likely be on
the order of 1/2 the size of ram; however, the recommendation of swap
equaling ram is a good one.

On 2010-07-10 15:38 GMT Larry Finger wrote:

> On 07/10/2010 08:27 AM, Carlos E. R. wrote:
> >
> > And, if you intend to hibernate, then (at least the one declared in
> > grub) must be as big as your ram or larger.
>
> Not quite true. The hibernation image is compressed and will likely
> be on the order of 1/2 the size of ram; however, the recommendation
> of swap equaling ram is a good one.

can be compressed. Not everybody does.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Elessar))