diff --git a/README.md b/README.md index e3fa714..a806984 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/service/zram-swap.config b/service/zram-swap.config index 61e3b7d..0f04624 100644 --- a/service/zram-swap.config +++ b/service/zram-swap.config @@ -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 # diff --git a/zram-swap.sh b/zram-swap.sh index 06543eb..2db30e2 100755 --- a/zram-swap.sh +++ b/zram-swap.sh @@ -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