Add a new mode to the scripted partition editor for variant disk names.

If the disk parameter "DEFAULT" is set in place of an actual device name,
or no disk is specified for the PARTITIONS parameter, the installer will
follow the logic used in the automatic-partitioning mode, in which it
will either provide a selection dialog for one of several disks if
several are present or automatically select it if there is only one. This
simplifies the creation of fully-automatic installation media for
hardware or VMs with varying disk names.

Suggested by:	Egoitz Aurrekoetxea <egoitz@sarenet.es>
MFC after:	3 weeks
Relnotes:	yes
This commit is contained in:
Nathan Whitehorn 2021-03-26 11:39:12 -04:00
parent f48c35fa1e
commit 5140034cc0
4 changed files with 27 additions and 11 deletions

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd March 22, 2021
.Dd March 26, 2021
.Dt BSDINSTALL 8
.Os
.Sh NAME
@ -158,7 +158,13 @@ Multiple disk setups are separated by semicolons.
The
.Ar disk
argument specifies the disk on which to operate (which will be erased),
while the
or the special value
.Em DEFAULT ,
which will result in either a selection window (as in
.Cm autopart )
for the destination disk or, if there is only one possible disk, will
automatically select it.
The
.Ar scheme
argument specifies the
.Xr gpart 8
@ -208,6 +214,10 @@ A shorter invocation to use the default partitioning (as
would have used) on the same disk:
.Pp
bsdinstall scriptedpart ada0
.Pp
or, even shorter:
.Pp
bsdinstall scriptedpart DEFAULT
.It Cm mount
Mounts the file systems previously configured by
.Cm autopart ,
@ -279,7 +289,9 @@ See
of
the
.Sx TARGETS
section for format details.
section for format details. If this variable is unset, the installer will
use the default partitioning as in
.Cm autopart .
Default: unset
.It Ev BSDINSTALL_DISTDIR
The directory in which the distribution files can be found (or to which they
@ -454,7 +466,7 @@ the interpreter for the setup script.
.Pp
A typical bsdinstall script looks like this:
.Bd -literal -offset indent
PARTITIONS=ada0
PARTITIONS=DEFAULT
DISTRIBUTIONS="kernel.txz base.txz"
#!/bin/sh

View File

@ -44,7 +44,6 @@
#define MIN_FREE_SPACE (1024*1024*1024) /* 1 GB */
#define SWAP_SIZE(available) MIN(available/20, 4*1024*1024*1024LL)
static char *boot_disk(struct gmesh *mesh);
static char *wizard_partition(struct gmesh *mesh, const char *disk);
int
@ -65,7 +64,7 @@ part_wizard(const char *fsreq)
dlg_put_backtitle();
error = geom_gettree(&mesh);
disk = boot_disk(&mesh);
disk = boot_disk_select(&mesh);
if (disk == NULL)
return (1);
@ -91,8 +90,8 @@ part_wizard(const char *fsreq)
return (0);
}
static char *
boot_disk(struct gmesh *mesh)
char *
boot_disk_select(struct gmesh *mesh)
{
struct gclass *classp;
struct gconfig *gc;

View File

@ -60,6 +60,7 @@ void delete_part_metadata(const char *name);
int part_wizard(const char *fstype);
int scripted_editor(int argc, const char **argv);
char *boot_disk_select(struct gmesh *mesh);
int wizard_makeparts(struct gmesh *mesh, const char *disk, const char *fstype,
int interactive);

View File

@ -183,10 +183,14 @@ int parse_disk_config(char *input)
}
} while (input != NULL && *input != 0);
if (disk != NULL)
return (part_config(disk, scheme, partconfig));
if (disk == NULL || strcmp(disk, "DEFAULT") == 0) {
struct gmesh mesh;
geom_gettree(&mesh);
disk = boot_disk_select(&mesh);
geom_deletetree(&mesh);
}
return (0);
return (part_config(disk, scheme, partconfig));
}
int