BSDINSTALL(8) | MidnightBSD System Manager's Manual | BSDINSTALL(8) |
bsdinstall
—
system installer
bsdinstall |
[options] [target] [...] |
bsdinstall
is used for installation of new
systems, both for system setup from installation media, e.g., CD-ROMs, and
for use on live systems to prepare VM images and jails.
Much like
make(1),
bsdinstall
takes a target and possible parameters of
the target as arguments. If invoked with no arguments, it will invoke the
auto
target, which provides a standard interactive
installation, invoking the others in sequence. To perform a scripted
installation, these subtargets can be invoked separately by an installation
script.
bsdinstall
supports the following options,
global to all targets:
-D
fileBSDINSTALL_LOG
). See
ENVIRONMENT VARIABLES for
more information on BSDINSTALL_LOG
.Most of the following targets are only useful for scripting the
installer. For interactive use, most users will be interested only in the
auto
, jail
, and
script
targets.
auto
jail
destinationauto
, except that disk
partitioning and network setup are skipped and a kernel is not installed
into the new system.script
scriptkeymap
hostname
BSDINSTALL_CONFIGCURRENT
is set, also sets the
host name of the current system.netconfig
wlanconfig
on wireless interfaces), saving the
result to the new system's rc.conf and
resolv.conf. If
BSDINSTALL_CONFIGCURRENT
is set, also configures
the network interfaces of the current system to match.autopart
bootconfig
zfsboot
zpool
with separate datasets for
/tmp, /usr,
/usr/home, /usr/ports,
/usr/src, and /var.
Optionally can set up
geli(8) to encrypt the
disk.partedit
scriptedpart
parametersautopart
and
partedit
, but non-interactively according to the
disk setup specified in parameters. Each disk setup
is specified by a three-part argument:
disk [scheme] [{partitions}]
Multiple disk setups are separated by semicolons. The
disk argument specifies the disk on which to
operate (which will be erased), while the scheme
argument specifies the
gpart(8) partition
scheme to apply to the disk. If scheme is
unspecified, scriptedpart
will apply the default
bootable scheme on your platform. The partitions
argument is also optional and specifies how to partition
disk. It consists of a comma-separated list of
partitions to create enclosed in curly braces. Each partition
declaration takes the form
size type [mount point]
size specifies the partition size to create in bytes (K, M, and G suffixes can be appended to specify kilobytes, megabytes, and gigabytes respectively), while the auto keyword causes the partition to take all the remaining space on the disk. The type option chooses the gpart(8) filesystem type, e.g., mnbsd-ufs, mnbsd-zfs, or mnbsd-swap. The optional mount point argument sets where the created partition is to be mounted in the installed system. As an example, a typical invocation looks like:
bsdinstall scriptedpart ada0 { 20G mnbsd-ufs /, 4G mnbsd-swap, 20G mnbsd-ufs /var, auto mnbsd-ufs /usr }
A shorter invocation to use the default partitioning (as
autopart
would have used) on the same disk:
bsdinstall scriptedpart ada0
mount
autopart
, partedit
, or
scriptedpart
under
BSDINSTALL_CHROOT
.distfetch
DISTRIBUTIONS
to
BSDINSTALL_DISTDIR
from
BSDINSTALL_DISTSITE
.checksum
DISTRIBUTIONS
against the distribution
manifest.distextract
DISTRIBUTIONS
into BSDINSTALL_CHROOT
.rootpass
adduser
time
services
entropy
config
netconfig
, etc.) onto the new
system.The following environment variables control various aspects of the installation process. Many are used internally during installation and have reasonable default values for most installation scenarios. Others are set by various interactive user prompts, and can be usefully overridden when making scripted or customized installers.
DISTRIBUTIONS
PARTITIONS
scriptedpart
of the
TARGETS section for format details.
Default: unsetBSDINSTALL_DISTDIR
BSDINSTALL_DISTSITE
BSDINSTALL_DISTDIR
. This should be a full path to
the files, including architecture and release names. Most targets, e.g.,
auto
and jail
, that prompt
for a mirror will skip that step if this variable is already defined in
the environment. Example:
ftp://ftp.midnightbsd.org/pub/MidnightBSD/releases/i386/0.4-RELEASEBSDINSTALL_CHROOT
BSDINSTALL_LOG
BSDINSTALL_TMPETC
config
target is executed. If this directory does
not already exist, it will be created. Default:
“/tmp/bsdinstall_etc”BSDINSTALL_TMPBOOT
config
target is executed. If this directory does
not already exist, it will be created. Default:
“/tmp/bsdinstall_boot”ZFSBOOT_POOL_NAME
ZFSBOOT_POOL_CREATE_OPTIONS
zpool
. Default: “-O
compress=lz4 -O atime=off
”ZFSBOOT_BEROOT_NAME
ZFSBOOT_BOOTFS_NAME
ZFSBOOT_VDEV_TYPE
ZFSBOOT_FORCE_4K_SECTORS
ZFSBOOT_GELI_ENCRYPTION
ZFSBOOT_BOOT_POOL
variable. Default:
“”ZFSBOOT_GELI_KEY_FILE
ZFSBOOT_BOOT_POOL
ZFSBOOT_BOOT_POOL_CREATE_OPTIONS
ZFSBOOT_BOOT_POOL ).
Default: unsetZFSBOOT_BOOT_POOL_NAME
ZFSBOOT_BOOT_POOL ).
Default:
“bootpool”ZFSBOOT_BOOT_POOL_SIZE
ZFSBOOT_BOOT_POOL ).
Default:
“2g”ZFSBOOT_DISKS
ZFSBOOT_SWAP_SIZE
ZFSBOOT_SWAP_ENCRYPTION
ZFSBOOT_SWAP_MIRROR
ZFSBOOT_DATASETS
ZFSBOOT_CONFIRM_LAYOUT
bsdinstall
scripts consist of two parts: a
preamble
and a setup
script. The preamble sets up the options for the installation (how
to partition the disk[s], which distributions to install, etc.) and the
optional second part is a shell script run under
chroot(8) in the newly
installed system before bsdinstall
exits. The two
parts are separated by the usual script header (#!), which also sets the
interpreter for the setup script.
A typical bsdinstall script looks like this:
PARTITIONS=ada0 DISTRIBUTIONS="kernel.txz base.txz" #!/bin/sh gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0 sysrc ifconfig_em0=DHCP sysrc sshd_enable=YES pkg install puppet
For a ZFS scripted installation, the script looks like this:
DISTRIBUTIONS="kernel.txz base.txz" export ZFSBOOT_VDEV_TYPE=stripe export ZFSBOOT_DISKS=ada0 export nonInteractive="YES" #!/bin/sh echo "ifconfig_em0=DHCP" >> /etc/rc.conf echo "sshd_enable=YES" >> /etc/rc.conf pkg install puppet
On release media, such a script placed at /etc/installerconfig will be run at boot time and the system will be rebooted automatically after the installation has completed. This can be used for unattended network installation of new systems; see diskless(8) for details.
The preamble consists of installer settings. These control global
installation parameters (see
ENVIRONMENT VARIABLES) as
well as disk partitioning. The preamble is interpreted as a
sh(1) script run at the very
beginning of the install. If more complicated behavior than setting these
variables is desired, arbitrary commands can be run here to extend the
installer. In addition to the variables in
ENVIRONMENT VARIABLES, in
particular DISTRIBUTIONS
, the preamble can contain a
variable PARTITIONS
which is passed to the
scriptedpart
target to control disk setup.
Alternatively, to use zfsboot
instead of
partedit
, the preamble can contain the variable
ZFSBOOT_DATASETS
instead of
PARTITIONS
, and setting the variables
ZFSBOOT_DISKS
and
ZFSBOOT_VDEV_TYPE
to create the pool of disks for
the base system. Usually, for a mirrored booting disk, this two variables
looks like this:
ZFSBOOT_DISKS="ada0 ada1" ZFSBOOT_VDEV_TYPE=mirror
Remenber to export all the variables for the
zfsboot
command, otherwise it will not get set.
Following the preamble is an optional shell script, beginning with a #! declaration. This script will be run at the end of the installation process inside a chroot(8) environment in the newly installed system and can be used to set up configuration files, install packages, etc. Note that newly configured system services, e.g., networking have not been started in the installed system at this time and only installation host services are available.
The zfsboot
partitioning takes the
ZFSBOOT_DATASETS
variable to create the datasets on
the base system. This variable can get pretty huge if the pool contains a
lot of datasets. The default value of the
ZFSBOOT_DATASETS
looks like this:
# DATASET OPTIONS (comma or space separated; or both) # Boot Environment [BE] root and default boot dataset /$ZFSBOOT_BEROOT_NAME mountpoint=none /$ZFSBOOT_BEROOT_NAME/$ZFSBOOT_BOOTFS_NAME mountpoint=/ # Compress /tmp, allow exec but not setuid /tmp mountpoint=/tmp,exec=on,setuid=off # Do not mount /usr so that 'base' files go to the BEROOT /usr mountpoint=/usr,canmount=off # Home directories separated so they are common to all BEs /usr/home # NB: /home is a symlink to /usr/home # Ports tree /usr/ports setuid=off # Source tree (compressed) /usr/src # Create /var and friends /var mountpoint=/var,canmount=off /var/audit exec=off,setuid=off /var/crash exec=off,setuid=off /var/log exec=off,setuid=off /var/mail atime=on /var/tmp setuid=off
The first column if the dataset to be created on the top of the
ZFSBOOT_POOL_NAME
and the rest of the columns are
the options to be set on each dataset. The options must be written on a coma
or space separated list, or both. And everything behind a pound/hash
character is ignored as a comment.
This version of bsdinstall
first appeared
in FreeBSD 9.0.
Nathan Whitehorn <nwhitehorn@FreeBSD.org>
July 18, 2022 | midnightbsd-3.1 |