summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdinstall
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
committersjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
commit65145fa4c81da358fcbc3b650156dab705dfa34e (patch)
tree55c065b6730aaac2afb6c29933ee6ec5fa4c4249 /usr.sbin/bsdinstall
parent60ff4eb0dff94a04d75d0d52a3957aaaf5f8c693 (diff)
parente6b664c390af88d4a87208bc042ce503da664c3b (diff)
downloadFreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.zip
FreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.tar.gz
Merge sync of head
Diffstat (limited to 'usr.sbin/bsdinstall')
-rw-r--r--usr.sbin/bsdinstall/bsdinstall.84
-rw-r--r--usr.sbin/bsdinstall/distextract/Makefile3
-rw-r--r--usr.sbin/bsdinstall/distextract/Makefile.depend4
-rw-r--r--usr.sbin/bsdinstall/distextract/distextract.c175
-rw-r--r--usr.sbin/bsdinstall/distfetch/Makefile3
-rw-r--r--usr.sbin/bsdinstall/partedit/Makefile3
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_x86.c5
-rwxr-xr-xusr.sbin/bsdinstall/scripts/docsinstall5
-rwxr-xr-xusr.sbin/bsdinstall/scripts/zfsboot200
9 files changed, 205 insertions, 197 deletions
diff --git a/usr.sbin/bsdinstall/bsdinstall.8 b/usr.sbin/bsdinstall/bsdinstall.8
index f3d06fa..a08eff9 100644
--- a/usr.sbin/bsdinstall/bsdinstall.8
+++ b/usr.sbin/bsdinstall/bsdinstall.8
@@ -129,7 +129,7 @@ with separate datasets for
and
.Pa /var .
Optionally can set up
-.Xr geli 8
+.Xr geli 8
to encrypt the disk.
.It Cm partedit
Provides the installer's interactive manual disk partitioner with an interface
@@ -354,7 +354,7 @@ instead of
.Cm partedit ,
the preamble can contain the variable
.Ev ZFSBOOT_DATASETS
-instead of
+instead of
.Ev PARTITIONS .
.Ss SETUP SCRIPT
Following the preamble is an optional shell script, beginning with a #!
diff --git a/usr.sbin/bsdinstall/distextract/Makefile b/usr.sbin/bsdinstall/distextract/Makefile
index f84c4d7..313ec00 100644
--- a/usr.sbin/bsdinstall/distextract/Makefile
+++ b/usr.sbin/bsdinstall/distextract/Makefile
@@ -2,8 +2,7 @@
BINDIR= /usr/libexec/bsdinstall
PROG= distextract
-DPADD= ${LIBARCHIVE} ${LIBNCURSESW} ${LIBDIALOG} ${LIBM}
-LDADD= -larchive -lncursesw -ldialog -lm
+LIBADD= archive dpv figpar ncursesw dialog m
WARNS?= 6
MAN=
diff --git a/usr.sbin/bsdinstall/distextract/Makefile.depend b/usr.sbin/bsdinstall/distextract/Makefile.depend
index 2a012b9..3d6ca5a 100644
--- a/usr.sbin/bsdinstall/distextract/Makefile.depend
+++ b/usr.sbin/bsdinstall/distextract/Makefile.depend
@@ -13,8 +13,12 @@ DIRDEPS = \
lib/libbz2 \
lib/libc \
lib/libcompiler_rt \
+ lib/libdpv \
lib/libexpat \
+ lib/libfigpar \
lib/liblzma \
+ lib/libthr \
+ lib/libutil \
lib/libz \
lib/msun \
lib/ncurses/ncursesw \
diff --git a/usr.sbin/bsdinstall/distextract/distextract.c b/usr.sbin/bsdinstall/distextract/distextract.c
index 54e0171..94536bc 100644
--- a/usr.sbin/bsdinstall/distextract/distextract.c
+++ b/usr.sbin/bsdinstall/distextract/distextract.c
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <archive.h>
#include <ctype.h>
#include <dialog.h>
+#include <dpv.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
@@ -42,17 +43,13 @@ __FBSDID("$FreeBSD$");
/* Data to process */
static char *distdir = NULL;
-struct file_node {
- char *path;
- char *name;
- int length;
- struct file_node *next;
-};
-static struct file_node *dists = NULL;
+static struct archive *archive = NULL;
+static struct dpv_file_node *dists = NULL;
/* Function prototypes */
+static void sig_int(int sig);
static int count_files(const char *file);
-static int extract_files(int nfiles, struct file_node *files);
+static int extract_files(struct dpv_file_node *file, int out);
#if __FreeBSD_version <= 1000008 /* r232154: bump for libarchive update */
#define archive_read_support_filter_all(x) \
@@ -66,11 +63,17 @@ main(void)
{
char *chrootdir;
char *distributions;
- int ndists = 0;
int retval;
- size_t file_node_size = sizeof(struct file_node);
+ size_t config_size = sizeof(struct dpv_config);
+ size_t file_node_size = sizeof(struct dpv_file_node);
size_t span;
- struct file_node *dist = dists;
+ struct dpv_config *config;
+ struct dpv_file_node *dist = dists;
+ static char backtitle[] = "FreeBSD Installer";
+ static char title[] = "Archive Extraction";
+ static char aprompt[] = "\n Overall Progress:";
+ static char pprompt[] = "Extracting distribution files...\n";
+ struct sigaction act;
char error[PATH_MAX + 512];
if ((distributions = getenv("DISTRIBUTIONS")) == NULL)
@@ -80,14 +83,14 @@ main(void)
/* Initialize dialog(3) */
init_dialog(stdin, stdout);
- dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer");
+ dialog_vars.backtitle = backtitle;
dlg_put_backtitle();
dialog_msgbox("",
"Checking distribution archives.\nPlease wait...", 4, 35, FALSE);
/*
- * Parse $DISTRIBUTIONS into linked-list
+ * Parse $DISTRIBUTIONS into dpv(3) linked-list
*/
while (*distributions != '\0') {
span = strcspn(distributions, "\t\n\v\f\r ");
@@ -95,7 +98,6 @@ main(void)
distributions++;
continue;
}
- ndists++;
/* Allocate a new struct for the distribution */
if (dist == NULL) {
@@ -141,10 +143,30 @@ main(void)
return (EXIT_FAILURE);
}
- retval = extract_files(ndists, dists);
+ /* Set cleanup routine for Ctrl-C action */
+ act.sa_handler = sig_int;
+ sigaction(SIGINT, &act, 0);
+ /*
+ * Hand off to dpv(3)
+ */
+ if ((config = calloc(1, config_size)) == NULL)
+ _errx(EXIT_FAILURE, "Out of memory!");
+ config->backtitle = backtitle;
+ config->title = title;
+ config->pprompt = pprompt;
+ config->aprompt = aprompt;
+ config->options |= DPV_WIDE_MODE;
+ config->label_size = -1;
+ config->action = extract_files;
+ config->status_solo =
+ "%10lli files read @ %'9.1f files/sec.";
+ config->status_many =
+ "%10lli files read @ %'9.1f files/sec. [%i/%i busy/wait]";
end_dialog();
+ retval = dpv(config, dists);
+ dpv_free();
while ((dist = dists) != NULL) {
dists = dist->next;
if (dist->path != NULL)
@@ -155,6 +177,12 @@ main(void)
return (retval);
}
+static void
+sig_int(int sig __unused)
+{
+ dpv_interrupt = TRUE;
+}
+
/*
* Returns number of files in archive file. Parses $BSDINSTALL_DISTDIR/MANIFEST
* if it exists, otherwise uses archive(3) to read the archive file.
@@ -167,7 +195,6 @@ count_files(const char *file)
int file_count;
int retval;
size_t span;
- struct archive *archive;
struct archive_entry *entry;
char line[512];
char path[PATH_MAX];
@@ -220,6 +247,7 @@ count_files(const char *file)
"Error while extracting %s: %s\n", file,
archive_error_string(archive));
dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
+ archive = NULL;
return (-1);
}
@@ -227,49 +255,27 @@ count_files(const char *file)
while (archive_read_next_header(archive, &entry) == ARCHIVE_OK)
file_count++;
archive_read_free(archive);
+ archive = NULL;
return (file_count);
}
static int
-extract_files(int nfiles, struct file_node *files)
+extract_files(struct dpv_file_node *file, int out __unused)
{
- int archive_file;
- int archive_files[nfiles];
- int current_files = 0;
- int i;
- int last_progress;
- int progress = 0;
int retval;
- int total_files = 0;
- struct archive *archive;
struct archive_entry *entry;
- struct file_node *file;
- char status[8];
- static char title[] = "Archive Extraction";
- static char pprompt[] = "Extracting distribution files...\n";
char path[PATH_MAX];
char errormsg[PATH_MAX + 512];
- const char *items[nfiles*2];
- /* Make the transfer list for dialog */
- i = 0;
- for (file = files; file != NULL; file = file->next) {
- items[i*2] = file->name;
- items[i*2 + 1] = "Pending";
- archive_files[i] = file->length;
-
- total_files += file->length;
- i++;
- }
-
- i = 0;
- for (file = files; file != NULL; file = file->next) {
+ /* Open the archive if necessary */
+ if (archive == NULL) {
if ((archive = archive_read_new()) == NULL) {
snprintf(errormsg, sizeof(errormsg),
"Error: %s\n", archive_error_string(NULL));
dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
- return (EXIT_FAILURE);
+ dpv_abort = 1;
+ return (-1);
}
archive_read_support_format_all(archive);
archive_read_support_filter_all(archive);
@@ -280,59 +286,44 @@ extract_files(int nfiles, struct file_node *files)
"Error opening %s: %s\n", file->name,
archive_error_string(archive));
dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
- return (EXIT_FAILURE);
+ file->status = DPV_STATUS_FAILED;
+ dpv_abort = 1;
+ return (-1);
}
+ }
- items[i*2 + 1] = "In Progress";
- archive_file = 0;
-
- dialog_mixedgauge(title, pprompt, 0, 0, progress, nfiles,
- __DECONST(char **, items));
-
- while ((retval = archive_read_next_header(archive, &entry)) ==
- ARCHIVE_OK) {
- last_progress = progress;
- progress = (current_files*100)/total_files;
-
- snprintf(status, sizeof(status), "-%d",
- (archive_file*100)/archive_files[i]);
- items[i*2 + 1] = status;
-
- if (progress > last_progress)
- dialog_mixedgauge(title, pprompt, 0, 0,
- progress, nfiles,
- __DECONST(char **, items));
-
- retval = archive_read_extract(archive, entry,
- ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_OWNER |
- ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL |
- ARCHIVE_EXTRACT_XATTR | ARCHIVE_EXTRACT_FFLAGS);
-
- if (retval != ARCHIVE_OK)
- break;
-
- archive_file++;
- current_files++;
- }
+ /* Read the next archive header */
+ retval = archive_read_next_header(archive, &entry);
- items[i*2 + 1] = "Done";
-
- if (retval != ARCHIVE_EOF) {
- snprintf(errormsg, sizeof(errormsg),
- "Error while extracting %s: %s\n", items[i*2],
- archive_error_string(archive));
- items[i*2 + 1] = "Failed";
- dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
- return (retval);
- }
-
- progress = (current_files*100)/total_files;
- dialog_mixedgauge(title, pprompt, 0, 0, progress, nfiles,
- __DECONST(char **, items));
+ /* If that went well, perform the extraction */
+ if (retval == ARCHIVE_OK)
+ retval = archive_read_extract(archive, entry,
+ ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_OWNER |
+ ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL |
+ ARCHIVE_EXTRACT_XATTR | ARCHIVE_EXTRACT_FFLAGS);
+ /* Test for either EOF or error */
+ if (retval == ARCHIVE_EOF) {
archive_read_free(archive);
- i++;
+ archive = NULL;
+ file->status = DPV_STATUS_DONE;
+ return (100);
+ } else if (retval != ARCHIVE_OK) {
+ snprintf(errormsg, sizeof(errormsg),
+ "Error while extracting %s: %s\n", file->name,
+ archive_error_string(archive));
+ dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
+ file->status = DPV_STATUS_FAILED;
+ dpv_abort = 1;
+ return (-1);
}
- return (EXIT_SUCCESS);
+ dpv_overall_read++;
+ file->read++;
+
+ /* Calculate [overall] percentage of completion (if possible) */
+ if (file->length >= 0)
+ return (file->read * 100 / file->length);
+ else
+ return (-1);
}
diff --git a/usr.sbin/bsdinstall/distfetch/Makefile b/usr.sbin/bsdinstall/distfetch/Makefile
index ed1f599..5c0f6e8 100644
--- a/usr.sbin/bsdinstall/distfetch/Makefile
+++ b/usr.sbin/bsdinstall/distfetch/Makefile
@@ -2,8 +2,7 @@
BINDIR= /usr/libexec/bsdinstall
PROG= distfetch
-DPADD= ${LIBFETCH} ${LIBNCURSESW} ${LIBDIALOG} ${LIBM}
-LDADD= -lfetch -lncursesw -ldialog -lm
+LIBADD= fetch ncursesw dialog m
WARNS?= 6
MAN=
diff --git a/usr.sbin/bsdinstall/partedit/Makefile b/usr.sbin/bsdinstall/partedit/Makefile
index fb75888..d48f777 100644
--- a/usr.sbin/bsdinstall/partedit/Makefile
+++ b/usr.sbin/bsdinstall/partedit/Makefile
@@ -5,8 +5,7 @@ PROG= partedit
LINKS= ${BINDIR}/partedit ${BINDIR}/autopart \
${BINDIR}/partedit ${BINDIR}/scriptedpart
SYMLINKS= ${BINDIR}/partedit /usr/sbin/sade
-DPADD= ${LIBGEOM} ${LIBNCURSESW} ${LIBUTIL} ${LIBDIALOG} ${LIBM}
-LDADD= -lgeom -lncursesw -lutil -ldialog -lm
+LIBADD+= geom ncursesw util dialog m
PARTEDIT_ARCH= ${MACHINE}
.if ${MACHINE} == "i386" || ${MACHINE} == "amd64"
diff --git a/usr.sbin/bsdinstall/partedit/partedit_x86.c b/usr.sbin/bsdinstall/partedit/partedit_x86.c
index cc6a571..6a60678 100644
--- a/usr.sbin/bsdinstall/partedit/partedit_x86.c
+++ b/usr.sbin/bsdinstall/partedit/partedit_x86.c
@@ -51,7 +51,10 @@ x86_bootmethod(void)
const char *
default_scheme(void)
{
- return ("GPT");
+ if (strcmp(x86_bootmethod(), "UEFI") == 0)
+ return ("GPT");
+ else
+ return ("MBR");
}
int
diff --git a/usr.sbin/bsdinstall/scripts/docsinstall b/usr.sbin/bsdinstall/scripts/docsinstall
index f0bc8f5..4836507 100755
--- a/usr.sbin/bsdinstall/scripts/docsinstall
+++ b/usr.sbin/bsdinstall/scripts/docsinstall
@@ -154,10 +154,13 @@ f_quietly cp -f $BSDINSTALL_TMPETC/resolv.conf $BSDINSTALL_CHROOT/etc/
#
# Install each of the selected packages
#
+docsets=""
for lang in $selected; do
- f_package_add $lang-freebsd-doc || return $FAILURE
+ docsets="$docsets $lang-freebsd-doc"
done
+ASSUME_ALWAYS_YES=YES chroot $BSDINSTALL_CHROOT pkg install $docsets || return $FAILURE
+
################################################################################
# END
################################################################################
diff --git a/usr.sbin/bsdinstall/scripts/zfsboot b/usr.sbin/bsdinstall/scripts/zfsboot
index 2b01dea..c759e85 100755
--- a/usr.sbin/bsdinstall/scripts/zfsboot
+++ b/usr.sbin/bsdinstall/scripts/zfsboot
@@ -1,7 +1,7 @@
#!/bin/sh
#-
-# Copyright (c) 2013 Allan Jude
-# Copyright (c) 2013 Devin Teske
+# Copyright (c) 2013-2014 Allan Jude
+# Copyright (c) 2013-2015 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -65,9 +65,9 @@ f_include $BSDCFG_SHARE/variable.subr
: ${ZFSBOOT_VDEV_TYPE:=stripe}
#
-# Should we use gnop(8) to configure a transparent mapping to 4K sectors?
+# Should we use sysctl(8) vfs.zfs.min_auto_ashift=12 to force 4K sectors?
#
-: ${ZFSBOOT_GNOP_4K_FORCE_ALIGN:=1}
+: ${ZFSBOOT_FORCE_4K_SECTORS:=1}
#
# Should we use geli(8) to encrypt the drives?
@@ -185,8 +185,6 @@ ECHO_APPEND='echo "%s" >> "%s"'
GELI_ATTACH='geli attach -j - -k "%s" "%s"'
GELI_DETACH_F='geli detach -f "%s"'
GELI_PASSWORD_INIT='geli init -b -B "%s" -e %s -J - -K "%s" -l 256 -s 4096 "%s"'
-GNOP_CREATE='gnop create -S 4096 "%s"'
-GNOP_DESTROY='gnop destroy "%s"'
GPART_ADD='gpart add -t %s "%s"'
GPART_ADD_INDEX='gpart add -i %s -t %s "%s"'
GPART_ADD_INDEX_WITH_SIZE='gpart add -i %s -t %s -s %s "%s"'
@@ -205,6 +203,7 @@ PRINTF_CONF="printf '%s=\"%%s\"\\\n' %s >> \"%s\""
PRINTF_FSTAB='printf "$FSTAB_FMT" "%s" "%s" "%s" "%s" "%s" "%s" >> "%s"'
SHELL_TRUNCATE=':> "%s"'
SWAP_GMIRROR_LABEL='gmirror label swap %s'
+SYSCTL_ZFS_MIN_ASHIFT_12='sysctl vfs.zfs.min_auto_ashift=12'
UMOUNT='umount "%s"'
ZFS_CREATE_WITH_OPTIONS='zfs create %s "%s"'
ZFS_SET='zfs set "%s" "%s"'
@@ -236,7 +235,7 @@ msg_encrypt_disks="Encrypt Disks?"
msg_encrypt_disks_help="Use geli(8) to encrypt all data partitions"
msg_error="Error"
msg_force_4k_sectors="Force 4K Sectors?"
-msg_force_4k_sectors_help="Use gnop(8) to configure forced 4K sector alignment"
+msg_force_4k_sectors_help="Use sysctl(8) vfs.zfs.min_auto_ashift=12 to force 4K sectors"
msg_freebsd_installer="FreeBSD Installer"
msg_geli_password="Enter a strong passphrase, used to protect your encryption keys. You will be required to enter this passphrase each time the system is booted"
msg_geli_setup="Initializing encryption on selected disks,\n this will take several seconds per disk"
@@ -288,10 +287,12 @@ msg_stripe_desc="Stripe - No Redundancy"
msg_stripe_help="[1+ Disks] Striping provides maximum storage but no redundancy"
msg_swap_encrypt="Encrypt Swap?"
msg_swap_encrypt_help="Encrypt swap partitions with temporary keys, discarded on reboot"
+msg_swap_invalid="The selected swap size (%s) is invalid. Enter a number optionally followed by units. Example: 2G"
msg_swap_mirror="Mirror Swap?"
msg_swap_mirror_help="Mirror swap partitions for redundancy, breaks crash dumps"
msg_swap_size="Swap Size"
msg_swap_size_help="Customize how much swap space is allocated to each selected disk"
+msg_swap_toosmall="The selected swap size (%s) is to small. Please enter a value greater than 100MB or enter 0 for no swap"
msg_these_disks_are_too_small="These disks are too small given the amount of requested\nswap (%s) and/or geli(8) (%s) partitions, which would\ntake 50%% or more of each of the following selected disk\ndevices (not recommended):\n\n %s\n\nRecommend changing partition size(s) and/or selecting a\ndifferent set of devices."
msg_uefi_not_supported="The FreeBSD UEFI loader does not currently support booting root-on-ZFS. Your system will need to boot in legacy (CSM) mode.\nDo you want to continue?"
msg_unable_to_get_disk_capacity="Unable to get disk capacity of \`%s'"
@@ -315,37 +316,40 @@ dialog_menu_main()
local usegeli="$msg_no"
local swapgeli="$msg_no"
local swapmirror="$msg_no"
- [ "$ZFSBOOT_GNOP_4K_FORCE_ALIGN" ] && force4k="$msg_yes"
+ [ "$ZFSBOOT_FORCE_4K_SECTORS" ] && force4k="$msg_yes"
[ "$ZFSBOOT_GELI_ENCRYPTION" ] && usegeli="$msg_yes"
[ "$ZFSBOOT_SWAP_ENCRYPTION" ] && swapgeli="$msg_yes"
[ "$ZFSBOOT_SWAP_MIRROR" ] && swapmirror="$msg_yes"
local disks n disks_grammar
f_count n $ZFSBOOT_DISKS
- { [ $n -eq 1 ] && disks_grammar=$msg_disk_singular; } ||
+ { [ $n -eq 1 ] && disks_grammar=$msg_disk_singular; } ||
disks_grammar=$msg_disk_plural # grammar
local menu_list="
- '>>> $msg_install' '$msg_install_desc'
- '$msg_install_help'
- 'T $msg_pool_type_disks' '$ZFSBOOT_VDEV_TYPE: $n $disks_grammar'
- '$msg_pool_type_disks_help'
- '- $msg_rescan_devices' '*'
- '$msg_rescan_devices_help'
- '- $msg_disk_info' '*'
- '$msg_disk_info_help'
- 'N $msg_pool_name' '$ZFSBOOT_POOL_NAME'
- '$msg_pool_name_help'
- '4 $msg_force_4k_sectors' '$force4k'
- '$msg_force_4k_sectors_help'
- 'E $msg_encrypt_disks' '$usegeli'
- '$msg_encrypt_disks_help'
- 'P $msg_partition_scheme' '$ZFSBOOT_PARTITION_SCHEME'
- '$msg_partition_scheme_help'
- 'S $msg_swap_size' '$ZFSBOOT_SWAP_SIZE'
- '$msg_swap_size_help'
- 'M $msg_swap_mirror' '$swapmirror'
- '$msg_swap_mirror_help'
- 'W $msg_swap_encrypt' '$swapgeli'
- '$msg_swap_encrypt_help'
+ '>>> $msg_install' '$msg_install_desc'
+ '$msg_install_help'
+ 'T $msg_pool_type_disks'
+ '$ZFSBOOT_VDEV_TYPE: $n $disks_grammar'
+ '$msg_pool_type_disks_help'
+ '- $msg_rescan_devices' '*'
+ '$msg_rescan_devices_help'
+ '- $msg_disk_info' '*'
+ '$msg_disk_info_help'
+ 'N $msg_pool_name' '$ZFSBOOT_POOL_NAME'
+ '$msg_pool_name_help'
+ '4 $msg_force_4k_sectors'
+ '$force4k'
+ '$msg_force_4k_sectors_help'
+ 'E $msg_encrypt_disks' '$usegeli'
+ '$msg_encrypt_disks_help'
+ 'P $msg_partition_scheme'
+ '$ZFSBOOT_PARTITION_SCHEME'
+ '$msg_partition_scheme_help'
+ 'S $msg_swap_size' '$ZFSBOOT_SWAP_SIZE'
+ '$msg_swap_size_help'
+ 'M $msg_swap_mirror' '$swapmirror'
+ '$msg_swap_mirror_help'
+ 'W $msg_swap_encrypt' '$swapgeli'
+ '$msg_swap_encrypt_help'
" # END-QUOTE
local defaultitem= # Calculated below
local hline="$hline_alnum_arrows_punc_tab_enter"
@@ -938,17 +942,19 @@ zfs_create_diskpart()
# 5. Add freebsd-zfs partition for zroot
#
f_eval_catch $funcname gpart "$GPART_ADD_INDEX" \
- $mbrindex freebsd-zfs ${disk}s1 || return $FAILURE
+ $mbrindex freebsd-zfs ${disk}s1 || return $FAILURE
f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \
- /dev/$disk$targetpart # Pedantic
+ /dev/$disk$targetpart # Pedantic
f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \
- /boot/zfsboot /dev/${disk}s1 count=1 ||
- return $FAILURE
+ /boot/zfsboot /dev/${disk}s1 count=1 ||
+ return $FAILURE
;;
esac # $ZFSBOOT_PARTITION_SCHEME
# Update fstab(5)
+ local swapsize
+ f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize
if [ "$isswapmirror" ]; then
# This is not the first disk in the mirror, do nothing
elif [ "$ZFSBOOT_SWAP_ENCRYPTION" -a "$ZFSBOOT_SWAP_MIRROR" ]; then
@@ -968,6 +974,8 @@ zfs_create_diskpart()
/dev/$disk${swappart}.eli none swap sw 0 0 \
$BSDINSTALL_TMPETC/fstab ||
return $FAILURE
+ elif [ ${swapsize:-0} -eq 0 ]; then
+ # If swap is 0 sized, don't add it to fstab
else
f_eval_catch $funcname printf "$PRINTF_FSTAB" \
/dev/$disk$swappart none swap sw 0 0 \
@@ -1062,35 +1070,24 @@ zfs_create_boot()
# Prepare the disks and build pool device list(s)
#
f_dprintf "$funcname: Preparing disk partitions for ZFS pool..."
- [ "$ZFSBOOT_GNOP_4K_FORCE_ALIGN" ] &&
- f_dprintf "$funcname: With 4k alignment using gnop(8)..."
+
+ # Force 4K sectors using vfs.zfs.min_auto_ashift=12
+ if [ "$ZFSBOOT_FORCE_4K_SECTORS" ]; then
+ f_dprintf "$funcname: With 4K sectors..."
+ f_eval_catch $funcname sysctl "$SYSCTL_ZFS_MIN_ASHIFT_12" \
+ || return $FAILURE
+ fi
local n=0
for disk in $disks; do
zfs_create_diskpart $disk $n || return $FAILURE
# Now $bootpart, $targetpart, and $swappart are set (suffix
# for $disk)
-
- # Forced 4k alignment support using Geom NOP (see gnop(8))
- if [ "$ZFSBOOT_GNOP_4K_FORCE_ALIGN" ]; then
- if [ "$ZFSBOOT_BOOT_POOL" ]; then
- boot_vdevs="$boot_vdevs $disk$bootpart.nop"
- f_eval_catch $funcname gnop "$GNOP_CREATE" \
- $disk$bootpart || return $FAILURE
- fi
- # Don't gnop encrypted partition
- if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then
- zroot_vdevs="$zroot_vdevs $disk$targetpart.eli"
- else
- zroot_vdevs="$zroot_vdevs $disk$targetpart.nop"
- f_eval_catch $funcname gnop "$GNOP_CREATE" \
- $disk$targetpart ||
- return $FAILURE
- fi
- else
- if [ "$ZFSBOOT_BOOT_POOL" ]; then
- boot_vdevs="$boot_vdevs $disk$bootpart"
- fi
- zroot_vdevs="$zroot_vdevs $disk$targetpart"
+ if [ "$ZFSBOOT_BOOT_POOL" ]; then
+ boot_vdevs="$boot_vdevs $disk$bootpart"
+ fi
+ zroot_vdevs="$zroot_vdevs $disk$targetpart"
+ if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then
+ zroot_vdevs="$zroot_vdevs.eli"
fi
n=$(( $n + 1 ))
@@ -1135,8 +1132,11 @@ zfs_create_boot()
if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then
# Generate an encryption key using random(4)
f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \
- /dev/random "$bootpool/$zroot_key" \
+ /dev/random "$bootpool/$zroot_key" \
"bs=4096 count=1" || return $FAILURE
+ f_eval_catch $funcname chmod "$CHMOD_MODE" \
+ go-wrx "$bootpool/$zroot_key" ||
+ return $FAILURE
else
# Clean up
f_eval_catch $funcname zfs "$ZFS_UNMOUNT" \
@@ -1189,6 +1189,7 @@ zfs_create_boot()
return $FAILURE
f_eval_catch -d $funcname umount "$UMOUNT" /mnt # tmpfs
fi
+
#
# Create the gmirror(8) GEOMS for swap
#
@@ -1266,22 +1267,10 @@ zfs_create_boot()
"$bootpool_name" || return $FAILURE
fi
- # Destroy the gnop devices (if enabled)
- for disk in ${ZFSBOOT_GNOP_4K_FORCE_ALIGN:+$disks}; do
- if [ "$ZFSBOOT_BOOT_POOL" ]; then
- f_eval_catch -d $funcname gnop "$GNOP_DESTROY" \
- $disk$bootpart.nop
- fi
- if [ ! "$ZFSBOOT_GELI_ENCRYPTION" ]; then
- f_eval_catch -d $funcname gnop "$GNOP_DESTROY" \
- $disk$targetpart.nop
- fi
- done
-
# MBR boot loader touch-up
if [ "$ZFSBOOT_PARTITION_SCHEME" = "MBR" ]; then
f_dprintf "$funcname: Updating MBR boot loader on disks..."
- # Stick the ZFS boot loader in the "convienient hole" after
+ # Stick the ZFS boot loader in the "convienient hole" after
# the ZFS internal metadata
for disk in $disks; do
f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \
@@ -1323,8 +1312,10 @@ zfs_create_boot()
$BSDINSTALL_TMPBOOT/loader.conf.zfs || return $FAILURE
if [ "$ZFSBOOT_SWAP_MIRROR" ]; then
- f_eval_catch $funcname echo "$ECHO_APPEND" 'geom_mirror_load=\"YES\"' \
- $BSDINSTALL_TMPBOOT/loader.conf.gmirror || return $FAILURE
+ f_eval_catch $funcname echo "$ECHO_APPEND" \
+ 'geom_mirror_load=\"YES\"' \
+ $BSDINSTALL_TMPBOOT/loader.conf.gmirror ||
+ return $FAILURE
fi
# We're all done unless we should go on for boot pool
@@ -1347,8 +1338,8 @@ zfs_create_boot()
return $FAILURE
done
f_eval_catch $funcname printf "$PRINTF_CONF" vfs.root.mountfrom \
- "\"zfs:$zroot_name/$zroot_bootfs\"" \
- $BSDINSTALL_TMPBOOT/loader.conf.root || return $FAILURE
+ "\"zfs:$zroot_name/$zroot_bootfs\"" \
+ $BSDINSTALL_TMPBOOT/loader.conf.root || return $FAILURE
# We're all done unless we should go on to do encryption
[ "$ZFSBOOT_GELI_ENCRYPTION" ] || return $SUCCESS
@@ -1358,9 +1349,12 @@ zfs_create_boot()
#
f_dprintf "$funcname: Configuring disk encryption..."
f_eval_catch $funcname echo "$ECHO_APPEND" 'aesni_load=\"YES\"' \
- $BSDINSTALL_TMPBOOT/loader.conf.aesni || return $FAILURE
+ $BSDINSTALL_TMPBOOT/loader.conf.aesni || return $FAILURE
f_eval_catch $funcname echo "$ECHO_APPEND" 'geom_eli_load=\"YES\"' \
- $BSDINSTALL_TMPBOOT/loader.conf.geli || return $FAILURE
+ $BSDINSTALL_TMPBOOT/loader.conf.geli || return $FAILURE
+ f_eval_catch $funcname echo "$ECHO_APPEND" \
+ 'geom_eli_passphrase_prompt=\"YES\"' \
+ $BSDINSTALL_TMPBOOT/loader.conf.geli || return $FAILURE
for disk in $disks; do
f_eval_catch $funcname printf "$PRINTF_CONF" \
geli_%s_keyfile0_load "$disk$targetpart YES" \
@@ -1431,14 +1425,14 @@ f_dprintf "FSTAB_FMT=[%s]" "$FSTAB_FMT"
# ZFS with UEFI yet
#
if f_interactive; then
- bootmethod=$(sysctl -n machdep.bootmethod)
- f_dprintf "machdep.bootmethod=[%s]" "$bootmethod"
- if [ "$bootmethod" != "BIOS" ]; then
- dialog_uefi_prompt
- retval=$?
- f_dprintf "uefi_prompt=[%s]" "$retval"
- [ $retval -eq $DIALOG_OK ] || f_die
- fi
+ bootmethod=$( sysctl -n machdep.bootmethod )
+ f_dprintf "machdep.bootmethod=[%s]" "$bootmethod"
+ if [ "$bootmethod" != "BIOS" ]; then
+ dialog_uefi_prompt
+ retval=$?
+ f_dprintf "uefi_prompt=[%s]" "$retval"
+ [ $retval -eq $DIALOG_OK ] || f_die
+ fi
fi
#
@@ -1544,10 +1538,10 @@ while :; do
;;
?" $msg_force_4k_sectors")
# Toggle the variable referenced both by the menu and later
- if [ "$ZFSBOOT_GNOP_4K_FORCE_ALIGN" ]; then
- ZFSBOOT_GNOP_4K_FORCE_ALIGN=
+ if [ "$ZFSBOOT_FORCE_4K_SECTORS" ]; then
+ ZFSBOOT_FORCE_4K_SECTORS=
else
- ZFSBOOT_GNOP_4K_FORCE_ALIGN=1
+ ZFSBOOT_FORCE_4K_SECTORS=1
fi
;;
?" $msg_encrypt_disks")
@@ -1555,7 +1549,7 @@ while :; do
if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then
ZFSBOOT_GELI_ENCRYPTION=
else
- ZFSBOOT_GNOP_4K_FORCE_ALIGN=1
+ ZFSBOOT_FORCE_4K_SECTORS=1
ZFSBOOT_GELI_ENCRYPTION=1
fi
;;
@@ -1569,10 +1563,26 @@ while :; do
;;
?" $msg_swap_size")
# Prompt the user to input/change the swap size for each disk
- f_dialog_input input \
- "$msg_please_enter_amount_of_swap_space" \
- "$ZFSBOOT_SWAP_SIZE" &&
- ZFSBOOT_SWAP_SIZE="${input:-0}"
+ while :; do
+ f_dialog_input input \
+ "$msg_please_enter_amount_of_swap_space" \
+ "$ZFSBOOT_SWAP_SIZE" &&
+ ZFSBOOT_SWAP_SIZE="${input:-0}"
+ if f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize
+ then
+ if [ $swapsize -ne 0 -a $swapsize -lt 104857600 ]; then
+ f_show_err "$msg_swap_toosmall" \
+ "$ZFSBOOT_SWAP_SIZE"
+ continue;
+ else
+ break;
+ fi
+ else
+ f_show_err "$msg_swap_invalid" \
+ "$ZFSBOOT_SWAP_SIZE"
+ continue;
+ fi
+ done
;;
?" $msg_swap_mirror")
# Toggle the variable referenced both by the menu and later
OpenPOWER on IntegriCloud