Luke A. Call writes:
> On 2022-10-26 11:57:23-0000, Stuart Henderson <[email protected]>
> wrote:
> > On 2022-10-24, Peter Fraser <[email protected]> wrote:
> > > I make a stupid mistake; I didn't check partition sizes before doing a
> > > sysupgrade.
> > > sysupgrade ran out of space or /usr in the middle of the upgrade.
> > > I know I should have checked first but it would be nice if sysupgrade did
> > > warn me.
> > > The site was a 20-minute drive away, and their down time was a lot longer
> > > then I expected.
> >
> > It would be nice, but it's tough to reliably test this without actually
> > extracting the files (and a warning with many false triggers wouldn't be
> > all that much use either ..)
>
> Thanks for that info, it is interesting.
>
> I'm just me, but would definitely prefer a warning that
> suggests a potential problem and says what to
"Might be too small" isn't very helpful without context. And where's
the unnecessary, complicated and fragile pipeline?
How about this:
# Find the length of the string encoding the size of the smallest
# physical partition (just using /usr and/or / would be boring):
smallest=$(df | awk '/^\// {print $2}' | sort -n | head -n1 | wc -c)
# Complain if it's too small:
if (( $smallest < 10 )); then
echo "Your storage is partitioned like it's the 20th century."
fi
For the real modern touch you can make the test abort unconditionally.
if (( $smallest < 10 )); then
echo "You should not be thinking about partitions."
echo "Aborting in case you hurt yourself."
exit 0 ## Return 0 because errors are scary.
fi
Matthew