Mounting /tmp in RAM and using zram

3,177 views
Skip to first unread message

Sweyn78

unread,
Dec 20, 2011, 11:23:59 PM12/20/11
to Chromium OS discuss
Hello! I have been using Linux for almost half a year now, and I've
discovered some cool things about filesystems and the fstab. Now, I
am not sure whether this is already done in Chromium OS< but if it is
not, I would highly recommend doing this:
*Mounting zram (zram is a compressed swap space inside of your system
RAM and functions as normal RAM, except that it has a higher carrying
capacity and requires some CPU usage)
*Mounting /tmp as tmpfs (when normal RAM runs-out, the computer will
swap to the zrams first, and the hd/ssd second)
Alternatively, you could use a ResierFS, Resier4, or ext2 partition
for /tmp and turn-off everything that has to do with preventing data-
loss. (I could post the mount options I use for my ReserFS /tmp if
necessary)
This will allow maximum browsing speed without wasting system
resources (think about it: by default in most distros, you're storing /
tmp files on a journaling filesystem, which is completely
unecessary). On an ssd, where reads and writes come at a premium, it
is especially important to try and reduce the amount of reads/writes
to the disk. If zram turns you off andyou really wanted to get
creative, you could use btrfs's subvolumes so that /tmp wouldn't be
fixed in size or result in a pocket of freespace between it and other
partitions.
Happy fstabing! :)

Olof Johansson

unread,
Dec 21, 2011, 12:59:04 AM12/21/11
to swe...@gmail.com, Chromium OS discuss
Hi,

On Tue, Dec 20, 2011 at 8:23 PM, Sweyn78 <swe...@gmail.com> wrote:

[...]

> *Mounting /tmp as tmpfs (when normal RAM runs-out, the computer will
> swap to the zrams first, and the hd/ssd second)

We already do this.

> This will allow maximum browsing speed without wasting system
> resources (think about it: by default in most distros, you're storing /
> tmp files on a journaling filesystem, which is completely
> unecessary).

Performance suggestions are good, but performance suggestions with
hard benchmark data to back it up are even better. There are some
autotests for running some of the chrome browsing benchmarks as part
of the autotest suite that you can build and run against your own
build of Chromium OS to collect this data. See
http://www.chromium.org/developers/testing/page-cyclers and the
pagecycler autotests for more info.

>  On an ssd, where reads and writes come at a premium, it
> is especially important to try and reduce the amount of reads/writes
> to the disk.

At a premium compared to what? SSDs are much faster than rotating
media for all operations.


-Olof

Jeremy Bicha

unread,
Dec 21, 2011, 1:50:02 AM12/21/11
to Chromium OS discuss
On 21 December 2011 00:59, Olof Johansson <ol...@chromium.org> wrote:
>>  On an ssd, where reads and writes come at a premium, it
>> is especially important to try and reduce the amount of reads/writes
>> to the disk.
>
> At a premium compared to what? SSDs are much faster than rotating
> media for all operations.

I assume he's referring to the commonly held myth that if you have to
pay careful attention to how much your write to your SSD if you don't
want your SSD to fail soon because you exceeded its write limit.

Jeremy

Olof Johansson

unread,
Dec 21, 2011, 1:37:29 PM12/21/11
to jer...@bicha.net, Chromium OS discuss

Ah. That is unfortunately not a myth at all, in particular not for
consumer-grade devices such as the ones used in Chromebooks.

Fortunately the workloads we have are still well behaved in that sense
though, so we're not exposed to some of those problems.


-Olof

Mike Frysinger

unread,
Dec 21, 2011, 2:00:01 PM12/21/11
to swe...@gmail.com, Chromium OS discuss
when it comes to zram vs tmpfs, i don't think that's necessary. we
use /tmp for few things, and none seem to be very large.
-mike

Sonny Rao

unread,
Dec 22, 2011, 2:29:49 AM12/22/11
to vap...@chromium.org, swe...@gmail.com, Chromium OS discuss
Well zram is a good way to increase effective memory without having to
actually swap. Also, if we did use actual swap to disk, we'd have to
encrypt it which would increase the overhead.

People on the team have investigated swap to zram for low memory
devices but as of now we have decided not to implement it yet since
all of our shipping devices currently have 2GiB of memory which seems
to be enough for "normal" uses.

That said, someone using Chromium OS could probably set it up fairly
easily if they wanted to or needed it.

Sonny

> --
> Chromium OS discuss mailing list: chromium-...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-os-discuss?hl=en

BigRedFed

unread,
Dec 22, 2011, 11:39:34 AM12/22/11
to Chromium OS discuss
Could this be setup on a CR-48 in dev-mode easily?  I would be willing to try it out.

Sonny Rao

unread,
Dec 22, 2011, 1:34:46 PM12/22/11
to bigr...@gmail.com, Chromium OS discuss
It's not trivial because I believe you'd have to build a new kernel
with CONFIG_ZRAM=y and CONFIG_SWAP=y and install it.
If you did that, then on the new kernel, create a zram device, format
for swap, then turn it on:

echo $size > /sys/block/zram0/disksize
mkswap /dev/zram0
swapon /dev/zram0

disclaimer: I haven't tried this myself :-)

Micah Catlin

unread,
Dec 22, 2011, 1:40:23 PM12/22/11
to sonn...@chromium.org, bigr...@gmail.com, Chromium OS discuss
I've tried this on some of the memory-limited ARM devices and it works very well.  Our armel flavor kernel splitconfig enables CONFIG_SWAP and CONFIG_ZRAM for this reason already.

If someone is interested in benchmarking, there's evidently also an option to use the "Snappy" compression algorithm instead of LZO.  It claims to offer faster CPU decompression but with worse compression ratios.  Depending on a given system's CPU abilities and memory bandwidth it might be a win.   Even further down the road there's an option to configure a zram device with a filesystem backing store -- so if we end up swapping to a disk in some situations it would help to cover slower IO speeds.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages