diff --git a/README.md b/README.md index 50a7a7c..bf636cb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ # TrueNAS_change_arc_size -Simple script for checking if arc size was changed. +Script for checking if arc size was changed, and changing it back. + + +## Usage +Set **arc_check.sh** file to run with cron, InitScript or both. + +In **arc_check.sh** change ****** value to match the size you want. For converting GiB to bytes I've used [this site](https://www.dataunitconverter.com/gibibyte-to-byte). + + +### Crontab +**1>** redirects stdout to /tmp/arc_size.log + +**2>** stderr to /tmp/arc_size.errlog + +<_cronexpression_> /dir/to/file/arc_check.sh 1> /tmp/arc_size.log 2> /tmp/arc_size.errlog + + +### InitScript + +You can configure it in TrueNAS GUI under System Settings > Advanced > Init/Shutdown Scripts \ No newline at end of file diff --git a/arc_check.sh b/arc_check.sh new file mode 100644 index 0000000..93ebeef --- /dev/null +++ b/arc_check.sh @@ -0,0 +1,21 @@ +#!/usr/bin/zsh + +arc_size=$(cat "/sys/module/zfs/parameters/zfs_arc_max") + +target_arc_size="" # GiB to bytes | ex. 24GiB = 25769803776 + +if [[ -z $arc_size || $arc_size -eq "0" || $arc_size -lt "0" ]] +then + echo "" >> /sys/module/zfs/parameters/zfs_arc_max + echo "Arc size changed!" + exit 1 + +elif [[ $arc_size = $target_arc_size ]] +then + echo "Arc size is set properly." + exit 0 + +else + echo "Unknown state!" + exit 1 +fi