diff --git a/distrib/amd64/cdroms/etc.rc b/distrib/amd64/cdroms/etc.rc index f14c7658b69a..82aefb06380d 100644 --- a/distrib/amd64/cdroms/etc.rc +++ b/distrib/amd64/cdroms/etc.rc @@ -36,9 +36,6 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin:/ export PATH -# hack to get around bugs in kernfs's rootdev/rrootdev lookup. -ls -l /dev/* > /dev/null 2>&1 - # mount a few tempfs to allow modifications over the CD contents mount -t tmpfs tmpfs /tmp mount -t tmpfs tmpfs /var diff --git a/distrib/amd64/installimage/etc.rc b/distrib/amd64/installimage/etc.rc index 5876c183dcd9..920107968fac 100644 --- a/distrib/amd64/installimage/etc.rc +++ b/distrib/amd64/installimage/etc.rc @@ -36,9 +36,6 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin:/ export PATH -# hack to get around bugs in kernfs's rootdev/rrootdev lookup. -ls -l /dev/* > /dev/null 2>&1 - mount -u / mount -t tmpfs tmpfs /tmp diff --git a/distrib/amd64/ramdisks/ramdisk-cgdroot/Makefile b/distrib/amd64/ramdisks/ramdisk-cgdroot/Makefile index 7be7a009f288..046eadd02b4c 100644 --- a/distrib/amd64/ramdisks/ramdisk-cgdroot/Makefile +++ b/distrib/amd64/ramdisks/ramdisk-cgdroot/Makefile @@ -1,14 +1,23 @@ # $NetBSD: Makefile,v 1.1 2013/07/15 00:22:10 khorben Exp $ IMAGE= ramdisk-cgdroot.fs -IMAGESIZE= 5000k +IMAGESIZE= 30000k IMAGEDEPENDS= +MAKEDEVTARGETS= all CRUNCHENV= INIT_CHROOT=1 SMALLPROG_INET6=1 +LISTS+= ${DISTRIBDIR}/common/list.cgdroot +LISTS+= ${.CURDIR}/list + .include "${.CURDIR}/../common/Makefile.ramdisk" +.include "${DISTRIBDIR}/common/Makefile.makedev" + +# Needed by zfs stuff. +CPPFLAGS+= -D_REENTRANT + +${IMAGE}: ${NETBSDSRCDIR}/distrib/common/cgdroot.rc -LISTS+= ${DISTRIBDIR}/common/list.cgdroot MTREECONF+= ${DISTRIBDIR}/common/mtree.cgdroot .if ${USE_INET6} != "no" diff --git a/distrib/amd64/ramdisks/ramdisk-zfsroot/Makefile b/distrib/amd64/ramdisks/ramdisk-zfsroot/Makefile new file mode 100644 index 000000000000..cc366e137de1 --- /dev/null +++ b/distrib/amd64/ramdisks/ramdisk-zfsroot/Makefile @@ -0,0 +1,17 @@ +# $NetBSD: Makefile,v 1.1 2020/02/22 09:53:47 roy Exp $ + +IMAGE= ramdisk-zfsroot.fs +IMAGESIZE= 5000k +IMAGEDEPENDS= +MAKEDEVTARGETS= all +CRUNCHENV= INIT_CHROOT=1 +SMALLPROG_INET6= 1 + +LISTS+= ${DISTRIBDIR}/common/list.zfsroot + +.include "${.CURDIR}/../common/Makefile.ramdisk" +.include "${DISTRIBDIR}/common/Makefile.makedev" + +LISTS+= ${.CURDIR}/list + +MTREECONF+= ${DISTRIBDIR}/common/mtree.zfsroot diff --git a/distrib/amd64/ramdisks/ramdisk-zfsroot/list b/distrib/amd64/ramdisks/ramdisk-zfsroot/list new file mode 100644 index 000000000000..8a408e9af3ed --- /dev/null +++ b/distrib/amd64/ramdisks/ramdisk-zfsroot/list @@ -0,0 +1,12 @@ +# $NetBSD: list,v 1.1 2020/02/22 09:53:47 roy Exp $ + +PROG bin/sync + +PROG sbin/fdisk +PROG sbin/gpt +PROG sbin/mbrlabel +PROG sbin/shutdown + +PROG usr/bin/less usr/bin/more + +PROG usr/sbin/installboot diff --git a/distrib/common/cgdroot.rc b/distrib/common/cgdroot.rc index 4900b02e0bc4..70c99e11e527 100644 --- a/distrib/common/cgdroot.rc +++ b/distrib/common/cgdroot.rc @@ -2,7 +2,7 @@ # # Copyright (c) 2013 Pierre Pronchery # All rights reserved. -# +# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: @@ -11,7 +11,7 @@ # 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 ``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. @@ -54,9 +54,14 @@ if [ $? -ne 0 ]; then umount /etc/cgd exit 2 fi -mount -o ro /dev/cgd0a /altroot -if [ $? -ne 0 ]; then +zpool import -f -N rpool +mount -t zfs rpool/ROOT /altroot +if test -z "`mount | sed -n '/ on \/altroot /p'`"; then + mount -o ro /dev/cgd0a /altroot +fi +if test -z "`mount | sed -n '/ on \/altroot /p'`"; then echo "Could not mount the root partition" 1>&2 + zpool export rpool cgdconfig -U umount /etc/cgd exit 2 diff --git a/distrib/common/list.cgdroot b/distrib/common/list.cgdroot index b7eb941689e3..1e2ab48b50ff 100644 --- a/distrib/common/list.cgdroot +++ b/distrib/common/list.cgdroot @@ -3,8 +3,35 @@ # list file (c.f. parselist.awk) for cgd full-disk encryption. # +SRCDIRS external/cddl/osnet/sbin + PROG sbin/cgdconfig PROG sbin/wsconsctl +PROG sbin/zfs +PROG sbin/zpool + +PROG usr/bin/ktrace +PROG usr/bin/kdump + +LINK sbin/zfs sbin/mount_zfs +ARGVLN zfs mount_zfs + +LIBS -lzfs +LIBS -lzfs_core +LIBS -lzpool +LIBS -luutil +LIBS -lumem +LIBS -lavl +LIBS -lnvpair LIBS -lcrypto +#LIBS -lutil # replaced by libhack +LIBS -lz +LIBS -lm +LIBS -lpthread +# Set up the rc script to configure cgd and mount file systems. COPY ${NETBSDSRCDIR}/distrib/common/cgdroot.rc etc/rc + +# Make firmware images available. +COPYDIR ${DESTDIR}/libdata altroot/libdata +SYMLINK altroot/libdata libdata diff --git a/distrib/common/list.zfsroot b/distrib/common/list.zfsroot new file mode 100644 index 000000000000..9b6fb81b7b64 --- /dev/null +++ b/distrib/common/list.zfsroot @@ -0,0 +1,35 @@ +# $NetBSD: list.zfsroot,v 1.2 2020/02/23 05:15:54 roy Exp $ +# +# list file (c.f. parselist.awk) for ZFS on root. +# + +SRCDIRS external/cddl/osnet/sbin +PROG sbin/zfs +PROG sbin/zpool +LINK sbin/zfs sbin/mount_zfs +ARGVLN zfs mount_zfs + +# We need sysctl to set init.root=/altroot +PROG sbin/sysctl + +# We need modload as we cannot build CDDL modules in the kernel +PROG sbin/modload +PROG sbin/modunload +PROG sbin/modstat + +LIBS -lnvpair +LIBS -luutil +LIBS -lzfs +LIBS -lavl +LIBS -lm +LIBS -lpthread +LIBS -lumem +#LIBS -lutil # replaced by libhack +LIBS -lz +LIBS -lzfs_core + +COPY ${NETBSDSRCDIR}/distrib/common/zfsroot.rc etc/rc + +# Make modules and firmware images available +SYMLINK altroot/stand stand +SYMLINK altroot/libdata libdata diff --git a/distrib/common/mtree.zfsroot b/distrib/common/mtree.zfsroot new file mode 100644 index 000000000000..be040287c1e4 --- /dev/null +++ b/distrib/common/mtree.zfsroot @@ -0,0 +1,5 @@ +# $NetBSD: mtree.zfsroot,v 1.3 2020/02/23 10:51:12 roy Exp $ + +. +./altroot +./rpool diff --git a/distrib/common/zfsroot.rc b/distrib/common/zfsroot.rc new file mode 100644 index 000000000000..8a1868424242 --- /dev/null +++ b/distrib/common/zfsroot.rc @@ -0,0 +1,50 @@ +#/bin/sh +# +# $NetBSD: zfsroot.rc,v 1.3 2020/02/23 10:51:12 roy Exp $ + +echo "Starting root on ZFS boot strapper" + +# Abort on any error +set -e + +# Configurable - define the ZFS root pool and ROOT. +# XXX Can these be set in boot.cfg? +# Assumption - the root pool is set to legacy mount. +rpool=rpool +rroot=ROOT + +# Assumption - the boot device is named boot. +# Could use /dev/dk0, /dev/wd0a, etc instead. +# XXX Can be exposed by sysctl kern.boot_device? +bootdev="NAME=boot" + +# Setup some stuff incase things go south and we drop to the shell +export HOME=/ +export PATH=/sbin:/bin:/usr/sbin:/usr/bin +umask 022 + +# Avoid having the solaris and zfs modules in ramdisk directly. +# Means we don't need to update the ramdisk with the kernel modules +# or load them from boot.cfg so it's less pain for the user. +#bootdev="$(/sbin/sysctl -n kern.boot_device)" +modpath="$(/sbin/sysctl -n kern.module.path)" +echo "Loading needed kernel modules from $bootdev:$modpath" +/sbin/mount -o ro "$bootdev" /mnt +for m in solaris zfs; do + /sbin/modload "/mnt/$modpath/$m/$m.kmod" +done +/sbin/umount /mnt + +# FIXME XXX Sometimes zpool import gets SIGBUS +# Ensure that we are in a writable directory to try and capture a coredump +# Not that we actually get a coredump .... +cd /tmp + +echo "Importing $rpool" +/sbin/zpool import -f -N "$rpool" + +echo "Mounting $rpool/$rroot to /altroot" +/sbin/mount -t zfs "$rpool/$rroot" /altroot; + +echo "Pivoting to /altroot, welcome to root on ZFS" +/sbin/sysctl -w init.root=/altroot diff --git a/distrib/evbarm/Makefile b/distrib/evbarm/Makefile index 81c97bd97f0b..e09cb1aa4c6b 100644 --- a/distrib/evbarm/Makefile +++ b/distrib/evbarm/Makefile @@ -6,6 +6,7 @@ .include SUBDIR= gzboot instkernel cdroms +SUBDIR+= zfsroot TARGETS+= release .if ${MACHINE_CPU} == "arm" diff --git a/distrib/evbarm/zfsroot/Makefile b/distrib/evbarm/zfsroot/Makefile new file mode 100644 index 000000000000..922644a30a25 --- /dev/null +++ b/distrib/evbarm/zfsroot/Makefile @@ -0,0 +1,42 @@ +# $NetBSD$ + +.include +.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" + +IMAGE= zfsroot.fs +IMAGESIZE= 5000k + +.if empty(MACHINE_ARCH:M*eb) +IMAGEENDIAN= be +.else +IMAGEENDIAN= le +.endif + +CRUNCHENV= INIT_CHROOT=1 +CRUNCHBIN= zfsrootbin +IMAGEDEPENDS+= ${CRUNCHBIN} + +# Put list.zfsroot first so it gets -lm and -lz in the right order. +LISTS+= ${DISTRIBDIR}/common/list.zfsroot +LISTS+= ${DISTRIBDIR}/evbarm/instkernel/ramdisk/list +IMAGEDEPENDS+= ${LISTS} +IMAGEDEPENDS+= ${DISTRIBDIR}/evbarm/instkernel/ramdisk/dot.profile + +MTREECONF+= ${DISTRIBDIR}/common/mtree.common +MTREECONF+= ${DISTRIBDIR}/common/mtree.zfsroot +IMAGEDEPENDS+= ${MTREECONF} + +# Use stubs to eliminate some large stuff from libc +HACKSRC= ${DISTRIBDIR}/utils/libhack +.include "${HACKSRC}/Makefile.inc" +${CRUNCHBIN}: libhack.o + +.include "${DISTRIBDIR}/common/Makefile.crunch" +.include "${DISTRIBDIR}/common/Makefile.dhcpcd" +.include "${DISTRIBDIR}/common/Makefile.makedev" +.include "${DISTRIBDIR}/common/Makefile.image" + +# XXX Install it somewhere. +release: ${IMAGE} + +.include diff --git a/distrib/evbarm/zfsroot/dot.profile b/distrib/evbarm/zfsroot/dot.profile new file mode 100644 index 000000000000..36e89fa8d149 --- /dev/null +++ b/distrib/evbarm/zfsroot/dot.profile @@ -0,0 +1 @@ +# $NetBSD$ diff --git a/distrib/i386/cdroms/etc.rc b/distrib/i386/cdroms/etc.rc index f78ea8128aff..6aad1b981ca5 100644 --- a/distrib/i386/cdroms/etc.rc +++ b/distrib/i386/cdroms/etc.rc @@ -36,9 +36,6 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin:/ export PATH -# hack to get around bugs in kernfs's rootdev/rrootdev lookup. -ls -l /dev/* > /dev/null 2>&1 - # mount a few tempfs to allow modifications over the CD contents mount -t tmpfs tmpfs /tmp mount -t tmpfs tmpfs /var diff --git a/distrib/i386/installimage/etc.rc b/distrib/i386/installimage/etc.rc index 0af0f6320fe5..bff88f71cc73 100644 --- a/distrib/i386/installimage/etc.rc +++ b/distrib/i386/installimage/etc.rc @@ -36,9 +36,6 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin:/ export PATH -# hack to get around bugs in kernfs's rootdev/rrootdev lookup. -ls -l /dev/* > /dev/null 2>&1 - mount -u / mount -t tmpfs tmpfs /tmp diff --git a/distrib/sets/lists/comp/mi b/distrib/sets/lists/comp/mi index a83f8dc3ae47..88b44bd1e321 100644 --- a/distrib/sets/lists/comp/mi +++ b/distrib/sets/lists/comp/mi @@ -11532,6 +11532,7 @@ ./usr/share/man/cat9/pcu_used_p.0 comp-sys-catman .cat ./usr/share/man/cat9/percpu.0 comp-sys-catman .cat ./usr/share/man/cat9/percpu_alloc.0 comp-sys-catman .cat +./usr/share/man/cat9/percpu_create.0 comp-sys-catman .cat ./usr/share/man/cat9/percpu_foreach.0 comp-sys-catman .cat ./usr/share/man/cat9/percpu_free.0 comp-sys-catman .cat ./usr/share/man/cat9/percpu_getref.0 comp-sys-catman .cat @@ -19450,6 +19451,7 @@ ./usr/share/man/html9/pcu_used_p.html comp-sys-htmlman html ./usr/share/man/html9/percpu.html comp-sys-htmlman html ./usr/share/man/html9/percpu_alloc.html comp-sys-htmlman html +./usr/share/man/html9/percpu_create.html comp-sys-htmlman html ./usr/share/man/html9/percpu_foreach.html comp-sys-htmlman html ./usr/share/man/html9/percpu_free.html comp-sys-htmlman html ./usr/share/man/html9/percpu_getref.html comp-sys-htmlman html @@ -27527,6 +27529,7 @@ ./usr/share/man/man9/pcu_used_p.9 comp-sys-man .man ./usr/share/man/man9/percpu.9 comp-sys-man .man ./usr/share/man/man9/percpu_alloc.9 comp-sys-man .man +./usr/share/man/man9/percpu_create.9 comp-sys-man .man ./usr/share/man/man9/percpu_foreach.9 comp-sys-man .man ./usr/share/man/man9/percpu_free.9 comp-sys-man .man ./usr/share/man/man9/percpu_getref.9 comp-sys-man .man diff --git a/distrib/sets/lists/man/mi b/distrib/sets/lists/man/mi index 2a9d82773cc3..e52f73b479a1 100644 --- a/distrib/sets/lists/man/mi +++ b/distrib/sets/lists/man/mi @@ -5387,6 +5387,7 @@ ./usr/share/man/html7/editline.html man-sys-htmlman html ./usr/share/man/html7/environ.html man-reference-htmlman html ./usr/share/man/html7/glob.html man-reference-htmlman html +./usr/share/man/html7/groups.html man-reference-htmlman html ./usr/share/man/html7/hier.html man-reference-htmlman html ./usr/share/man/html7/hostname.html man-reference-htmlman html ./usr/share/man/html7/intro.html man-reference-htmlman html @@ -5420,6 +5421,7 @@ ./usr/share/man/html7/symlink.html man-reference-htmlman html ./usr/share/man/html7/sysctl.html man-reference-htmlman html ./usr/share/man/html7/tests.html man-reference-htmlman html +./usr/share/man/html7/users.html man-reference-htmlman html ./usr/share/man/html7/zpool-features.html man-zfs-htmlman zfs,html ./usr/share/man/html8/MAKEDEV.html man-sysutil-htmlman html ./usr/share/man/html8/MAKEDEV.local.html man-sysutil-htmlman html @@ -8436,6 +8438,7 @@ ./usr/share/man/man7/editline.7 man-sys-man .man ./usr/share/man/man7/environ.7 man-reference-man .man ./usr/share/man/man7/glob.7 man-reference-man .man +./usr/share/man/man7/groups.7 man-reference-man .man ./usr/share/man/man7/hier.7 man-reference-man .man ./usr/share/man/man7/hostname.7 man-reference-man .man ./usr/share/man/man7/intro.7 man-reference-man .man @@ -8472,6 +8475,7 @@ ./usr/share/man/man7/symlink.7 man-reference-man .man ./usr/share/man/man7/sysctl.7 man-reference-man .man ./usr/share/man/man7/tests.7 man-reference-man .man +./usr/share/man/man7/users.7 man-reference-man .man ./usr/share/man/man7/zpool-features.7 man-zfs-man zfs,.man ./usr/share/man/man8/MAKEDEV.8 man-sysutil-man .man ./usr/share/man/man8/MAKEDEV.local.8 man-sysutil-man .man diff --git a/distrib/sparc64/cdroms/installcd/etc.rc b/distrib/sparc64/cdroms/installcd/etc.rc index f78ea8128aff..6aad1b981ca5 100644 --- a/distrib/sparc64/cdroms/installcd/etc.rc +++ b/distrib/sparc64/cdroms/installcd/etc.rc @@ -36,9 +36,6 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin:/ export PATH -# hack to get around bugs in kernfs's rootdev/rrootdev lookup. -ls -l /dev/* > /dev/null 2>&1 - # mount a few tempfs to allow modifications over the CD contents mount -t tmpfs tmpfs /tmp mount -t tmpfs tmpfs /var diff --git a/distrib/sparc64/instfs/dot.profile b/distrib/sparc64/instfs/dot.profile index 9043f01565a1..bc2c948094bd 100644 --- a/distrib/sparc64/instfs/dot.profile +++ b/distrib/sparc64/instfs/dot.profile @@ -91,9 +91,6 @@ EOM # examine the dmesg state mount -t kernfs /kern /kern - # hack to get around bugs in kernfs's rootdev/rrootdev lookup. - ls -l /dev/* > /dev/null 2>&1 - # mount the ramdisk read write mount -t ffs -u /kern/rootdev / diff --git a/distrib/vax/cdroms/installcd/etc.rc b/distrib/vax/cdroms/installcd/etc.rc index f7ec71c1dbd6..08101b3f680c 100644 --- a/distrib/vax/cdroms/installcd/etc.rc +++ b/distrib/vax/cdroms/installcd/etc.rc @@ -36,9 +36,6 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin:/ export PATH -# hack to get around bugs in kernfs's rootdev/rrootdev lookup. -ls -l /dev/* > /dev/null 2>&1 - lowmemfail() { cat << "EOM"