FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 05-02-2012, 06:53 PM
walt
 
Default Any experience with swapfiles?

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?
 
Old 05-02-2012, 08:31 PM
Paul Hartman
 
Default Any experience with swapfiles?

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.
 
Old 05-02-2012, 08:33 PM
Paul Hartman
 
Default Any experience with swapfiles?

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!
 
Old 05-02-2012, 08:58 PM
Simon
 
Default Any experience with swapfiles?

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?
>
>
 
Old 05-02-2012, 09:50 PM
walt
 
Default Any experience with swapfiles?

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?
 
Old 05-02-2012, 10:02 PM
Paul Hartman
 
Default Any experience with swapfiles?

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
 

Thread Tools




All times are GMT. The time now is 07:33 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org