Added config file option for debugging

This commit is contained in:
Scott B 2021-08-15 23:01:03 -07:00
parent e1780c39e2
commit dc77af4a6c
3 changed files with 18 additions and 11 deletions

View file

@ -17,7 +17,7 @@ Install from the AUR: `paru -S zram-swap-git`
or directly from GitHub:
```bash
```sh
mkdir zram-swap-git && cd zram-swap-git
wget https://raw.githubusercontent.com/foundObjects/zram-swap/arch-packaging/PKGBUILD
makepkg -Cci
@ -28,7 +28,7 @@ Make any configuration changes to `/etc/default/zram-swap` first if desired, see
*Others:*
```bash
```sh
git clone https://github.com/foundObjects/zram-swap.git
cd zram-swap && sudo ./install.sh
```
@ -51,7 +51,7 @@ The configuration file is heavily commented and self-documenting.
A very simple configuration that's expected to use roughly 2GB RAM might look
something like:
```bash
```sh
# override fractional calculations and specify a fixed swap size
_zram_fixedsize="6G"
@ -74,15 +74,13 @@ lz4.
### Debugging
Start zram-swap.sh with `zram-swap.sh -x (start|stop)` to view the debug trace
and determine what's going wrong.
To view a script debug trace either start zram-swap.sh with `zram-swap.sh -x (start|stop)`
or uncomment the debug flag in `/etc/default/zram-swap`:
To dump the full execution trace during service start/stop edit
`/etc/systemd/systemd/zram-swap.service` and add -x to the following two lines:
```
ExecStart=/usr/local/sbin/zram-swap.sh -x start
ExecStop=/usr/local/sbin/zram-swap.sh -x stop
```sh
# setting _zram_swap_debugging to any non-zero value enables debugging
# default: undefined
_zram_swap_debugging="beep boop"
```
### Compatibility

View file

@ -6,6 +6,10 @@ _zram_algorithm="lz4"
# default: "1/2"
_zram_fraction="1/2"
# setting _zram_swap_debugging to any non-zero value enables debugging
# default: undefined
#_zram_swap_debugging="beep boop"
# expected compression factor; set this by hand if your compression results are
# drastically different from the estimates below
#

View file

@ -17,11 +17,16 @@ _zram_fraction="1/2"
_zram_algorithm="lz4"
_comp_factor=''
_zram_fixedsize=''
_zram_swap_debug=''
# load user config
[ -f /etc/default/zram-swap ] &&
. /etc/default/zram-swap
# support a debugging flag in the config file so people don't have to edit the systemd service
# to enable debugging
[ -n "$_zram_swap_debug" ] && set -x
# set expected compression ratio based on algorithm -- we'll use this to
# calculate how much uncompressed swap data we expect to fit into our
# target ram allocation. skip if already set in user config