How to Avoid Stales while Copying Plots

Copying a plot from the temporary drive to your final drive after its completion leads to a high amount of input-output (IO) traffic. This often results in partials being sent too late to the pool (stale), which causes your partial to be rejected. The following bash script details how you could avoid this, by adapting the ioscheduler on a plots storage drive so that the farmer doesn't get late partials while the copy of a newly crafted plot is running.

#!/bin/bash
FS="<target drive mount point>"
DEVICE=`lsblk -ndo pkname $(findmnt -nro source $FS)`
echo $DEVICE

echo "bfq" > /sys/block/$DEVICE/queue/scheduler
echo 1 >/sys/block/$DEVICE/queue/iosched/strict_guarantees
echo 1500 >/sys/block/$DEVICE/queue/iosched/fifo_expire_sync
echo 20 >/sys/block/$DEVICE/queue/iosched/fifo_expire_async
echo 10 >/sys/block/$DEVICE/queue/iosched/timeout_sync
echo 50 >/sys/block/$DEVICE/queue/iosched/slice_idle

cat /sys/block/$DEVICE/queue/scheduler
cat /sys/block/$DEVICE/queue/iosched/strict_guarantees
cat /sys/block/$DEVICE/queue/iosched/fifo_expire_sync
cat /sys/block/$DEVICE/queue/iosched/fifo_expire_async
cat /sys/block/$DEVICE/queue/iosched/timeout_sync
cat /sys/block/$DEVICE/queue/iosched/slice_idle

These setting don't persist over a reboot.

Credits: @neurosis