Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tmps and swap

66 views
Skip to first unread message

Günther Schwarz

unread,
Feb 7, 2012, 3:50:53 PM2/7/12
to
Any hints on how to prevent a tmpfs file system to be written to the swap
partition? Other than omitting a swap partition completely, of course. I
do not want some files to end up on the hard disk.

Günther

Lew Pitcher

unread,
Feb 7, 2012, 4:15:55 PM2/7/12
to
On Tuesday 07 February 2012 15:50, in comp.os.linux.security, st...@gmx.de
wrote:

> Any hints on how to prevent a tmpfs file system to be written to the swap
> partition? Other than omitting a swap partition completely, of course. I
> do not want some files to end up on the hard disk.

I'm afraid that you can't do that.

To quote /usr/src/linux/Documentation/filesystems/tmpfs.txt
"Since tmpfs lives completely in the page cache and on swap, all tmpfs
pages currently in memory will show up as cached."

tmpfs lives in cache and swap. There are no tmpfs tuning parameters to
prevent tmpfs pages from being written to swap (mount(8) only lists size=,
nr_blocks=, nr_inodes, and mode= (initial permissions) ), tmpfs will be
written to swap, with the same rules as any other cache.

Sorry
--
Lew Pitcher

Richard Kettlewell

unread,
Feb 7, 2012, 5:40:48 PM2/7/12
to
Encrypted swap, with a throwaway key generated on boot?

--
http://www.greenend.org.uk/rjk/

Günther Schwarz

unread,
Feb 7, 2012, 6:01:14 PM2/7/12
to
Lew Pitcher wrote:

> On Tuesday 07 February 2012 15:50, in comp.os.linux.security,
> st...@gmx.de wrote:
>
>> Any hints on how to prevent a tmpfs file system to be written to the
>> swap partition? Other than omitting a swap partition completely, of
>> course. I do not want some files to end up on the hard disk.
>
> I'm afraid that you can't do that.
>
> To quote /usr/src/linux/Documentation/filesystems/tmpfs.txt
> "Since tmpfs lives completely in the page cache and on swap, all tmpfs
> pages currently in memory will show up as cached."

Thanks a lot for the clarification. So this is how I did suspect it to
be. I will have to live with a small risk. No risk, no fun.

Günther

Günther Schwarz

unread,
Feb 7, 2012, 6:01:48 PM2/7/12
to
Richard Kettlewell wrote:

> Günther Schwarz <st...@gmx.de> writes:
>> Any hints on how to prevent a tmpfs file system to be written to the
>> swap partition? Other than omitting a swap partition completely, of
>> course. I do not want some files to end up on the hard disk.
>
> Encrypted swap, with a throwaway key generated on boot?

Do you have a link on a howto for that? I need unassisted boot up, so
typing a password at boot time is not an option.

Günther

Pascal Hambourg

unread,
Feb 7, 2012, 6:34:56 PM2/7/12
to
Hello,

Günther Schwarz a écrit :
> Any hints on how to prevent a tmpfs file system to be written to the swap
> partition? Other than omitting a swap partition completely, of course. I
> do not want some files to end up on the hard disk.

You can use ramfs instead of tmpfs. But the drawback is that you cannot
limit the size. See Documentation/filesystems/ramfs-rootfs-initramfs.txt

Stachu 'Dozzie' K.

unread,
Feb 8, 2012, 4:18:08 AM2/8/12
to
http://www.google.com/search?q=encrypted+swap+linux+howto

--
Secunia non olet.
Stanislaw Klekot

Günther Schwarz

unread,
Feb 9, 2012, 4:51:12 PM2/9/12
to
This is interesting, thanks a lot. The swap partition set up with a key
from /dev/urandom might well solve some other issues related to the swap
partition. I will give it a try.

Günther

Günther Schwarz

unread,
Feb 9, 2012, 4:51:14 PM2/9/12
to
An interesting option also. But it might be too easy for an user to fill
the memory completely. I will first try with an encrypted swap with a key
form /dev/urandom as suggested by Stachu.

Günther

Alexander Schreiber

unread,
May 31, 2012, 3:52:45 PM5/31/12
to
Well, you could
- use RAM disk instead
- encrypt swap with a random key (set up freshly from /dev/urandom
at every boot and not stored anywhere)

Kind regards,
Alex.
--
"Opportunity is missed by most people because it is dressed in overalls and
looks like work." -- Thomas A. Edison
0 new messages