ecdye / zram-config

A complete zram-config utility for swap, directories, and logs to reduce SD, NAND and eMMC block wear.
MIT License
413 stars 53 forks source link

How do I use zram-config #10

Closed spotty101 closed 5 years ago

spotty101 commented 5 years ago

How do I use zram-config
I have changed the hard drive on an old laptop using mx linux ( just found out it does not use systemd ) to a ssd. So I thought I would try and reduce the writes to it using zswap and found your project which also reduces log writes to the drive.

I have downloaded and installed using

sudo apt-get install git git clone https://github.com/StuartIanNaylor/zram-config cd zram-config sudo sh install.sh

edited ztab to (without the --)

--# swap alg mem_limit disk_size swap_priority page-cluster swappiness swap lz4 200M 600M 75 0 90

--# dir alg mem_limit disk_size target_dir bind_dir --#dir lz4 50M 150M /home/pi /pi.bind

--# log alg mem_limit disk_size target_dir bind_dir oldlog_dir log lz4 50M 150M /var/log /log.bind /opt/zram/oldlog

I started it using

sudo ./zram-config start I got this error grep: /boot/cmdline.txt: No such file or directory

Starting zram

:~/zram-config $ sudo ./zram-config start [sudo] password for david: grep: /boot/cmdline.txt: No such file or directory

Laptop No systemd

zramctl NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT /dev/zram0 lz4 600M 4K 76B 12K 2 [SWAP]

df Filesystem 1K-blocks Used Available Use% Mounted on udev 4001928 0 4001928 0% /dev tmpfs 806188 1472 804716 1% /run /dev/sdb2 19901264 6249376 12617904 34% / tmpfs 5120 4 5116 1% /run/lock tmpfs 2487680 183564 2304116 8% /run/shm /dev/sdb3 80107640 19042820 56952440 26% /home /dev/sda5 30865336 24375064 4915720 84% /mnt/MX-Data /dev/sda4 323202812 162449304 160753508 51% /mnt/Windows /dev/sda8 81258232 74505792 2601708 97% /mnt/Old-home cgroup 12 0 12 0% /sys/fs/cgroup tmpfs 806184 20 806164 1% /run/user/1000

free -h total used free shared buff/cache available Mem: 7.7G 3.5G 698M 563M 3.5G 3.4G Swap: 4.6G 0B 4.6G

Note larger swap total

swapon NAME TYPE SIZE USED PRIO /dev/sdb4 partition 4.2G 0B -2 /dev/zram0 partition 600M 0B 75

Note zram partition I assume swap is working

but nothing suggesting log file has been moved

I am comparing with a virtualbox in a desktop with debian that uses systemd

here i can see the log seems to be set up

df shows /dev/zram1 numbers /opt/zram/zram1 overlay1 number /var/log

zramctrl has extra line /dev/zram1 lz4 number /opt/zram/zram1

Thanks for your help

Dave

StuartIanNaylor commented 5 years ago

zram-conf is very raspberry pi/arm specific.

https://github.com/StuartIanNaylor/zram-swap-config https://github.com/StuartIanNaylor/zramdrive https://github.com/StuartIanNaylor/log2zram Are general individual services but still use systemd but guess we could just /etc/rc-local or /etc/inittab The cmdline.txt alternative in non arm world would be a grub line I guess.

What distro and version are you using as I will knock up a branch for older x86

spotty101 commented 5 years ago

I was wondering why you had the other 3. I thought you just decided to roll them into one. Both the desktop and the laptop are debian stretch X64 based. The laptop is MXlinux which I just found out does not use systemD by default. I am assuming the destop does.

Would it be better if I uninstall and use the others?

Dave

StuartIanNaylor commented 5 years ago

Mxlinux already has a zram service /usr/local/bin/zram its also one of the nasty type that doesn't check for existing services but doesn't seem to be enabled by default Try the sysv-init branch created no ephemeral mode will look later but debian has services for that already. git clone --branch sysv-init https://github.com/StuartIanNaylor/zram-config from zram-config git pull git checkout sysv-init

They are all examples that check for other zram service and can co-habit as that basic test and method is missed from most. zram-conf is an all in example using a ztab to make a point that zram is not just swap. If you create a dir of /home/%USERNAME% you will notice there is a delay on start as the copyup of OverlaysFS CoW creates files with write access in the upper. Dunno about home really but you can tell me how it goes. Logs are working and shipping out to oldlog is enabled so is the swap. zram-conf will work with other zram services but if they will work with zram-conf ie a simple check zram devices already exist is unknown and prob no.

I its an old laptop do approx half your ram so mem-limit is half ram and disk-size is 3x that. The page-cache 0f 0 is optimised for zram rather than the default of 3 (8 page chache) the swappiness with lacking processors above 80 can slow boot but once the boot has finished because overall load is much less even 100 can provide much benefit. Basically 100 is better but it might create to much hit on boot so play and see how it goes.

spotty101 commented 5 years ago

I installed the sysv-init version It seems to be working as expected now even after a reboot

Thanks Dave

glad i noticed the other day that mxlinux is a non systemd distro I am sure that would have made this worse if I had not known

StuartIanNaylor commented 5 years ago

MXLinux seems to be debian for those who don't like systemd as its actually there just not enabled. The conversion of the script was simple really the emphemeral mode might take some more time but really never envisage for x86. Glad its working and glad I also have a sysv-init version now.

With no systemd the main branch has no service provider so just will not start. Being X86 its grub rather than uboot for arm so that is quite different.

I don't intend to make an all-in-one for all architecture and distro's as it just turns into scripting hell and becomes hard to read. The scripts are available as examples to hack, copy and clone and only have a licence because no licence equates to all rights reserved but just take what you want as I claim no ownership as I don't do property and certainly nothing intellectual about me.