diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2025-12-08 21:33:30 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2025-12-08 21:33:30 +0000 |
| commit | f63a8c0a0915a3eceac179d4d18b2c03b1319fa2 (patch) | |
| tree | 8d061bbf61cdeaa795fa3f308be80c5e5ee4da1f | |
| parent | 2cfd9fe87b90eddb9d0b3df3459d923092c491fb (diff) | |
bsdinstall: Mount /dev and /packages after using the shell to partition disks
Normally after partitions are created by the installer, the 'mount'
script is used to mount the target disk partitions under /mnt. The
tail end of this script also mounts a couple of additional filesystems
under /mnt so that chrooted programs can work such as devfs and
/packages.
When the "Shell" option is used to permit the user to manually mount
the destination filesystem, the "mount" script is not used as the user
is instructed to mount the target filesystems and construct
/mnt/etc/fstab, etc. However, this means that the user is responsible
for mounting devfs (which is not included in /etc/fstab) and /packages
as well. The help message for the "Shell" option doesn't mention
these requirements, so users may not know to do so. This can lead to
confusing errors as chrooted commands can fail to find needed /dev
entries. For example, running fwget to fetch wireless firmware fails
because /dev/pci doesn't exist.
To make this less painful for users using this option, split out the
bottom half of the 'mount' script that mounts these non-fstab-related
filesystems into a separate 'mount_aux' script. Invoke 'mount_aux'
after using "Shell" to create the filesystem to ensure that these
filesystems are always present.
PR: 290901
Reported by: Peter <freebsd@peterk.org>
Tested by: Peter <freebsd@peterk.org>
Differential Revision: https://reviews.freebsd.org/D53770
| -rw-r--r-- | tools/build/mk/OptionalObsoleteFiles.inc | 1 | ||||
| -rw-r--r-- | usr.sbin/bsdinstall/scripts/Makefile | 1 | ||||
| -rwxr-xr-x | usr.sbin/bsdinstall/scripts/auto | 1 | ||||
| -rwxr-xr-x | usr.sbin/bsdinstall/scripts/mount | 10 | ||||
| -rwxr-xr-x | usr.sbin/bsdinstall/scripts/mount_aux | 39 |
5 files changed, 43 insertions, 9 deletions
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index e0bc47492f7d..0551074f0bce 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -434,6 +434,7 @@ OLD_FILES+=usr/libexec/bsdinstall/jail OLD_FILES+=usr/libexec/bsdinstall/keymap OLD_FILES+=usr/libexec/bsdinstall/mirrorselect OLD_FILES+=usr/libexec/bsdinstall/mount +OLD_FILES+=usr/libexec/bsdinstall/mount_aux OLD_FILES+=usr/libexec/bsdinstall/netconfig OLD_FILES+=usr/libexec/bsdinstall/netconfig_ipv4 OLD_FILES+=usr/libexec/bsdinstall/netconfig_ipv6 diff --git a/usr.sbin/bsdinstall/scripts/Makefile b/usr.sbin/bsdinstall/scripts/Makefile index 4fd59e49d506..92a455d8e9e3 100644 --- a/usr.sbin/bsdinstall/scripts/Makefile +++ b/usr.sbin/bsdinstall/scripts/Makefile @@ -16,6 +16,7 @@ SCRIPTS=auto \ keymap \ mirrorselect \ mount \ + mount_aux \ netconfig \ netconfig_ipv4 \ netconfig_ipv6 \ diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto index 5fefc07e4c07..2204b33ae105 100755 --- a/usr.sbin/bsdinstall/scripts/auto +++ b/usr.sbin/bsdinstall/scripts/auto @@ -405,6 +405,7 @@ case "$PARTMODE" in clear echo "Use this shell to set up partitions for the new system. When finished, mount the system at $BSDINSTALL_CHROOT and place an fstab file for the new system at $PATH_FSTAB. Then type 'exit'. You can also enter the partition editor at any time by entering 'bsdinstall partedit'." sh 2>&1 + bsdinstall mount_aux || error "Failed to mount auxiliary filesystems" ;; "$msg_manual") # Manual if f_isset debugFile; then diff --git a/usr.sbin/bsdinstall/scripts/mount b/usr.sbin/bsdinstall/scripts/mount index fd13e13c6a77..a432ccd5dfe5 100755 --- a/usr.sbin/bsdinstall/scripts/mount +++ b/usr.sbin/bsdinstall/scripts/mount @@ -52,12 +52,4 @@ for i in $FILESYSTEMS; do fi done -# User might want a shell and require devfs, so mount it -mkdir $BSDINSTALL_CHROOT/dev 2>/dev/null -mount -t devfs devfs $BSDINSTALL_CHROOT/dev - -# If installing from the DVD, mount packages where they'll be accessible -if [ -d /packages ]; then - mkdir -p $BSDINSTALL_CHROOT/dist/packages - mount -t nullfs /packages $BSDINSTALL_CHROOT/dist/packages -fi +bsdinstall mount_aux diff --git a/usr.sbin/bsdinstall/scripts/mount_aux b/usr.sbin/bsdinstall/scripts/mount_aux new file mode 100755 index 000000000000..21def9b6e8c0 --- /dev/null +++ b/usr.sbin/bsdinstall/scripts/mount_aux @@ -0,0 +1,39 @@ +#!/bin/sh +#- +# Copyright (c) 2011 Nathan Whitehorn +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +BSDCFG_SHARE="/usr/share/bsdconfig" +. $BSDCFG_SHARE/common.subr || exit 1 + +# User might want a shell and require devfs, so mount it +mkdir $BSDINSTALL_CHROOT/dev 2>/dev/null +mount -t devfs devfs $BSDINSTALL_CHROOT/dev + +# If installing from the DVD, mount packages where they'll be accessible +if [ -d /packages ]; then + mkdir -p $BSDINSTALL_CHROOT/dist/packages + mount -t nullfs /packages $BSDINSTALL_CHROOT/dist/packages +fi |
