public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Any experience with swapfiles?
@ 2012-05-02 18:53 walt
  2012-05-02 20:31 ` Paul Hartman
  2012-05-02 20:58 ` Simon
  0 siblings, 2 replies; 6+ messages in thread
From: walt @ 2012-05-02 18:53 UTC (permalink / raw
  To: gentoo-user

I have two machines with 4GB of ram and I've never seen either one use
swapspace (yet) so I'm thinking I could delete my swap partitions and
substitute a much smaller swapfile -- if it's safe.

Any downside to using a swap file instead of a swap partition, maybe
depending on which filesystem you use, or something?  Security holes?
Any horror stories out there?




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-user] Any experience with swapfiles?
  2012-05-02 18:53 [gentoo-user] Any experience with swapfiles? walt
@ 2012-05-02 20:31 ` Paul Hartman
  2012-05-02 20:33   ` Paul Hartman
  2012-05-02 20:58 ` Simon
  1 sibling, 1 reply; 6+ messages in thread
From: Paul Hartman @ 2012-05-02 20:31 UTC (permalink / raw
  To: gentoo-user

On Wed, May 2, 2012 at 1:53 PM, walt <w41ter@gmail.com> wrote:
> I have two machines with 4GB of ram and I've never seen either one use
> swapspace (yet) so I'm thinking I could delete my swap partitions and
> substitute a much smaller swapfile -- if it's safe.
>
> Any downside to using a swap file instead of a swap partition, maybe
> depending on which filesystem you use, or something?  Security holes?
> Any horror stories out there?

I think a swapfile cannot be used for suspend-to-disk. When creating a
swap file you should take care to ensure it is not fragmented.
Otherwise, performance should be equal between swap partition or swap
file under normal circumstances, as far as I know.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-user] Any experience with swapfiles?
  2012-05-02 20:31 ` Paul Hartman
@ 2012-05-02 20:33   ` Paul Hartman
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Hartman @ 2012-05-02 20:33 UTC (permalink / raw
  To: gentoo-user

On Wed, May 2, 2012 at 3:31 PM, Paul Hartman
<paul.hartman+gentoo@gmail.com> wrote:
> On Wed, May 2, 2012 at 1:53 PM, walt <w41ter@gmail.com> wrote:
>> I have two machines with 4GB of ram and I've never seen either one use
>> swapspace (yet) so I'm thinking I could delete my swap partitions and
>> substitute a much smaller swapfile -- if it's safe.
>>
>> Any downside to using a swap file instead of a swap partition, maybe
>> depending on which filesystem you use, or something?  Security holes?
>> Any horror stories out there?
>
> I think a swapfile cannot be used for suspend-to-disk. When creating a
> swap file you should take care to ensure it is not fragmented.
> Otherwise, performance should be equal between swap partition or swap
> file under normal circumstances, as far as I know.

And I will add: be sure the swapfile you create is not a sparse file!



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-user] Any experience with swapfiles?
  2012-05-02 18:53 [gentoo-user] Any experience with swapfiles? walt
  2012-05-02 20:31 ` Paul Hartman
@ 2012-05-02 20:58 ` Simon
  2012-05-02 21:50   ` [gentoo-user] " walt
  1 sibling, 1 reply; 6+ messages in thread
From: Simon @ 2012-05-02 20:58 UTC (permalink / raw
  To: gentoo-user

I haven't used a swap partition on any of my systems (intel celeron,
p3, amd64, intel xeon)  for over... what...  10 years?
Swapfiles only, and sometimes I don't even mount the swap.  Although I
have never removed support for any kind of swap from my kernel.


dd if=/dev/zero of=/path/to/swapfile bs=1M count=1024
mkswap /path/to/swapfile
swapon /path/to/swapfile
  (btw, I like to put the swap file in /root or /boot, but that's my
pref, on space constrained PC, i would put a swapfile on every drive
to distribute it).


I don't have access to my box to confirm but I think /etc/fstab would
be setup the same as normal swap except with the file path instead of
the device partition.

Except for issue pointed out by Paul about hibernation, dd line above
takes care of non-sparsity.  As for security, having a swap is less
secure than having none:  a malicious persion could extract
information from programs memory which was swapped (ie, like the
decripted information "for your eyes only").

Having no swap at all was a problem on small systems with little RAM
when emerging big stuff (boost failed all the time on a pc with
256mb).

Resizing swap "on-the-fly" with swapfiles:
  And on HDD-space constrained system, i used to have several
swapfiles that I created and deleted in the manner above, that I named
swapfile-256, swapfile-512, etc...  A smooth "upgrade of swap
on-the-fly" was done this way:  say I had 256 swapped on, I could swap
on a new 512 (768 total at moment, all data still on 256mb file), then
swapoff the 256 (takes a bit of time for swap data to move over),
delete the 256.  Downgrade can be done in the same manner.  "swapon
-s" (status) will be a good friend of yours now.

Good luck!

Simon


On Wed, May 2, 2012 at 2:53 PM, walt <w41ter@gmail.com> wrote:
> I have two machines with 4GB of ram and I've never seen either one use
> swapspace (yet) so I'm thinking I could delete my swap partitions and
> substitute a much smaller swapfile -- if it's safe.
>
> Any downside to using a swap file instead of a swap partition, maybe
> depending on which filesystem you use, or something?  Security holes?
> Any horror stories out there?
>
>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [gentoo-user] Re: Any experience with swapfiles?
  2012-05-02 20:58 ` Simon
@ 2012-05-02 21:50   ` walt
  2012-05-02 22:02     ` Paul Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: walt @ 2012-05-02 21:50 UTC (permalink / raw
  To: gentoo-user

On 05/02/2012 01:58 PM, Simon wrote:

<excellent help snipped for brevity>

> Except for issue pointed out by Paul about hibernation

That's an interesting point, and the reason for the problem is definitely
not obvious to me.  Anyone know the technical details?

> As for security, having a swap is less
> secure than having none:  a malicious persion could extract
> information from programs memory which was swapped

BTW, man mkswap says nothing about proper file permissions for a swapfile.
I'm guessing that only root should be able to read the file?




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-user] Re: Any experience with swapfiles?
  2012-05-02 21:50   ` [gentoo-user] " walt
@ 2012-05-02 22:02     ` Paul Hartman
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Hartman @ 2012-05-02 22:02 UTC (permalink / raw
  To: gentoo-user

On Wed, May 2, 2012 at 4:50 PM, walt <w41ter@gmail.com> wrote:
> On 05/02/2012 01:58 PM, Simon wrote:
>
> <excellent help snipped for brevity>
>
>> Except for issue pointed out by Paul about hibernation
>
> That's an interesting point, and the reason for the problem is definitely
> not obvious to me.  Anyone know the technical details?
>
>> As for security, having a swap is less
>> secure than having none:  a malicious persion could extract
>> information from programs memory which was swapped
>
> BTW, man mkswap says nothing about proper file permissions for a swapfile.
> I'm guessing that only root should be able to read the file?
>
>

Actually it looks like it may be possible, depending on which method
you use for suspending. Here's a kernel document talking about using
swap files and swsusp:

https://www.kernel.org/doc/Documentation/power/swsusp-and-swap-files.txt



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-05-02 22:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-02 18:53 [gentoo-user] Any experience with swapfiles? walt
2012-05-02 20:31 ` Paul Hartman
2012-05-02 20:33   ` Paul Hartman
2012-05-02 20:58 ` Simon
2012-05-02 21:50   ` [gentoo-user] " walt
2012-05-02 22:02     ` Paul Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox