xref: /OK3568_Linux_fs/yocto/meta-openembedded/meta-oe/recipes-extended/zram/zram/zram-swap-deinit (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#!/bin/sh
2*4882a593Smuzhiyunset -e
3*4882a593Smuzhiyun
4*4882a593Smuzhiyundevice=$1
5*4882a593Smuzhiyunif [ "$device" = "" ]; then
6*4882a593Smuzhiyun    echo "Usage: zram-swap-deinit <device>"
7*4882a593Smuzhiyun    exit 1
8*4882a593Smuzhiyunfi
9*4882a593Smuzhiyun
10*4882a593Smuzhiyunsysblockdev=/sys/block/$(basename $device)
11*4882a593Smuzhiyunif [ ! -d $sysblockdev ]; then
12*4882a593Smuzhiyun    echo "Block device not found in sysfs"
13*4882a593Smuzhiyun    exit 1
14*4882a593Smuzhiyunfi
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun# zramctl -r is not suitable as it also removes the actual device. Recreating
17*4882a593Smuzhiyun# it is non-trivial, especially if not /dev/zram0 is used...
18*4882a593Smuzhiyunecho 1 > ${sysblockdev}/reset
19*4882a593Smuzhiyun
20