Commit Graph

120 Commits

Author SHA1 Message Date
Warner Losh
fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh
d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh
b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
John Baldwin
2309909919 bsdinstall: Handle errors from geom_gettree.
geom_gettree probably never fails, and if it does there isn't much of
a fallback other than aborting partitioning.  However, a few places
were checking the return value and not doing anything with it
triggering a unused-but-set-variable warning.  Checking the errors
resolves the warning.

While here, check for errors in other places that weren't checking for
them at all, remove a spurious double call (the second call overwrote
the mesh structure leaking all the pointers from the first), and close
a few resource leaks on error paths.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D40779
2023-06-28 11:11:00 -07:00
John Baldwin
f66a8328c3 bsdinstall: Replace correct, but fragile, string builder with open_memstream.
The old one triggered a false positive -Warray-bounds from GCC (the
compiler assumed len was always 0), but it was also fragile with
manually computed lengths paired with strcat vs using a string
builder.

Differential Revision:	https://reviews.freebsd.org/D40658
2023-06-27 10:19:32 -07:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Simon J. Gerraty
0c3627f44d bsdinstall avoid subdir depending on parent
When not doing tree walks, it is bad for sub-dirs to depend on
parents.  Move the generation of opt_osname.h to distextract
and have others that need that depend on it.

In usr.sbin/bsdinstall use SUBDIR_DEPEND_ so tree walking still works.

Reviewed by:	obrien
Differential Revision:	https://reviews.freebsd.org/D39742
2023-04-20 22:00:40 -07:00
Simon J. Gerraty
d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Brad Davis
147585b489 bsdinstall: allow whitelabeling the installer
Override OSNAME to change the name of the OS in the installer.

This is a first step, the shell changes will be separate.

Reviewed by:		allanjude
Approved by:		allanjude
Differential Revision:	https://reviews.freebsd.org/D34878
Sponsored by:		Rubicon Communications, LLC ("Netgate")
2022-05-13 10:35:43 -06:00
Brad Davis
2c4499dcd7 bsdinstall: add missing init of fd variable
Missed breaking this commit into smaller pieces

Approved by:		kp
2022-05-13 09:06:02 -06:00
Brad Davis
964ad27f1e bsdinstall: Filter out devices that cannot be opened
Devices that cannot be opened are most likely the install media and
should not be listed as destinations.

Reviewed by:		allanjude
Approved by:		allanjude
Differential Revision:	https://reviews.freebsd.org/D34879
Sponsored by:		Rubicon Communications, LLC ("Netgate")
2022-05-13 08:33:21 -06:00
Alfonso S. Siciliano
9b4c606b96
bsdinstall/partedit: Fix UFS auto partitioning
Fix bsdinstall "Auto (UFS) Guided Disk Setup" and sade(8) "Auto".
The problem is a string comparison failure, it arose during the
dialog(3)/bsddialog(3) form conversion:

 * dialog uses only form.text while bsdialog differentiates between
   form.init and form.value.
 * dialog always allocates memory for form values while bsddialog only
   when a button is pressed.

Reviewed by:		bapt
Differential Revision:	https://reviews.freebsd.org/D35033
2022-04-30 01:24:23 +02:00
Alfonso S. Siciliano
50e244964e
bsdinstall/partedit: Replace libdialog with libbsddialog
bsdinstall/partedit: Replace (LGPL) libdialog with (BSD-2-Clause)
libbsddialog. Rewrite diskeditor.c and rename diskmenu.c because
it uses an API for menu totally incompatible with libbsddialog.
This is a User Interface change everything else is unchanged.

Approved by:		bapt (mentor)
Differential Revision:	https://reviews.freebsd.org/D34639
2022-04-04 02:05:00 +02:00
Alexander Motin
2117cdd4b4 GEOM: Introduce gctl_add_param() API.
Make gctl_add_param() API public, allowing more precise control over
parameter flags.  Previously it was impossible to properly declare
write-only ASCII parameters, used for result reporting, they were
declared as read-write binary instead, that was not nice.

MFC after:	1 month
2022-03-07 11:12:25 -05:00
Baptiste Daroussin
7d51283f70 partedit: cleanup headers
Removed dialog.h where not needed and include headers actually used
2021-11-24 12:06:34 +01:00
Ed Maste
3e5bff102b bsdinstall: Remove unused sysctl.h header #include 2021-08-07 20:30:29 -04:00
Ryan Moeller
b07b7aec65 bsdinstall: Drop vestigial bsdinstall-esps cleanup
This is not needed after 0b7472b3d8.

MFC after:	3 days
Sponsored by:	iXsystems, Inc.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D29325
2021-03-26 14:12:18 -04:00
Nathan Whitehorn
5140034cc0 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
2021-03-26 11:43:47 -04:00
Nathan Whitehorn
c2f16c595e Fix scripted installs on EFI systems after default mounting of the ESP.
Because the ESP mount point (/boot/efi) is in mtree, tar will attempt to
extract a directory at that point post-mount when the system is installed.
Normally, this is fine, since tar can happily set whatever properties it
wants. For FAT32 file systems, however, like the ESP, tar will attempt to
set mtime on the root directory, which FAT does not support, and tar will
interpret this as a fatal error, breaking the install (see
https://github.com/libarchive/libarchive/issues/1516). This issue would
also break scripted installs on bare-metal POWER8, POWER9, and PS3
systems, as well as some ARM systems.

This patch solves the problem in two ways:
- If stdout is a TTY, use the distextract stage instead of tar, as in
  interactive installs. distextract solves this problem internally and
  provides a nicer UI to boot, but requires a TTY.
- If stdout is not a TTY, use tar but, as a stopgap for 13.0, exclude
  boot/efi from tarball extraction and then add it by hand. This is a
  hack, and better solutions (as in the libarchive ticket above) will
  obsolete it, but it solves the most common case, leaving only
  unattended TTY-less installs on a few tier-2 platforms broken.

In addition, fix a bug with fstab generation uncovered once the tar issue
is fixed that umount(8) can depend on the ordering of lines in fstab in a
way that mount(8) does not. The partition editor now writes out fstab in
mount order, making sure umount (run at the end of scripted, but not
interactive, installs) succeeds.

PR:		254395
Reviewed by:	gjb, imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D29380
2021-03-23 09:29:54 -04:00
Nathan Whitehorn
0b7472b3d8 Mount the EFI system partition (ESP) on newly-installed systems.
Per hier(7), the ESP will be mounted at /boot/efi. On UFS systems,
any existing ESP will be reused and mounted there; otherwise, a new one
will be made. On ZFS systems, space for an ESP is allocated on all disks
in the root pool, but only the partition actually used to boot is set up
and mounted.

This makes future upgrades of the EFI loader easier (upgrade scripts can
just change /boot/efi) and also greatly simplifies the parts of the
installer involved in initialization of the ESP. It also makes the
installer's behavior correspond to the documentation in hier(7).

Reviewed by:		imp, tsoome
MFC after:		1 week
Relnotes:		yes
Differential Revision:	https://reviews.freebsd.org/D28897
2021-02-23 16:24:21 -05:00
Mitchell Horne
7b08a307e8 bsdinstall: riscv-specific tweaks
Make the installer more useful, by allowing it to create a bootable
installation. Also, enable the menu option for ZFS-on-root.

Like arm64, RISC-V boots by UEFI only, so arm64's partedit
implementation is renamed and shared among the two platforms.

Reviewed by:	gjb
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D28180
2021-01-27 19:29:42 -04:00
Mitchell Horne
10720ae4db bsdinstall: remove VTOC8 partition scheme option
Now that sparc64 has been removed, there are no kernels built with
support for the VTOC8 partitioning scheme by default. Remove the option
from the installer, as it is unsupported on all installer images
produced by re@.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D27641
2020-12-17 15:00:19 +00:00
Yoshihiro Takahashi
8f11c99715 - Cleanups related to sparc64 removal.
- Remove remains of sparc64 files.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D25831
2020-07-28 10:58:37 +00:00
Ben Woods
2d482628aa Fix regression in bsdinstall post r356740 - partedit errno(2) 21 EISDIR
This resulted in the partitioning step failing if either of the
"Auto (UFS)" or "Manual" options were selected.

Reason: partedit was attempting to open a directory (TMPDIR) read/write,
which resulted in errno(2) 21 - EISDIR - Is a directory.

Reported by:	Clay Daniels <clay.daniels.jr@gmail.com>
Reviewed by:	Ryan Moeller <ryan@freqlabs.com>
Approved by:	emaste, bcran
Differential Revision:	https://reviews.freebsd.org/D23232
2020-01-17 22:26:41 +00:00
Rebecca Cran
a107ddbb83 bsdinstall: Use TMPDIR if set
Submitted by:	Ryan Moeller <ryan@freqlabs.com>
Reviewed by:	bcran, Nick Wolff <darkfiberiru@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D22979/
2020-01-15 00:45:05 +00:00
Justin Hibbits
bc4d122db0 powerpc/boot: Move ubldr to /boot/uboot, and make this a separate filesystem
Summary:
Now that mpc85xx can boot via ubldr, move ubldr to a separate
filesystem, mounted on /boot/uboot, so that a fresh install can boot correctly.

Reviewed By: nwhitehorn
Differential Revision: https://reviews.freebsd.org/D18709
2019-02-18 01:57:47 +00:00
Rebecca Cran
db8b561345 Rework UEFI ESP generation
Currently, the installer uses pre-created 800KB FAT12 filesystems that
it dd's onto the ESP partition.
This changeset improves that by having the installer generate a FAT32
filesystem directly onto the ESP using newfs_msdos and then copying
loader.efi into /EFI/freebsd.
For live installs it then runs efibootmgr to add a FreeBSD boot entry
in the BIOS.

Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D17947
2018-12-20 19:39:37 +00:00
Justin Hibbits
60f18ad0b4 Add partition scheme for mpc85xx devices
Some mpc85xx devices with u-boot need MBR partitioning with a FAT boot
partition.  Since the infrastructure is already in place to have a dedicated
boot partition, this adds the necessary bits to use that infrastructure with
mpc85xx boards.

Reviewed By: nwhitehorn
Differential Revision: https://reviews.freebsd.org/D15664
2018-06-07 00:24:10 +00:00
Nathan Whitehorn
8c7de243f4 Fix math error in the computation of the free space after the last partition
on a disk. This resulted in one sector always remaining free at the end.

PR:		bin/228322
Submitted by:	Rikiya Yonemoto
MFC after:	2 weeks
2018-05-18 17:43:15 +00:00
Ed Maste
4a8b3e41f5 bsdinstall: enable SUJ by default (revert r327890)
fsck should be fixed as of r328092.

PR:		225110
Tested by:	dumbbell, Arshan Khanifar <arshankhanifar gmail.com>
2018-01-25 19:57:21 +00:00
Ed Maste
643139e5b1 bsdinstall: disable SUJ by default
SUJ + cg checksums produce spurious warnings after an unclean shutdown
(e.g. a crash).  For now disable SUJ for UFS installs so installing from
a FreeBSD 12 snapshot results in a usable filesystem, until this can be
fixed.

PR:		225110
Submitted by:	Arshan Khanifar <arshankhanifar gmail.com>
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D13890
2018-01-12 20:25:57 +00:00
Nathan Whitehorn
8befcf7be1 Add installer support for PS3 and PowerNV systems, also laying the
foundation for invoking efibootmgr as part of new-style EFI booting on
x86. On PS3 and PowerNV, which are booted using Linux kexec from petitboot
rather than by loader(8), install the kernel and the rest of /boot to a
FAT partition and set up the appropriate petitboot configuration file
there.

The new bootconfig installer stage can do platform-dependent modifications
more complex than partition layout and installation of boot blocks and can
be used to (as here) set up some special configuration files, run efibootmgr,
or boot0cfg.

MFC after:	1 month
2018-01-02 05:27:24 +00:00
Nathan Whitehorn
9f7602f019 Teach bsdinstall partedit/sade how to format FAT partitions on GPT, which
have the partition type code "ms-basic-data".

MFC after:	2 weeks
2017-12-31 03:13:45 +00:00
Nathan Whitehorn
6134b18696 Fix bug introduced in r326674, in which efi boot partitions created by
the installer but not mounted (i.e. with boot1.efifat dd'ed to them
rather than the forthcoming proper filesystem) would get newfs_msdos run
on them immediately after the boot code was copied. This would overwrite
the bootstrap code, causing the EFI system partition to be blanked and
resulting in an unbootable system.

PR:		224562
2017-12-28 01:21:30 +00:00
Nathan Whitehorn
52f39da1f8 Support mounted boot partitions in the installer. This allows the platform
layer, for example, to specify that the EFI boot partition should be
mounted at /efi and formatted normally with newfs_msdos rather than
splatted to from /boot/boot1.efifat.

This commit adds only the API for this; actual platform use will come later.
2017-12-08 00:57:13 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Ravi Pokala
40f0d8dc4a When doing a non-interactive installation, don't display an interactive
warning about a filesystem which doesn't have a mountpoint. Presumably, the
person who wrote the install script knew what they were doing.

Submitted by:	Brian Mueller <bmueller@panasas.com>
MFC after:	1 month
Sponsored by:	Panasas
Differential Revision:	https://reviews.freebsd.org/D12346
2017-09-12 22:19:21 +00:00
Ed Maste
c0fcb86aee bsdinstall: correct comment after r320007
Submitted by:	vangyzen
2017-06-16 19:26:33 +00:00
Ed Maste
4ca43ae5f2 bsdinstall: use consistent EFI configuration across platforms
- increase arm64 EFI partition to 200M, as x86
- use EFI_BOOTPART_SIZE and EFI_BOOTPART_PATH macros on x86
- increase ZFS EFI partition to 200M

PR:		201898
Reviewed by:	allanjude, manu
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D11239
2017-06-16 18:58:48 +00:00
Enji Cooper
ab9ff47abc sade(8): start new sentence on new line
Reported by:	make manlint
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 07:50:42 +00:00
Enji Cooper
d6f6b20128 style(9): sort headers
MFC after:	2 weeks
MFC with:	r318693
Sponsored by:	Dell EMC Isilon
2017-05-23 06:05:54 +00:00
Enji Cooper
d547c56fdf Some minor style(9) fixes
- Wrap at <80 columns.
- Sort by type

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-23 06:04:38 +00:00
Marcelo Araujo
63128851f3 Use nitems() from sys/param.h.
Reviewed by:	ngie
MFC after:	2 weeks.
Differential Revision:	https://reviews.freebsd.org/D9942
2017-05-03 14:03:46 +00:00
Conrad Meyer
6c546e77b6 bsdinstall(8): Sprinkle a snprintf to fixed size buffer
Use a snprintf to write an environment variable to a fixed-size buffer to
avoid stack overflow.

Reported by:	Coverity (CWE-120)
CID:		1238926
Sponsored by:	Dell EMC Isilon
2017-04-14 00:36:45 +00:00
Rodney W. Grimes
ce9f2d31b3 Convert absolute links to relative links.
Style.Makefile(9) has been ignored to produce minimal diffs.

Approved by:	grehan (mentor)
MFC after:	1 week
2017-03-07 05:10:38 +00:00
Ravi Pokala
0ee82391df Fix indentation (only line in file w/ 8-space indent rather than hard-tab).
MFH:		1 week
2017-02-08 00:02:54 +00:00
Yoshihiro Takahashi
2b375b4edd Remove pc98 support completely.
I thank all developers and contributors for pc98.

Relnotes:	yes
2017-01-28 02:22:15 +00:00
Wojciech Macek
e24e98d090 bsdinstall: add warning when unsupported partition is modified
Right now is possible to modify bootable partition type to
non-bootable type without getting warning from partedit.
Example: if you auto parition drive for arm64, you will
get freebsd-ufs as bootable partition; now you are able
to change bootable partition type to freebsd-zfs; there
will be no warning and the system will install but
will not be bootable afterwards.

After this fix, partedit will issue the same warning it
does when user attempts to create bootable partition of
not supported type, notyfing a user about incoming
problem and allowing to think the decision over before
commiting the schema.

This has been tested on amd64 and arm64.

Obtained from:         Semihalf
Submitted by:          Dominik Ermel <der@semihalf.com>
Sponsored by:          Cavium
Reviewed by:           nwhitehorn
Differential Revision: https://reviews.freebsd.org/D6879
2016-09-05 08:42:36 +00:00
Dag-Erling Smørgrav
47ead00d5b Ensure that the sector size is a multiple of 4096 to avoid creating
unaligned partitions when the actual sector size is hidden from us.

PR:		211361
MFC after:	3 days
2016-08-15 09:30:21 +00:00