You are not logged in.

#1 2008-06-01 23:37:31

Falcata
Member
From: Michiana
Registered: 2008-01-23
Posts: 501
Website

Swap Files

A few questions I have:
1) What are swap files?
2) What are their advantages compared to swap partitions?
3) How would I use them?

Offline

#2 2008-06-01 23:40:23

dyscoria
Member
Registered: 2008-01-10
Posts: 1,007

Re: Swap Files

AFAIK:

1) same as swap partitions, just instead of being a partition its a file
2) no advantage, as its still limited by disk I/O
3) this might be what you're looking for


flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)

Offline

#3 2008-06-01 23:47:08

Falcata
Member
From: Michiana
Registered: 2008-01-23
Posts: 501
Website

Re: Swap Files

Okay, thanks.

Offline

#4 2008-06-02 06:28:11

edward.al
Member
Registered: 2008-05-26
Posts: 12

Re: Swap Files

it means swap file is slower than swap partitions?

Offline

#5 2008-06-02 07:40:33

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Re: Swap Files

A bit. But with modern RAM volumes swapping becomes a bit of rare emergency... So swap files instead of swap partitions can be a good idea.

Offline

#6 2008-06-02 07:46:43

schivmeister
Developer/TU
From: Singapore
Registered: 2007-05-17
Posts: 971
Website

Re: Swap Files

I've been wondering though, would there be security risks for swap files? They're just like other files residing on the hard disk, and it would be possible to exploit it since it holds RAM information. Don't quite know for sure.


I need real, proper pen and paper for this.

Offline

#7 2008-06-02 12:31:11

T-u-N-i-X
Member
From: İstanbul
Registered: 2006-03-14
Posts: 435
Website

Re: Swap Files

If I want to hibernate, I guess that I'd have to use swap partition.... But because of that I've already partitioned my hard disk without using a swap partition, I may use a swap file.. But in this situation, initrd wouldn't read that swap file and can't wake the computer from hibernate, right ?


Quis custodiet ipsos custodiet?

Offline

#8 2008-06-02 15:18:16

gothmog.todi
Member
From: Austria
Registered: 2007-07-18
Posts: 120

Re: Swap Files

You are right if you talking about standard kernelspace hibernate. But there are ways to use swap files.
From the wiki:

tuxonice allows you to suspend on a regular file if you have not a swap partition, while uswsusp give this possibility only if you run an experimental and unstable mm kernel.

Offline

#9 2008-06-02 17:15:20

Zepp
Member
From: Ontario, Canada
Registered: 2006-03-25
Posts: 334
Website

Re: Swap Files

edward.al wrote:

it means swap file is slower than swap partitions?

A bit, probably not noticeable unless your swap file is heavily fragmented

schivmeister wrote:

I've been wondering though, would there be security risks for swap files? They're just like other files residing on the hard disk, and it would be possible to exploit it since it holds RAM information. Don't quite know for sure.

The swap file should be owned by root.

Offline

#10 2008-06-02 17:39:13

bender02
Member
From: UK
Registered: 2007-02-04
Posts: 1,328

Re: Swap Files

Zepp wrote:
schivmeister wrote:

I've been wondering though, would there be security risks for swap files? They're just like other files residing on the hard disk, and it would be possible to exploit it since it holds RAM information. Don't quite know for sure.

The swap file should be owned by root.

Note that the fact that it's on a separate partition does *not* provide any security. Anyone with a read permission on /dev/<thatpartition> can read the swap. By the way, just try 'strings /dev/<swappartition> | grep <your root password>' and see how many times it's there smile [And note that your root password gets written to ~/.bash_history so you want to be careful with that command as well smile]

Last edited by bender02 (2008-06-02 17:39:51)

Offline

#11 2008-06-02 17:44:15

Zepp
Member
From: Ontario, Canada
Registered: 2006-03-25
Posts: 334
Website

Re: Swap Files

bender02 wrote:
Zepp wrote:
schivmeister wrote:

I've been wondering though, would there be security risks for swap files? They're just like other files residing on the hard disk, and it would be possible to exploit it since it holds RAM information. Don't quite know for sure.

The swap file should be owned by root.

Note that the fact that it's on a separate partition does *not* provide any security. Anyone with a read permission on /dev/<thatpartition> can read the swap. By the way, just try 'strings /dev/<swappartition> | grep <your root password>' and see how many times it's there smile [And note that your root password gets written to ~/.bash_history so you want to be careful with that command as well smile]

Yes, the swap partition should also be owned by root for the same reason.

Offline

#12 2008-06-02 17:47:36

bender02
Member
From: UK
Registered: 2007-02-04
Posts: 1,328

Re: Swap Files

Zepp wrote:

Yes, the swap partition should also be owned by root for the same reason.

I didn't mean to contradict you, I was just trying to give some perspective on the problem. I'd say, not only owned by root, but also chmodded to 600. On the side, the standard permissions on /dev/<block device> are "brw-rw---- root disk", so anyone in the 'disk' group can read the swap partition.

Offline

#13 2008-06-02 17:50:48

Zepp
Member
From: Ontario, Canada
Registered: 2006-03-25
Posts: 334
Website

Re: Swap Files

bender02 wrote:
Zepp wrote:

Yes, the swap partition should also be owned by root for the same reason.

I didn't mean to contradict you, I was just trying to give some perspective on the problem. I'd say, not only owned by root, but also chmodded to 600. On the side, the standard permissions on /dev/<block device> are "brw-rw---- root disk", so anyone in the 'disk' group can read the swap partition.

Yes, you are absolutely correct on the permissions, and ya no it was good that you elaborated on my point I didn't really explain what I was getting at originally smile.

Offline

Board footer

Powered by FluxBB