Difference between pages "Zram" and "Gentoo Linux"

From Funtoo
(Difference between pages)
Jump to: navigation, search
m (Swap on zram)
 
 
Line 1: Line 1:
== Compressed RAM based block devices ==
+
Gentoo Linux is a source-based Linux distribution created by Daniel Robbins. It uses Portage as official package management system which original design was based on FreeBSD's ports. The main portage's utility is called [http://docs.funtoo.org/wiki/Emerge Emerge] that is written in Python and can be used to install/uninstall packages.
The zram module creates RAM based block devices named /dev/zram<id> (<id> = 0, 1, ...). Pages written to these disks are compressed and stored in memory itself. These disks allow very fast I/O and compression provides good amounts of memory savings. Some of the usecases include /tmp storage, use as swap disks, various caches under /var and maybe many more.
+
  
== Get zram ==
+
[http://docs.funtoo.org/wiki/Make.conf Make.conf] is Portage main configuration's file, because it contains many variables. For example, the best known : CFLAGS,CHOST,CXXFLAGS,USE, INPUT_DEVICES, VIDEO_CARDS,LINGUAS,GENTOO_MIRRORS.There are also many optional's variables like PORTDIR_OVERLAY.
Latest zram code is into mainline linux kernel. We recommend you to test it with 2.6.37 or later.
+
In this Linux distribution, the user compiles the source code locally according to their chosen configuration in order to improve their system and also to learn more about Linux.
<source lang=text>
+
Device Drivers  --->
+
  [*] Staging drivers  --->
+
      <M> Compressed RAM block device support
+
</source>
+
Compile and install module.
+
 
+
== Usage ==
+
=== Load module, create devices ===
+
To create one zram device, do
+
<source lang='bash'>modprobe zram num_devices=1</source>
+
 
+
=== Set Disksize ===
+
Set disk size by writing the value to sysfs node 'disksize' (in bytes). If disksize is not given, default value of 25% of RAM is used.
+
{{fancyimportant|The disksize cannot be changed if the disk contains an data. So, for such a disk, you need to issue 'reset' (see below) before you can change its disksize.}}
+
 
+
* Set disksize of 50MB for /dev/zram0:
+
<source lang='bash'>echo $((50*1024*1024)) > /sys/block/zram0/disksize</source>
+
* Reset the sysfs node
+
<source lang='bash'>echo 1 > /sys/block/zram0/reset</source>
+
== Use case ==
+
=== Swap on zram ===
+
As example we will use netbook with dualcore Intel Atom with 2G of ram.
+
Disable usual swap, create a zram device and set the disksize to 200Mb and, finally, create a swap
+
<source lang='bash'>swapoff -a
+
modprobe zram num_devices=1
+
echo $((200*1024*1024)) > /sys/block/zram0/disksize
+
mkswap /dev/zram0
+
swapon -p10 /dev/zram0</source>
+
To test, recompile something big, like chromium, and notice a speed gain.
+
 
+
=== Swap on zram and a separate /tmp ===
+
<source lang='bash'>modprobe zram zram_num_devices=4</source>
+
* Initialize /dev/zram0 with 50MB disksize
+
<source lang='bash'>echo  $((50*1024*1024)) > /sys/block/zram0/disksize</source>
+
* Initialize /dev/zram1 with default size (see above)
+
<source lang='bash'>echo 1 > /sys/block/zram1/initistate</source>
+
* Activate
+
<source lang='bash'>mkswap /dev/zram0
+
swapon /dev/zram0
+
mkfs.ext4 /dev/zram1
+
mount /dev/zram1 /tmp</source>
+
 
+
== Start zram automatically via Init Script (the easy way) ==
+
*Add the 'mv' overlay with layman and emerge zram-init:
+
<source lang='bash'>layman -a mv
+
emerge zram-init</source>
+
*Edit  /etc/conf.d/zram-init (set type, size, flags, etc)
+
*Add zram-init to the default runlevel
+
<source lang ='bash'>rc-config add zram-init default </source>
+

Latest revision as of 05:50, 25 January 2011

Gentoo Linux is a source-based Linux distribution created by Daniel Robbins. It uses Portage as official package management system which original design was based on FreeBSD's ports. The main portage's utility is called Emerge that is written in Python and can be used to install/uninstall packages.

Make.conf is Portage main configuration's file, because it contains many variables. For example, the best known : CFLAGS,CHOST,CXXFLAGS,USE, INPUT_DEVICES, VIDEO_CARDS,LINGUAS,GENTOO_MIRRORS.There are also many optional's variables like PORTDIR_OVERLAY. In this Linux distribution, the user compiles the source code locally according to their chosen configuration in order to improve their system and also to learn more about Linux.