stuartiannaylor last edited by
Don’t know if you know how generally stinky the ubuntu zram-conf-05.deb is but take it from me it contains high notes of cheese.
I think I have completed at least a zram-conf that in name allows you to configure zram which might be useful for the magicmirror folder as mounting a zram drive at /magicmirror will cut sd blockwear to somewhere to nothing to extremely minimal whilst running at near ram speed.
All the info is at https://github.com/StuartIanNaylor/zram-config
sudo apt-get install git git clone https://github.com/StuartIanNaylor/zram-config cd zram-config sudo sh install.sh
Will get you up and running but it all fairly easy runs from a ztab file in /etc where you can set as many drives or swaps as you wish even logs.
If anyone fancies giving it a try please do as needing some testers but seem to be working fine.
Lusbueb last edited by
is this the same?
stuartiannaylor last edited by stuartiannaylor
Same in as they both use the same terrible outmoded methods that is essentially a copy of zram-conf-05.deb.
Since kernel 3.15 zram has been multi-stream and partitioning by core just makes smaller swaps with smaller single page write ability for absolutely no reason.
Also makes no check that any previous zram utils maybe in operation and overwrites.
Ignores the important mem_limit property for sys_admins and completely ignores the hot_plug and remove methods.
I have no idea why that bad script has been copied and emulated so much, but yeah the above are very much the same as zram-conf-05.deb.
I suggest you have a look at https://github.com/StuartIanNaylor/zram-config as it combines many functions that are beneficial for MagicMirror and has a better implementation of zram for quite a few reasons.
Uses /etc/ztab so if you wish you can set up as many zswaps, zdir and a zlog if you wish.
Zlog creates a zram directory which is the upper in a OverlayFS file systems so only on write is a file copied up. It also uses the olddir directive of logrotate so oldlogs are shipped to persistent.
Provides negligible flash wear and an extremely small Zram memory footprint.
Zdir is the same as zlog without the logrotate directives where the MagicMirror directory is loaded via a OverlayFS mount with the upper mounted on zram.
Due to the copyup of COW only files that are write accessed use upper so again the whole MagicMirror dir can be provided with zero SD writes in an extremely small memory footprint.
You can make as many Zdir as you need.
Zswap does actually use the kernel doc methods of hot_plug and hot_remove for zram devices and will work with other zram services.
Also includes the important mem-Limit for sysadmin and Zswap is multi-stream and there is little point making swaps per core but you can make as many as you like.
Linux swapiness and page-cache settings are also based the assumption of HDD like swap and zram is mem not disk so swapiness needs to be increased to 80-100 and page-cache set to 0 for single pages to help cut latency as the default of 3 = caches of 8 pages for disk based caching.
None of the scripts ever seem to provide the tuneables to actually utilise zram performance and again you can set both in the ztab as you set up your swap.
Hopefully the likes of the above will actually read the kernel docs for zram https://www.kernel.org/doc/Documentation/blockdev/zram.txt before they just copy and paste a bad Ubuntu script again.
Not really sure how zram will in anyway give you smooth youtube/video playback though… ? But if its caching locally then yes.
But yeah you can get near memcpy speed with compression rations of up 3:1 or even use deflate or ztstd which are slower and prob not for swap but for text such as logs or much of the data format that nodejs uses the compression can be much higher than the performance base of LZO/4.
pi@raspberrypi:~ $ zramctl NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT /dev/zram0 lz4 1.2G 4K 76B 4K 4 [SWAP] /dev/zram1 lz4 150M 16.3M 25.1K 208K 4 /opt/zram/zram1 /dev/zram2 lz4 60M 7.5M 1.2M 1.7M 4 /opt/zram/zram2
pi@raspberrypi:~ $ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 14803620 2558152 11611220 19% / devtmpfs 470116 0 470116 0% /dev tmpfs 474724 223868 250856 48% /dev/shm tmpfs 474724 12284 462440 3% /run tmpfs 5120 4 5116 1% /run/lock tmpfs 474724 0 474724 0% /sys/fs/cgroup /dev/mmcblk0p1 44220 22390 21831 51% /boot /dev/zram1 132384 280 121352 1% /opt/zram/zram1 overlay1 132384 280 121352 1% /home/pi/MagicMirror /dev/zram2 55408 3460 47648 7% /opt/zram/zram2 overlay2 55408 3460 47648 7% /var/log tmpfs 94944 0 94944 0% /run/user/1000
cat /etc/ztab # swap alg mem_limit disk_size swap_priority page-cluster swappiness swap lz4 400M 1200M 75 0 90 # dir alg mem_limit disk_size target_dir bind_dir dir lz4 50M 150M /home/pi/MagicMirror /magicmirror.bind # log alg mem_limit disk_size target_dir bind_dir oldlog_dir log lz4 20M 60M /var/log /log.bind /oldlog
pi@raspberrypi:~ $ free -h total used free shared buff/cache available Mem: 927M 206M 184M 233M 535M 434M Swap: 1.3G 0B 1.3G
pi@raspberrypi:~ $ swapon NAME TYPE SIZE USED PRIO /dev/zram0 partition 1.2G 0B 75 /var/swap file 100M 0B -2
pi@raspberrypi:/opt/zram $ ls log.bind magicmirror.bind oldlog zram1 zram2
pi@raspberrypi:/opt/zram $ top top - 23:18:21 up 1:28, 2 users, load average: 0.31, 0.29, 0.29 Tasks: 114 total, 1 running, 68 sleeping, 0 stopped, 0 zombie %Cpu(s): 1.9 us, 0.1 sy, 0.0 ni, 98.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 949448 total, 153464 free, 223452 used, 572532 buff/cache KiB Swap: 1331192 total, 1331192 free, 0 used. 412052 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1215 pi 20 0 600844 325968 287276 S 5.3 34.3 8:09.51 chromium-browse 2536 pi 20 0 8104 3204 2728 R 1.6 0.3 0:00.11 top 970 pi 20 0 775108 156128 112876 S 1.0 16.4 11:17.06 chromium-browse 1611 pi 20 0 11656 3772 3056 S 0.3 0.4 0:00.30 sshd 1 root 20 0 27072 5964 4824 S 0.0 0.6 0:02.51 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H 6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq 7 root 20 0 0 0 0 S 0.0 0.0 0:00.24 ksoftirqd/0 8 root 20 0 0 0 0 I 0.0 0.0 0:00.87 rcu_sched 9 root 20 0 0 0 0 I 0.0 0.0 0:00.00 rcu_bh