Forum
  • Search
  • Member List
  • Calendar
Hello There, Guest! Login Register — Login with Facebook

[PROBLEM] RAM disk/drive on Xbian, how to use zramswap?
Thank you for your donation

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode | Linear Mode
Problem: RAM disk/drive on Xbian, how to use zramswap?
19th May, 2023, 06:29 AM
Post: #1
postcd Offline
Registered
Posts: 31
Joined: Nov 2021
Reputation: 0
RAM disk/drive on Xbian, how to use zramswap?
Hello,

one Kodi plugin downloads repeatedly a file worth tens of MB data and to save SDHC card writing cycles, I have found using "df -Th", that only tmpfs (RAM based filesystem per my understanding) is /dev and /run
# df -Th|grep tmpfs
Code:
devtmpfs       devtmpfs  1.6G   71M  1.5G   5% /dev
none           tmpfs     360M  748K  359M   1% /run
none           tmpfs     4.0K     0  4.0K   0% /sys/fs/cgroup

I may utilize /dev/bigfile.name if i "chown xbian /dev", but since it may not be good practice, but /run seems to have already writing permissions for all users "Access: (1777/drwxrwxrwt)". Beside that I was able to do:

Code:
mkdir -p /mnt/tmpfs
echo "tmpfs /mnt/tmpfs tmpfs size=100M,mode=0755,uid=xbian 0 0" >> /etc/fstab
mount -a
(allowing me to utilize /mnt/tmpfs/ directory as a RAM disk storage)

Yet someone suggested me to use zram with lz4 compression (claiming to be better compression than Xbian default lzo-rle) to save the space. Though i have doubts about this approach since zram is slower than regular tmpfs and if tmps/memory pressure is high, it will then move to zram swap per my understanding). But anyway if i want to do it, i tried these steps (failed):

# zramctl --output-all
Code:
NAME       DISKSIZE DATA COMPR ALGORITHM STREAMS ZERO-PAGES TOTAL MEM-LIMIT MEM-USED MIGRATED MOUNTPOINT
/dev/zram0     128M   4K   73B lzo-rle         4          0    4K        0B       4K       0B [SWAP]

# mount -t ext4 /dev/zram0 /mnt/zram
Code:
mount: /mnt/zram: /dev/zram0 already mounted or mount point busy.

# mount -t tmpfs /dev/zram0 /mnt/zram
# df -h
Code:
/dev/zram0      1.8G     0  1.8G   0% /mnt/zram
tmpfs           100M   26M   75M  26% /mnt/tmpfs

I am able to mount it automatically using /etc/fstab line:
Code:
/dev/zram0 /mnt/zram tmpfs size=100M,mode=0755,uid=xbian 0 0

I could do:
# swapoff -a;zramctl --algorithm lz4 --streams 4 --size 128M /dev/zram0 && swapon
# zramctl --output-all
Code:
NAME       DISKSIZE DATA COMPR ALGORITHM STREAMS ZERO-PAGES TOTAL MEM-LIMIT MEM-USED MIGRATED MOUNTPOINT
/dev/zram0     128M   0B    0B lz4             4          0    0B        0B       0B       0B
# free -h
Code:
Swap:             0B          0B          0B

I could write file to /mnt/zram/ but i see no zram usage:

# df -h /mnt/zram /mnt/tmpfs
Code:
Filesystem      Size  Used Avail Use% Mounted on
/dev/zram0      100M   26M   75M  26% /mnt/zram
tmpfs           100M   26M   75M  26% /mnt/tmpfs

# zramctl
Code:
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lz4           128M   0B    0B    0B       4

# free -h
Code:
total        used        free      shared  buff/cache   available
Mem:           3.5Gi       330Mi       2.4Gi       160Mi       808Mi       2.8Gi
Swap:             0B          0B          0B

and test the speed:

ioping -R /mnt/zram
-R, -rapid test with rapid I/O during 3s (-q -i 0 -w 3)

Code:
--- /mnt/zram (tmpfs /dev/zram0 100 MiB) ioping statistics ---
311.8 k requests completed in 2.45 s, 1.19 GiB read, 127.1 k iops, 496.6 MiB/s
generated 311.8 k requests in 3.00 s, 1.19 GiB, 103.9 k iops, 405.9 MiB/s
min/avg/max/mdev = 6.41 us / 7.87 us / 1.78 ms / 6.88 us

vs regular tmpfs:

Code:
--- /mnt/tmpfs (tmpfs tmpfs 100 MiB) ioping statistics ---
314.2 k requests completed in 2.46 s, 1.20 GiB read, 127.9 k iops, 499.6 MiB/s
generated 314.2 k requests in 3.00 s, 1.20 GiB, 104.7 k iops, 409.2 MiB/s
min/avg/max/mdev = 6.39 us / 7.82 us / 1.36 ms / 4.46 us

# fdisk -x /dev/zram0
Code:
Disk /dev/zram0: 128 MiB, 134217728 bytes, 32768 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

# lsblk -a
Code:
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
ram0          1:0    0    4M  0 disk
ram1          1:1    0    4M  0 disk
...
zram0       254:0    0  128M  0 disk /mnt/zram
zram1       254:1    0    0B  0 disk
zram2       254:2    0    0B  0 disk
zram3       254:3    0    0B  0 disk

Do you have idea on /etc/fstab line to mount zram based filesystem please?
Visit this user's website Find all posts by this user
Quote this message in a reply
25th May, 2023, 04:37 AM
Post: #2
Nachteule Offline
Administrator
******
Posts: 2,406
Joined: Dec 2014
Reputation: 122
RE: RAM disk/drive on Xbian, how to use zramswap?
Simple answer:

xbian-package-zram-swap

/etc/default/zram-swap
Find all posts by this user
Quote this message in a reply
12th Jun, 2023, 06:50 PM
Post: #3
postcd Offline
Registered
Posts: 31
Joined: Nov 2021
Reputation: 0
RE: RAM disk/drive on Xbian, how to use zramswap?
> xbian-package-zram-swap

did "apt install xbian-package-zram-swap" -> "xbian-package-zram-swap is already the newest version (1.0.8)."

> /etc/default/zram-swap

is a config. file apparently, thanks. Being unsure how to modify it, i assumed i need to somehow activate zram so i did:

Quote:ZRUNSHM=1

After reboot, it caused following in "zramctl --output-all" output:
Quote:/dev/zram2 1M 44K 743B lzo-rle 4 1 24K 0B 24K 0B /run/shm

(only 1MB? Copying file to it says: No space left on device)
Quote:# grep -v "#" /etc/default/zram-swap|grep .
SIZE=128
SWAPFILE=
ZRUNSHM=1
ZTEMPXBMC=0
SWAPNOUSE='/dev/sda21,/dev/mmcblk0p99'

and mount:
Quote:/dev/zram2 on /run/shm type ext2 (rw,nosuid,noatime)

Quote:# swapon
NAME TYPE SIZE USED PRIO
/dev/zram0 partition 128M 0B 20
/dev/mmcblk0p3 partition 245M 0B 0

Setting SWAPFILE=/mnt/zram
not apparently changed outputs of above commands (file existed before reboot, after reboot not exist)

I wanted to have proper zram 128M partition and proper grow-able zramswap... any idea what to try please?
Visit this user's website Find all posts by this user
Quote this message in a reply
12th Jun, 2023, 08:11 PM
Post: #4
Nachteule Offline
Administrator
******
Posts: 2,406
Joined: Dec 2014
Reputation: 122
RE: RAM disk/drive on Xbian, how to use zramswap?
Moving shm to zram is complete nonsense in my opinion

Ever googled for zswap?

Since you obviously want to do everything yourself I can't help you there. and - please don't be angry - I don't have much desire to do that anymore either
Find all posts by this user
Quote this message in a reply
17th Nov, 2023, 01:05 PM
Post: #5
ontosalsa Offline
Banned
Posts: 1
Joined: Nov 2023
RE: RAM disk/drive on Xbian, how to use zramswap?
I learned about zswap on Google. I'm still having problems, but thanks for your feedback anyway.
Visit this user's website Find all posts by this user
Quote this message in a reply
11th Dec, 2023, 02:51 PM
Post: #6
sortrequire Offline
Banned
Posts: 1
Joined: Dec 2023
RE: RAM disk/drive on Xbian, how to use zramswap?
(12th Jun, 2023 08:11 PM)Nachteule Wrote:  Moving shm to zram is complete nonsense in my opinion

Ever googled for zswap?

Since you obviously want to do everything yourself I can't help you there. and - please don't be angry - I don't have much desire to do that anymore either

I find it necessary to search for the right keywords to extract data. I'm doing research based on your suggestion. Looking forward to finding a solution.
Visit this user's website Find all posts by this user
Quote this message in a reply
27th Feb, 2025, 11:14 AM
Post: #7
ngoutlandish Offline
Registered
Posts: 1
Joined: May 2024
Reputation: 0
RE: RAM disk/drive on Xbian, how to use zramswap?
This sounds like something from a Linux or performance optimization discussion, maybe about memory management? Are you troubleshooting something specific, or just sharing a frustrating exchange?
Visit this user's website Find all posts by this user
Quote this message in a reply
28th Jun, 2025, 06:58 PM
Post: #8
annawhite Offline
Registered
Posts: 1
Joined: Jun 2025
Reputation: 0
RE: RAM disk/drive on Xbian, how to use zramswap?
Have you considered using zramfs instead of zram0 to mount directly as a filesystem? And have you tried writing large files to /mnt/zram to see when ZRAM actually compresses and takes up RAM? Because according to the parameters you shared, ZRAM is not "forced to work" due to the large amount of free memory.
Among Us Online
Find all posts by this user
Quote this message in a reply
3rd Jul, 2025, 11:49 AM
Post: #9
ben12 Offline
Registered
Posts: 2
Joined: Jul 2025
Reputation: 0
RE: RAM disk/drive on Xbian, how to use zramswap?
(12th Jun, 2023 08:11 PM)Nachteule Wrote:  Eaglercraft Moving shm to zram is complete nonsense in my opinion
Ever googled for zswap?
Since you obviously want to do everything yourself I can't help you there. and - please don't be angry - I don't have much desire to do that anymore either
Zswap is smarter for many workloads because it defers actual disk swapping. It's good on devices with actual swap partitions. On the other hand, zram is good on devices without disks, like many Raspberry Pi systems.
Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


  • View a Printable Version
  • Send this Thread to a Friend
  • Subscribe to this thread
Forum Jump:

Current time: 5th Jul, 2025, 07:11 AM Powered By MyBB, © 2002-2025 MyBB Group.