-.\" $OpenBSD: installboot.8,v 1.5 2021/07/20 14:51:56 kettenis Exp $
+.\" $OpenBSD: installboot.8,v 1.6 2022/08/19 08:27:48 kn Exp $
.\"
.\" Copyright (c) 2013, 2014 Joel Sing
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: July 20 2021 $
+.Dd $Mdocdate: August 19 2022 $
.Dt INSTALLBOOT 8
.Os
.Sh NAME
.Nd install bootstrap on a disk
.Sh SYNOPSIS
.Nm installboot
-.Op Fl npv
+.Op Fl nv
.Op Fl r Ar root
.Ar disk
.Op Ar stage1 Op Ar stage2
+.Nm
+.Op Fl nv
+.Fl p
+.Ar disk
.Sh DESCRIPTION
.Nm
installs bootstrap on the specified disk.
The options are as follows:
.Bl -tag -width Ds
.It Fl n
-Perform a dry run - do not actually write any bootstrap to the disk.
+Perform a dry run - do not actually write to the disk.
.It Fl p
Prepare filesystem.
This will create a new filesystem on the partition reserved for the
-/* $OpenBSD: installboot.c,v 1.14 2021/07/20 14:51:56 kettenis Exp $ */
+/* $OpenBSD: installboot.c,v 1.15 2022/08/19 08:27:48 kn Exp $ */
/*
* Copyright (c) 2012, 2013 Joel Sing <jsing@openbsd.org>
int stages;
int verbose;
-char *root = "/";
+char *root;
char *stage1;
char *stage2;
static __dead void
usage(void)
{
- extern char *__progname;
-
- fprintf(stderr, "usage: %s [-npv] [-r root] disk [stage1%s]\n",
- __progname, (stages >= 2) ? " [stage2]" : "");
+ fprintf(stderr, "usage:\t%1$s [-nv] [-r root] disk [stage1%2$s]\n"
+ "\t%1$s [-nv] -p disk\n",
+ getprogname(), (stages >= 2) ? " [stage2]" : "");
exit(1);
}
prepare = 1;
break;
case 'r':
- root = strdup(optarg);
- if (root == NULL)
- err(1, "strdup");
+ root = optarg;
break;
case 'v':
verbose = 1;
if (argc < 1 || argc > stages + 1)
usage();
+ if (prepare && (root != NULL || argc > 1))
+ usage();
dev = argv[0];
if (argc > 1)
if (argc > 2)
stage2 = argv[2];
+ if ((devfd = opendev(dev, (nowrite ? O_RDONLY : O_RDWR), OPENDEV_PART,
+ &realdev)) == -1)
+ err(1, "open: %s", realdev);
+
+ if (prepare) {
+ md_prepareboot(devfd, realdev);
+ return 0;
+ }
+
/* Prefix stages with root, unless they were user supplied. */
+ if (root == NULL)
+ root = "/";
if (verbose)
fprintf(stderr, "Using %s as root\n", root);
if (argc <= 1 && stage1 != NULL) {
exit(1);
}
- if ((devfd = opendev(dev, (nowrite ? O_RDONLY : O_RDWR), OPENDEV_PART,
- &realdev)) == -1)
- err(1, "open: %s", realdev);
-
if (verbose) {
fprintf(stderr, "%s bootstrap on %s\n",
(nowrite ? "would install" : "installing"), realdev);
md_loadboot();
- if (prepare) {
- md_prepareboot(devfd, realdev);
- return 0;
- }
-
#ifdef SOFTRAID
sr_installboot(devfd, dev);
#else