Skip to content

Commit

Permalink
zrmactl: add new command to control /dev/zramN devices
Browse files Browse the repository at this point in the history
Co-Author: Timofey Titovets <nefelim4ag@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
  • Loading branch information
karelzak committed Aug 1, 2014
1 parent d990dea commit 0624d84
Show file tree
Hide file tree
Showing 5 changed files with 695 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,4 @@ update.log
/whereis
/wipefs
/write
/zramctl
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,14 @@ UL_REQUIRES_LINUX([losetup])
UL_REQUIRES_BUILD([losetup], [libsmartcols])
AM_CONDITIONAL([BUILD_LOSETUP], [test "x$build_losetup" = xyes])

AC_ARG_ENABLE([zramctl],
AS_HELP_STRING([--disable-zramctl], [do not build zramctl]),
[], [UL_DEFAULT_ENABLE([zramctl], [check])]
)
UL_BUILD_INIT([zramctl])
UL_REQUIRES_LINUX([zramctl])
UL_REQUIRES_BUILD([zramctl], [libsmartcols])
AM_CONDITIONAL([BUILD_ZRAMCTL], [test "x$build_zramctl" = xyes])

AC_ARG_ENABLE([fsck],
AS_HELP_STRING([--disable-fsck], [do not build fsck]),
Expand Down
9 changes: 9 additions & 0 deletions sys-utils/Makemodule.am
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@ endif
endif # BUILD_LOSETUP


if BUILD_ZRAMCTL
sbin_PROGRAMS += zramctl
dist_man_MANS += sys-utils/zramctl.8
zramctl_SOURCES = sys-utils/zramctl.c
zramctl_LDADD = $(LDADD) libcommon.la libsmartcols.la
zramctl_CFLAGS = $(AM_CFLAGS) -I$(ul_libsmartcols_incdir)
endif


if BUILD_PRLIMIT
usrbin_exec_PROGRAMS += prlimit
dist_man_MANS += sys-utils/prlimit.1
Expand Down
106 changes: 106 additions & 0 deletions sys-utils/zramctl.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
.TH ZRAMCTL 8 "July 2014" "util-linux" "System Administration"
.SH NAME
zramctl \- set up and control zram devices
.SH SYNOPSIS
.ad l
Get info:
.sp
.in +5
.BR zramctl " [options]"
.sp
.in -5
Reset zram:
.sp
.in +5
.B "zramctl \-r"
.IR zramdev ...
.sp
.in -5
Print name of first unused zram device:
.sp
.in +5
.B "zramctl \-f"
.sp
.in -5
Setup zram device:
.sp
.in +5
.B zramctl
.RB [ \-f " | "\fIzramdev\fP ]
.RB [ \-s
.IR size ]
.RB \ [ \-t
.IR number ]
.in +8
.RB [ \-a
.IR algorithm ]
.sp
.in -13
.ad b
.SH DESCRIPTION
.B 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 zram devices
are shown.

.SH OPTIONS
.IP "\fB\-a, \-\-algorithm \fI{lzo|lz4}\fP"
Set compression algorithm used for compress data in zram device.
.IP "\fB\-f, \-\-find\fP"
Find the first unused zram device. If a \fB--size\fR argument is present, then
initialize the device.
.IP "\fB\-h, \-\-help\fP"
print help
.IP "\fB\-h, \-\-noheadings\fP"
Do not print a header line in status output.
.IP "\fB\-o, \-\-output \fIlist\fP"
Define the status output columns to use. If no output arrangement is specified,
then a default set is used.
Use \fB\-\-help\fP to get a list of all supported columns.
.IP "\fB\-r, \-\-reset\fP
Reset options specified zram device(s). Zram device setting can be changed only
after reset.
.IP "\fB\-\-raw\fP"
Use the raw format for status output.
.IP "\fB\-s, \-\-size\fP \fIsize\fP
Force zram driver to reread size of the file associated with the specified zram device

The \fIsize\fR 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.
.IP "\fB\-t, \-\-streams \fInumber\fP"
Set number of maximum compress streams what used for device. The default is one stream.
.IP "\fB\-V, \-\-version\fP"
Display version information and exit.

.SH RETURN VALUE
.B zramctl
returns 0 on success, nonzero on failure.

.SH FILES
.TP
.I /dev/zram[0..N]
zram block devices

.SH EXAMPLE
The following commands can be used for setup the zram device with gigabyte size
and using as swap device.
.nf
.IP
# zramctl --find --size 1024M
/dev/zram0
# mkswap /dev/zram0
# swapon /dev/zram0
...
# swapoff /dev/zram0
# zramctl --reset /dev/zram0
.fi
.SH AUTHORS
.nf
Timofey Titovets <nefelim4ag@gmail.com>
Karel Zak <kzak@redhat.com>
.fi
.SH AVAILABILITY
The zramctl command is part of the util-linux package and is available from
ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
Loading

0 comments on commit 0624d84

Please sign in to comment.