Wednesday, August 6, 2014

zramctl

I merged zramctl tool a few days ago. It's based on original code from Timofey Titovets and the idea is the same as for losetup(8). zRam was merged to Linux kernel 3.14; the zram devices use RAM to create compressed block devices. The zramctl provides user friendly command line interface to create, reset and list the devices.

It's pretty simple and easy to use from userspace. See example below (kernel 3.15.7-200.fc20)
 
# modprobe zram num_devices=4
  
# zramctl --find --size 10M
/dev/zram0
 
# mkfs.ext2 -q /dev/zram0
# mount /dev/zram0 /mnt/test
  
./zramctl --find --size 10M --streams 2
/dev/zram1
 
# mkswap /dev/zram1
Setting up swapspace version 1, size = 10236 KiB
no label, UUID=776a95b7-5876-4be4-a66b-9b869cf35bd1
# swapon UUID=776a95b7-5876-4be4-a66b-9b869cf35bd1
  
# zramctl
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo            10M  40K  797B   40K       1 /mnt/test
/dev/zram1 lzo            10M   4K   78B    4K       2 [SWAP]

Note that kernel 3.14 does not support more compression streams and algorithms selection.

The next step will be probably to support zram initialization in swapon(8) to
make it easy for users to define swap on zram in /etc/fstab.