Bob Mottram 10 anni fa
parent
commit
2a29cc921f
1 ha cambiato i file con 144 aggiunte e 20 eliminazioni
  1. 144
    20
      beaglebone.txt

+ 144
- 20
beaglebone.txt Vedi File

@@ -366,6 +366,130 @@ After the system has rebooted you can ssh back unto it and log in as the root us
366 366
 uname -mrs
367 367
 #+END_SRC
368 368
 
369
+Now enable zram.
370
+
371
+#+BEGIN_SRC: bash
372
+emacs /etc/modprobe.d/zram.conf
373
+#+END_SRC
374
+
375
+Add the following:
376
+
377
+#+BEGIN_SRC: bash
378
+options zram num_devices=1
379
+#+END_SRC
380
+
381
+Save and exit, then create an initialisation script.
382
+
383
+#+BEGIN_SRC: bash
384
+emacs /etc/init.d/zram
385
+#+END_SRC
386
+
387
+Add the following:
388
+
389
+#+BEGIN_SRC: bash
390
+#!/bin/bash
391
+### BEGIN INIT INFO
392
+# Provides: zram
393
+# Required-Start:
394
+# Required-Stop:
395
+# Default-Start: 2 3 4 5
396
+# Default-Stop: 0 1 6
397
+# Short-Description: Increased Performance In Linux With zRam (Virtual Swap Compressed in RAM)
398
+# Description: Adapted from systemd scripts at https://github.com/mystilleef/FedoraZram
399
+### END INIT INFO
400
+
401
+start() {
402
+    # get the number of CPUs
403
+    num_cpus=$(grep -c processor /proc/cpuinfo)
404
+    # if something goes wrong, assume we have 1
405
+    [ "$num_cpus" != 0 ] || num_cpus=1
406
+
407
+    # set decremented number of CPUs
408
+    decr_num_cpus=$((num_cpus - 1))
409
+
410
+    # get the amount of memory in the machine
411
+    mem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching '[[:digit:]]+')
412
+    mem_total=$((mem_total_kb * 1024))
413
+
414
+    # load dependency modules
415
+    modprobe zram num_devices=$num_cpus
416
+
417
+    # initialize the devices
418
+    for i in $(seq 0 $decr_num_cpus); do
419
+    echo $((mem_total / num_cpus)) > /sys/block/zram$i/disksize
420
+    done
421
+
422
+    # Creating swap filesystems
423
+    for i in $(seq 0 $decr_num_cpus); do
424
+    mkswap /dev/zram$i
425
+    done
426
+
427
+    # Switch the swaps on
428
+    for i in $(seq 0 $decr_num_cpus); do
429
+    swapon -p 100 /dev/zram$i
430
+    done
431
+}
432
+
433
+stop() {
434
+    # get the number of CPUs
435
+    num_cpus=$(grep -c processor /proc/cpuinfo)
436
+
437
+    # set decremented number of CPUs
438
+    decr_num_cpus=$((num_cpus - 1))
439
+
440
+    # Switching off swap
441
+    for i in $(seq 0 $decr_num_cpus); do
442
+    if [ "$(grep /dev/zram$i /proc/swaps)" != "" ]; then
443
+    swapoff /dev/zram$i
444
+    sleep 1
445
+    fi
446
+    done
447
+
448
+    sleep 1
449
+    rmmod zram
450
+}
451
+
452
+case "$1" in
453
+    start)
454
+        start
455
+        ;;
456
+    stop)
457
+        stop
458
+        ;;
459
+    restart)
460
+        stop
461
+        sleep 3
462
+        start
463
+        ;;
464
+    *)
465
+        echo "Usage: $0 {start|stop|restart}"
466
+        RETVAL=1
467
+esac
468
+exit $RETVAL
469
+#+END_SRC
470
+
471
+Save and exit, then reboot again.
472
+
473
+#+BEGIN_SRC: bash
474
+chmod +x /etc/init.d/zram
475
+update-rc.d zram defaults
476
+service zram start
477
+reboot
478
+#+END_SRC
479
+
480
+After the system has rebooted ssh back into it and become the root user, then to check that the changes were successful:
481
+
482
+#+BEGIN_SRC: bash
483
+cat dmesg | grep zram
484
+#+END_SRC
485
+
486
+Should show something like:
487
+
488
+#+BEGIN_SRC: bash
489
+[  507.322337] zram: Created 1 device(s) ...
490
+[  507.651151] Adding 505468k swap on /dev/zram0.  Priority:100 extents:1 across:505468k SS
491
+#+END_SRC
492
+
369 493
 ** Random number generation
370 494
 
371 495
 #+BEGIN_VERSE
@@ -2095,34 +2219,34 @@ Search for MaxClients and replace the value with 6. As an example the settings s
2095 2219
 Timeout 30
2096 2220
 KeepAlive On
2097 2221
 MaxKeepAliveRequests 5
2098
-KeepAliveTimeout 1
2222
+KeepAliveTimeout 10
2099 2223
 
2100 2224
 <IfModule mpm_prefork_module>
2101
-    StartServers 5
2102
-    MinSpareServers 5
2103
-    MaxSpareServers 10
2104
-    MaxClients 5
2105
-    MaxRequestsPerChild 10
2225
+    StartServers           1
2226
+    MinSpareServers        1
2227
+    MaxSpareServers        3
2228
+    MaxClients            10
2229
+    MaxRequestsPerChild 3000
2106 2230
 </IfModule>
2107 2231
 
2108 2232
 <IfModule mpm_worker_module>
2109
-    StartServers 2
2110
-    MinSpareThreads 5
2111
-    MaxSpareThreads 5
2112
-    ThreadLimit 6
2113
-    ThreadsPerChild 10
2114
-    MaxClients 5
2115
-    MaxRequestsPerChild 10
2233
+    StartServers          1
2234
+    MinSpareThreads       5
2235
+    MaxSpareThreads      15
2236
+    ThreadLimit          25
2237
+    ThreadsPerChild       5
2238
+    MaxClients           25
2239
+    MaxRequestsPerChild 200
2116 2240
 </IfModule>
2117 2241
 
2118 2242
 <IfModule mpm_event_module>
2119
-    StartServers 2
2120
-    MinSpareThreads 5
2121
-    MaxSpareThreads 5
2122
-    ThreadLimit 6
2123
-    ThreadsPerChild 10
2124
-    MaxClients 5
2125
-    MaxRequestsPerChild 10
2243
+    StartServers          1
2244
+    MinSpareThreads       5
2245
+    MaxSpareThreads      15
2246
+    ThreadLimit          25
2247
+    ThreadsPerChild       5
2248
+    MaxClients           25
2249
+    MaxRequestsPerChild 200
2126 2250
 </IfModule>
2127 2251
 #+END_SRC
2128 2252