#Bash 的 zramctl 命令
zramctl [OPTION]... DEVICE
功能
设置和控制 ZRAM (压缩内存)设备。
类型
可执行文件(/usr/sbin/zramctl),属于 util-linux。
参数
OPTIONS选项:-a,--algorithm lzo|lz4|lz4hc|deflate|842|zstd- 设置压缩算法-f,--find- 找到第一个未使用的 ZRAM 设备-n,--noheadings- 不打印标题行(列名)-o,--output list- 只打印指定的列;多个列名用逗号分隔--output-all- 打印所有列--raw- 以原始格式输出-r,--reset- 重置指定 ZRAM 设备的选项-s,--size size- 创建指定大小的 ZRAM 设备-t,--streams number- 设置设备可使用的最大压缩流数量-h,--help- 显示帮助-V,--version- 显示版本
DEVICE- 要操作的设备
#列名
| 列名 | 说明 |
|---|---|
NAME | ZRAM 设备名 |
DISKSIZE | 未压缩数据量的限制 |
DATA | 存储数据的未压缩大小 |
COMPR | 存储数据的压缩大小 |
ALGORITHM | 压缩算法 |
STREAMS | 并发压缩操作的数量 |
ZERO-PAGES | 没有分配内存的空白页 |
TOTAL | 总内存开销 |
MEM-LIMIT | 用于存储压缩数据的内存限制 |
MEM-USED | ZRAM 已被用于存储压缩数据的内存 |
MIGRATED | 通过压缩迁移的对象数量 |
MOUNTPOINT | 挂载点 |
#推荐阅读
#手册
ZRAMCTL(8) System Administration ZRAMCTL(8)
NAME
zramctl - set up and control zram devices
SYNOPSIS
Get info:
zramctl [options]
Reset zram:
zramctl -r zramdev...
Print name of first unused zram device:
zramctl -f
Set up a zram device:
zramctl [-f | zramdev] [-s size] [-t number] [-a algorithm]
DESCRIPTION
zramctl is used to quickly set up zram device parameters, to reset zram
devices, and to query the status of used zram devices.
If no option is given, all non-zero size zram devices are shown.
Note that zramdev node specified on command line has to already exist.
The command zramctl creates a new /dev/zram<N> nodes only when --find
option specified. It’s possible (and common) that after system boot
/dev/zram<N> nodes are not created yet.
OPTIONS
-a, --algorithm lzo|lz4|lz4hc|deflate|842|zstd
Set the compression algorithm to be used for compressing data in
the zram device.
The list of supported algorithms could be inaccurate as it depends
on the current kernel configuration. A basic overview can be
obtained by using the command "cat
/sys/block/zram0/comp_algorithm"; however, please note that this
list might also be incomplete. This is due to the fact that ZRAM
utilizes the Crypto API, and if certain algorithms were built as
modules, it becomes impossible to enumerate all of them.
-f, --find
Find the first unused zram device. If a --size argument is present,
then initialize the device.
-n, --noheadings
Do not print a header line in status output.
-o, --output list
Define the status output columns to be used. If no output
arrangement is specified, then a default set is used. Use --help to
get a list of all supported columns.
--output-all
Output all available columns.
--raw
Use the raw format for status output.
-r, --reset
Reset the options of the specified zram device(s). Zram device
settings can be changed only after a reset.
-s, --size size
Create a zram device of the specified size. Zram devices are
aligned to memory pages; when the requested size is not a multiple
of the page size, it will be rounded up to the next multiple. When
not otherwise specified, the unit of the size parameter is bytes.
The size argument may be followed by the multiplicative suffixes
KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB,
ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning
as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on
for GB, TB, PB, EB, ZB and YB.
-t, --streams number
Set the maximum number of compression streams that can be used for
the device. The default is use all CPUs and one stream for kernels
older than 4.6.
-h, --help
Display help text and exit.
-V, --version
Print version and exit.
EXIT STATUS
zramctl returns 0 on success, nonzero on failure.
FILES
/dev/zram[0..N]
zram block devices
EXAMPLE
The following commands set up a zram device with a size of one gigabyte
and use it as swap device.
# zramctl --find --size 1024M
/dev/zram0
# mkswap /dev/zram0
# swapon /dev/zram0
...
# swapoff /dev/zram0
# zramctl --reset /dev/zram0
AUTHORS
Timofey Titovets <[email protected]>, Karel Zak <[email protected]>
SEE ALSO
Linux kernel documentation
<https://docs.kernel.org/admin-guide/blockdev/zram.html>
REPORTING BUGS
For bug reports, use the issue tracker at
https://github.com/util-linux/util-linux/issues.
AVAILABILITY
The zramctl command is part of the util-linux package which can be
downloaded from Linux Kernel Archive
<https://www.kernel.org/pub/linux/utils/util-linux/>.
util-linux 2.39.3 2023-11-21 ZRAMCTL(8)