Re: git: 8664e266d6a4 - main - growfs(7): clarify assumptions and limitations

From: Mike Karels <mike_at_karels.net>
Date: Fri, 06 Jan 2023 05:42:22 UTC
On 5 Jan 2023, at 23:04, Eugene Grosbein wrote:

> 06.01.2023 7:44, Mike Karels wrote:
>
>> The branch main has been updated by karels:
>>
>> URL: https://cgit.FreeBSD.org/src/commit/?id=8664e266d6a4573d1875ee8f4ce0cdb091171780
>>
>> commit 8664e266d6a4573d1875ee8f4ce0cdb091171780
>> Author:     Mike Karels <karels@FreeBSD.org>
>> AuthorDate: 2023-01-05 13:15:21 +0000
>> Commit:     Mike Karels <karels@FreeBSD.org>
>> CommitDate: 2023-01-06 00:44:16 +0000
>>
>>     growfs(7): clarify assumptions and limitations
>>
>>     Document that the growfs(7) script works only if the root file system
>>     is in the last partition and free space immediately follows it.
>>     Don't imply that /usr can be a separate partition, as that would
>>     likely mean that root is not last.
>>
>>     Reported by:    marklmi at yahoo dot com
>
> Meantime, growfs(8) binary command living in /sbin successfully growfs root file system
> being NOT last, if there is following free space immediately after it.
>
> I use that feature occasionally dealing with installworld problem for systems installed
> long time ago (pre-date introduction of Clang in FreeBSD)
> when distinct root and /usr partitions sized 512MB were more than enough.
>
> For example:
>
> swap partition (b) 8GB
> root partition (a) 512MB
> /usr partition (d) 512MB
> others including /usr/local, /home etc...
>
> For major source based upgrade 512MB is not enough to hold new /usr contents,
> so I temporary destroy swap partition at the beginning and recreate it 1GB less to make hole
> that is used to create alternative 1GB sized partition temporary mounted as /mnt/usr.
> I dump|restore /usr to /mnt/usr, change /etc/fstab to mount new partition as /usr
> and not mount old one at all, and reboot. After that:
>
> swap partition (b) 7GB
> /usr partition (g) 1GB
> root partition (a) 512MB
> former /usr partition (d) 512MB
> others...
>
> Then I destroy partition (d) making free space immediately following root partition
> that is NOT last one. And growfs(8) works on mounted r/w root just fine.
> That worked every time I tried.
>
> I wonder why growfs(7) should have the limitation described in cited commit.

Growfs(7) is not really a general-purpose tool.  It is intended to expand
distributed images that are placed onto variable-sized media and booted, and
those images have a single file system and possibly a swap partition (which
comes first, so the root can be expanded).  The growfs(7) script does not
take a parameter for which file system to expand, so it would have to intuit
what you want.  Meanwhile, what you describe is reasonably straightforward
using gpart and growfs(8) (or zpool online -e).  The reason for describing the
limitations of the script is that questions like this one arose, and the man
page for growfs(7) documents usage separate from the /etc/rc.d system.  Rather
than trying to document usage of the full range of situations where the script
might work, I just documented the intended (and tested) use case.  In fact,
the script may well work in other cases where there is space after the root.

		Mike