[Raspberry Pi3] Zram settings

Source: Internet
Author: User

Linux 3.15 added a Mac-like function, memory compression zram, and a zswap, Zram is usually placed in a module in the system, so that can be customized according to the needs of the load.

Raspberry Pi3 1g Memory capacity is too small, set the Zram can squeeze a bit of memory, android4.4 data seems to be 40%.

Paste code (copied from desktop Ubuntu)

Setup code:

#!/bin/SH# Load Dependency modulesnrdevices=$(grep-C ^processor/proc/cpuinfo |sed 's/^0$/1/')ifModinfo Zram |grep-Q'zram_num_devices:' 2>/dev/NULL; ThenModprobe_args="Zram_num_devices=${nrdevices}"elifModinfo Zram |grep-Q'num_devices:' 2>/dev/NULL; ThenModprobe_args="Num_devices=${nrdevices}"ElseExit1fimodprobezram $MODPROBE _args# Calculate memory to use forZram (1/2of RAM) Totalmem= ' Lc_all=c Free|grep-E"^mem:"|sed-E'S/^mem: *//'-E's/*.*//'' Mem=$ (((Totalmem/2/${nrdevices}) *1024x768) # Initialize the devices forIinch$(seq${nrdevices}); DoDevnumber=$ ((I-1))  Echo$mem >/sys/block/zram${devnumber}/disksize Mkswap/dev/Zram${devnumber} swapon-P5/dev/Zram${devnumber} Done

To close the code:

#!/bin/shif devices=$ (grepawk'{print $}'  then-in does      swapoff $i  donefi  rmmod Zram

If you want to turn on the settings, just add the code to the/etc/rc.local, the boot automatically set

Startup or not can be viewed using the following command:

Swapon-s

The output is as follows

Filename                Type        Size    used    priority/DEV/ZRAM0                                 partition    118464     0     5/dev/zram1                                 partition    118464    0    5/dev/zram2                                 Partition    118464    0    5/dev/zram3                                 partition    118464     0    5

You can see that the number of 4 and processor is the same, the total is half of the total usable physical memory, as for why the processor number is better, the reason is unknown

[Raspberry Pi3] Zram settings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.