zram-init − Scripts to support compressed swap devices or ramdisks with zram
zram-init [options] SIZE|write [DIR]
Prepare a zram
device and use it as swap (resp. mount it under DIR).
SIZE is the maximal size in megabytes. For
umounting/freeing the zram device, use SIZE=0.
When using write (or anything else starting with
w) an idle writeback is forced (only makes sense if
previously initialized with -w or -W
LIMIT).
If DIR is
− then only a filesystem is created in
/dev/zramDEV (or the device is removed if SIZE
is 0), but it is not mounted (options −o −c
−m −T take no effect in this case, of
course).
The latter can be useful e.g. for btrfs if multiple devices
should be mounted jointly afterwards.
An empty argument means the same as if the option is not specified.
−d DEV |
Use zram device /dev/zramDEV. Default is 0 (/dev/zram0). |
Make sure to use the matching value for unmounting (SIZE=0)!
-D NUM |
If modprobe needs to be used, require NUM devices. |
This is not recommended. Rely instead on /etc/modprobe.d/zram.conf with the line options zram num_devices=NUM.
−s NUM |
Use up to NUM parallel compression streams for the device. | ||
−S MAX |
Use maximally MAX megabytes of uncompressed memory for the device. | ||
−b DEV |
Use DEV as backing device. | ||
−I |
If combined with −b DEV, store incompressible pages to backing device. | ||
−w |
If combined with -b DEV, enable idle writeback to backing device. |
−W LIMIT
As -w but additionally set writeback_limit to LIMIT * 4kB.
−a 842|deflate|lz4|lz4hc|lzo|zstd
Set the compression algorithm to be used for compressing data in the zram device.
−c OWNER
Chown to OWNER (resp. OWNER:GROUP) after mounting.
−m MODE
Chmod DIR to MODE after mounting.
−o OPTS
Mount DIR with −o OPTS.
−p PRIO
Use priority PRIO for
the swap device. Default is 16383.
Use PRIO=− if you want to keep the default
priority (-1).
−t ext2|ext4|btrfs|xfs
Set the filesystem type if DIR is specified. Default is ext4.
−B BSIZE
Override default blocksize (ext2, ext4). Valid values are 1024, 2048, 4096.
−i IRATIO
Override default bytes/inodes in fs (ext2, ext4).
−N INODES
Override inode count (ext2, ext4).
−L LABEL
Specify the label LABEL for the new filesystem.
−U UUID
Specify the uuid UUID for the new filesystem.
−T |
Do not use the discard (TRIM) feature of ext4/swap. |
Use this option with linux-3.14 or earlier or when you want a slight speed increase at the cost of possibly wasting a lot of memory.
−l |
Do not use zramctl even if available. | ||
−k |
Do no attempt to umount/free a previously used zram under this device. |
If you have push.sh in $PATH, you can also use the following options accumulatively:
−K ARG |
Pass ARG to the respective mkswap or mkfs.* call. |
|||
−M ARG |
Pass ARG to the respective swapon/mount call. |
|||
−2 ARG |
Pass ARG to the tune2fs call (ignored unless for ext2 or ext4). |
|||
−Z ARG |
Pass ARG to the zramctl call. |
Call with LANG=C to disable translations.
Martin Väth <martin at mvath.de> (developer, current maintainer)
zramctl(8), mkswap(8), mke2fs(8), mkfs.btrfs(8)
The zram-init homepage https://github.com/vaeth/zram-initprovides