[CfT] BSDA2: loaderupdate

Kamikaze

Warrior of Sunlight
Teammitglied
Ich habe gerade die erste Version meines Boot loader Updaters gepusht.
Noch nicht kommentiert oder dokumentiert aber funktional so weit fertig:


Wer mich unterstützen will einfach die Sourcen herunterladen und das Skript ausführen:

Code:
# src/loaderupdate -h
usage: loaderupdate -h
       loaderupdate [-D destdir] [-b bootloader] [-e efiloader] [-p pmbr]
                    device ... [-dn]
       loaderupdate [-D destdir] [-b bootloader] [-e efiloader] [-p pmbr]
                    -a [-dn]
       loaderupdate [-D destdir] [-b bootloader] [-e efiloader] [-p pmbr]
                    -P [-an] [device ...]
        -a, --all         Update loaders of all devices
        -b, --bootloader  The freebsd-boot loader to install, e.g. /boot/gptboot
        -d, --demo        Print the actions that would be performed
        -D, --destdir     The root containing /boot
        -e, --efiloader   The EFI loader to install, e.g. /boot/loader.efi
        -h, --help        Display the list of command arguments
        -n, --noefi       Do not create EFI Boot Manager entries
        -P, --dump        Show the detected partitioning
        -p, --pmbr        The protective MBR image, e.g. /boot/pmbr
        -q, --quiet       Do not produce any additional output

Ich würde mich über den Output von src/loaderupdate -Pa (--dump Modus) und src/loaderupdate -da (--demo Modus) freuen.

Die beiden Kommandos machen erst mal keine Änderungen.

Wer den nötigen Mut aufbringt kann natürlich auch tatsächlich ein Update durchführen.

Code:
root# src/loaderupdate nvd0
loaderupdate> gpart bootcode -b/boot/pmbr nvd0
bootcode written to nvd0
loaderupdate> gpart bootcode -p/boot/gptzfsboot -i1 nvd0
partcode written to nvd0p1
loaderupdate> mkdir -p nvd0p2:/efi/FreeBSD
loaderupdate> cp /boot/loader.efi nvd0p2:/efi/FreeBSD/bootamd64.efi
loaderupdate> efibootmgr -B 0001
Removing boot variable 'Boot0001'
Removing 0x1 from BootOrder
BootCurrent: 0000
Timeout    : 0 seconds
BootOrder  : 0000, 0002, 0004, 0003, 0005, 2001, 2002, 2003
+Boot0000* nvd1/amd64/FreeBSD 12.2-STABLE 760e643de558(kami/12) SCO15M19
 Boot0002* nvd0/amd64/Shell
 Boot0004* nvd1/amd64/Shell
 Boot0003* nvd0/amd64/MemTest86 8.4
 Boot0005* nvd1/amd64/MemTest86 8.4
 Boot2001* EFI USB Device
 Boot2002* EFI DVD/CDROM
 Boot2003* EFI Network
loaderupdate> efibootmgr -cl nvd0p2:/efi/FreeBSD/bootamd64.efi -L 'nvd0/amd64/FreeBSD 12.2-STABLE 760e643de558(kami/12) SCO15M19'
BootCurrent: 0000
Timeout    : 0 seconds
BootOrder  : 0001, 0000, 0002, 0004, 0003, 0005, 2001, 2002, 2003
 Boot0001  nvd0/amd64/FreeBSD 12.2-STABLE 760e643de558(kami/12) SCO15M19
+Boot0000* nvd1/amd64/FreeBSD 12.2-STABLE 760e643de558(kami/12) SCO15M19
 Boot0002* nvd0/amd64/Shell
 Boot0004* nvd1/amd64/Shell
 Boot0003* nvd0/amd64/MemTest86 8.4
 Boot0005* nvd1/amd64/MemTest86 8.4
 Boot2001* EFI USB Device
 Boot2002* EFI DVD/CDROM
 Boot2003* EFI Network
loaderupdate> efibootmgr -a 0001
BootCurrent: 0000
Timeout    : 0 seconds
BootOrder  : 0001, 0000, 0002, 0004, 0003, 0005, 2001, 2002, 2003
 Boot0001* nvd0/amd64/FreeBSD 12.2-STABLE 760e643de558(kami/12) SCO15M19
+Boot0000* nvd1/amd64/FreeBSD 12.2-STABLE 760e643de558(kami/12) SCO15M19
 Boot0002* nvd0/amd64/Shell
 Boot0004* nvd1/amd64/Shell
 Boot0003* nvd0/amd64/MemTest86 8.4
 Boot0005* nvd1/amd64/MemTest86 8.4
 Boot2001* EFI USB Device
 Boot2002* EFI DVD/CDROM
 Boot2003* EFI Network
root#
 
Code:
[beastie] /home/datasmurf/Desktop/Dateien/Werkbank/bsda2/src # ./loaderupdate -Pa
ERROR: No freebsd-boot or efi partitions on device: da1

Code:
[beastie] /home/datasmurf/Desktop/Dateien/Werkbank/bsda2/src # ./loaderupdate -P ada0
Boot Environment
----------------
destdir:                /
ostype:                 FreeBSD
kernel version:         FreeBSD 12.2-RELEASE-p1 GENERIC
kernel arch:            amd64
protective MBR:         /boot/pmbr
freebsd-boot loader:    /boot/gptzfsboot
EFI loader:             /boot/loader.efi

Device ada0
-----------
    install:            /boot/loader.efi > ada0p1:/efi/FreeBSD/bootamd64.efi
    EFI boot entry:     ada0/amd64/FreeBSD 12.2-RELEASE-p1 GENERIC

Code:
[beastie] /home/datasmurf/Desktop/Dateien/Werkbank/bsda2/src # ./loaderupdate -da
ERROR: No freebsd-boot or efi partitions on device: da1

Code:
[beastie] /home/datasmurf/Desktop/Dateien/Werkbank/bsda2/src # ./loaderupdate -d ada0
loaderupdate> mkdir -p ada0p1:/efi/FreeBSD
loaderupdate> cp /boot/loader.efi ada0p1:/efi/FreeBSD/bootamd64.efi
loaderupdate> efibootmgr -cl ada0p1:/efi/FreeBSD/bootamd64.efi -L 'ada0/amd64/FreeBSD 12.2-RELEASE-p1 GENERIC'
 
@datasmurf Ich habe das --all Verhalten jetzt geändert:

  • Explizit angegebene Devices die keine Boot Partition haben sind ein Fehlerfall.
  • Durch das --all Flag implizierte Devices nicht.

Danke für Dein Feedback.
 
Ich habe gestern den aktuellen Stand gepusht. Jetzt gibt es auch einen README.md Abschnitt:


Hier ist noch mal die Anleitung zum Testen:
Code:
# fetch https://github.com/lonkamikaze/bsda2/archive/master.tar.gz
# sha256 master.tar.gz
SHA256 (master.tar.gz) = 637564205549d43f0bb6e458ce7bec119ba42cd400e675d3fbfcc633091eac09
# tar -xf master.tar.gz
# cd bsda2-master/
# src/loaderupdate -Pa
Boot Environment               
----------------            
destdir:                /   
ostype:                 FreeBSD
kernel version:         FreeBSD 12.2-STABLE 760e643de558(kami/12) SCO15M19                                      
kernel arch:            amd64
file system:            zfs  
protective MBR:         /boot/pmbr
freebsd-boot loader:    /boot/gptzfsboot
EFI loader:             /boot/loader.efi
                                                        
Device nvd0                    
-----------                            
    install:            /boot/pmbr > nvd0
    install:            /boot/gptzfsboot > nvd0p1
    install:            /boot/loader.efi > nvd0p2:/efi/FreeBSD/bootamd64.efi                                    
    EFI boot entry:     FreeBSD 12.2-STABLE 760e643de558(kami/12) SCO15M19 amd64 [nvd0p2]                       
                                                        
Device nvd1                     
-----------               
    install:            /boot/pmbr > nvd1
    install:            /boot/gptzfsboot > nvd1p1
    install:            /boot/loader.efi > nvd1p2:/efi/FreeBSD/bootamd64.efi                                    
    EFI boot entry:     FreeBSD 12.2-STABLE 760e643de558(kami/12) SCO15M19 amd64 [nvd1p2]                       
# src/loaderupdate -da
gpart bootcode -b/boot/pmbr nvd0
gpart bootcode -p/boot/gptzfsboot -i1 nvd0
mkdir -p nvd0p2
mount -tmsdosfs -osync /dev/nvd0p2 nvd0p2
mkdir -p nvd0p2/efi/FreeBSD
cp /boot/loader.efi nvd0p2/efi/FreeBSD/bootamd64.efi
efibootmgr -B 0001
efibootmgr -cl nvd0p2:/efi/FreeBSD/bootamd64.efi -L 'FreeBSD 12.2-STABLE 760e643de558(kami/12) SCO15M19 amd64 [nvd0p2]'
efibootmgr -a 0001
gpart bootcode -b/boot/pmbr nvd1
gpart bootcode -p/boot/gptzfsboot -i1 nvd1
mkdir -p nvd1p2
mount -tmsdosfs -osync /dev/nvd1p2 nvd1p2
mkdir -p nvd1p2/efi/FreeBSD
cp /boot/loader.efi nvd1p2/efi/FreeBSD/bootamd64.efi
efibootmgr -B 0000
efibootmgr -cl nvd1p2:/efi/FreeBSD/bootamd64.efi -L 'FreeBSD 12.2-STABLE 760e643de558(kami/12) SCO15M19 amd64 [nvd1p2]'
efibootmgr -a 0000
#

Auch die Manual-Page kann direkt ohne Installation gelesen werden:
Code:
# man man/loaderupdate.8 
LOADERUPDATE(8)         FreeBSD System Manager's Manual        LOADERUPDATE(8)

NAME
     loaderupdate – update boot loaders

SYNOPSIS
     loaderupdate [-D destdir] [-L efilabel] [-b bootloader] [-e efiloader]
                  [-p pmbr] [-dn] device ...
     loaderupdate [-D destdir] [-L efilabel] [-b bootloader] [-e efiloader]
                  [-p pmbr] [-dn] -a
     loaderupdate [-D destdir] [-L efilabel] [-b bootloader] [-e efiloader]
                  [-p pmbr] [-n] -P [-a | device ...]
     loaderupdate -h

DESCRIPTION
     The loaderupdate script updates the boot loaders of a given set of
     bootable devices according to a given boot environment.

     The boot environment must contain a system kernel under
     /boot/kernel/kernel as well as the required loader images. The defaults
     of which can be overridden by the -b, -e and -p parameters. Which boot
     loaders are used by default also depends on the file system of the boot
     environment.

     The default boot environment / can be overridden by providing the path to
     the current mountpoint of a different boot environment via the DESTDIR
     environment variable, or the -D parameter.

     The BOOTSTRAPPING section of gpart(8) provides a good overview of the
     boot process.

   Arguments
     The following argument types can be given:

     destdir
             The path of the mountpoint for the boot environment containing
             the kernel and boot loader images. The default boot environment
             is /.

     efilabel
             Formatting string for EFI boot manager entry labels, defaults to:
                   “{version} {arch} [{pdev}]”

             The following substitutions are available:
                   {dev}         The device containing the partition
                   {pdev}        The device of the efi partition
                   {index}       The index of the efi partition
                   {version}     The kernel version
                   {arch}        The kernel architecture

             Supports the character escape sequences and formatting flags
             described in printf(1).  Formatting flags are separated from the
             substitution name by a colon character. If no formatting field is
             given string formatting is assumed.  E.g.:
                   “{version:.12} {arch} [{index:2d}]”

     bootloader
             The boot loader image to use for freebsd-boot partitions. The
             default is either /boot/gptboot or /boot/gptzfsboot, depending on
             the file system containing boot environment.

     efiloader
             The boot loader image to use for efi partitions, the default is
             /boot/loader.efi, the efi variant of loader(8).

     pmbr    The protective MBR image installed in front of the GUID Partition
             Table. The protective MBR chain-boots the freebsd-boot partition
             on systems booting in legacy BIOS mode. This is only installed if
             a freebsd-boot partition is present. The default protective MBR
             image is /boot/pmbr.

     device  The hard disk device to update.

   Options
     The following options are available:

     -a --all
             Selects all available devices.

     -b --bootloader bootloader
             Override the default freebsd-boot loader image.

     -d --demo
             Instead of updating the boot loaders just show the commands that
             would be run. In combination with -q this does not print anything
             apart from errors, which is useful to run all checks performed by
             loaderupdate without committing any changes.

     -D --destdir destdir
             Override the default boot environment.

     -e --efiloader efiloader
             Override the default efi loader image.

     -L --label efilabel
             Set a custom label for EFI boot manager entries.

     -n --noefi
             Do not create EFI boot manager entries via the efibootmgr(8)
             command. This is useful when preparing a disk for another system.

     -P --dump
             Instead of performing boot loader updates print a summary of the
             boot environment and selected devices.

     -p --pmbr pmbr
             Override the default protective MBR image.

     -q --quiet
             Do not print the commands that are run. This flag does not
             suppress the output from those commands.

ENVIRONMENT
     DESTDIR
             Overrides the default boot environment.

FILES
     /boot/kernel/kernel
             Used to determine the version, architecture and OS to boot by
             extracting the version, machine and ostype symbols from the
             kernel binary.

     /boot/gptboot
             The freebsd-boot partition image for booting from UFS, see
             gptboot(8).

     /boot/gptzfsboot
             The freebsd-boot partition image for booting from ZFS, see
             gptboot(8).

     /boot/loader.efi
             The default efi variant of loader(8).  Capable of booting from
             UFS and Zfs, alternatives include /boot/loader_4th.efi,
             /boot/loader_lua.efi and /boot/loader_simp.efi.

     /boot/pmbr
             The default protective MBR image.

EXIT STATUS
     The following is a list of all anticipated exit codes. Codes labelled
     generic should be handled internally.

     EOK=0   Command completed successfully.

     ESIGNAL=1
             Interrupted by signal.

     EFAIL=2
             Generic application logic error.

     EPARAM=3
             Invalid or conflicting arguments were supplied.

     ENODEVICE=4
             No or inaccessible devices selected.

     EDESTDIR=5
             The destdir is not a directory.

     ENOKERNEL=6
             Cannot access kernel in destdir.

     EEFILABEL=7
             Corrupt label formatting, see efilabel in the Arguments section.

     ESCHEME=8
             None or unsupported partitioning scheme detected in device.

     ENOPARTS=9
             Neither a freebsd-boot nor an efi boot partition was found on a
             selected device.

     EEFIBOOTMGR=10
             Failed to run efibootmgr(8).

     ELOADER=11
             Cannot read a required loader image.

     EMOUNT=12
             Failed to mount the efi boot partition.

     ECMD=13
             Failed to execute a command during the update procedure.

EXAMPLES
     Run gpart(8) for a list of devices:
           gpart show

     Inspect the boot environment and the desired device:
           loaderupdate -P nvd0

     Review the commands to execute:
           loaderupdate -d nvd0

     Finally update the loaders for the device:
           loaderupdate nvd0

SEE ALSO
     efibootmgr(8), gpart(8), gptboot(8), gptzfsboot(8), loader(8)

HISTORY
     The loaderupdate command was added with the bsda2-0.4.0 release.

AUTHORS
     Dominic Fandrey <freebsd@k4m1.org>

CAVEATS
     Only supports GUID Partition Table formatted devices.

FreeBSD 12.2-STABLE            17 January, 2021            FreeBSD 12.2-STABLE
 
Hallo @Kamikaze

Ich habe noch drei Sachen, die mir aufgefallen sind.

Code:
root@freebsdpkg ~/tmp/bsd2/bsda2/src (git)-[master] # ./loaderupdate -Pa
NOTE: Cannot access device: fd0
NOTE: Cannot access device: cd0
fd0 bzw. cd0 würde ich ausblenden. Die Meldung verwirrt meiner Meinung mehr als sie nutzt.

Code:
root@freebsdpkg ~/tmp/bsd2/bsda2/src (git)-[master] # ./loaderupdate
ErrorCode 4 ???
Ohne Parameter Error Code 4?

Code:
        -d, --demo        Print the actions that would be performed
Das würde ich nicht "--demo" nennen sondern: "dry-run".
 
Code:
root@freebsdpkg ~/tmp/bsd2/bsda2/src (git)-[master] # ./loaderupdate -Pa
NOTE: Cannot access device: fd0
NOTE: Cannot access device: cd0
fd0 bzw. cd0 würde ich ausblenden. Die Meldung verwirrt meiner Meinung mehr als sie nutzt.
Da muss ich mir überlegen nach welchen Kriterien ich Devices aussortieren sollte. Was ist denn fd0 für ein Device?
Code:
root@freebsdpkg ~/tmp/bsd2/bsda2/src (git)-[master] # ./loaderupdate
ErrorCode 4 ???
Ohne Parameter Error Code 4?
Das ist sehr seltsam, auf jeden Fall ein Bug. Bei mir kommt das:
Code:
# ./loaderupdate 
usage: loaderupdate [-D destdir] [-L efilabel] [-b bootloader] [-e efiloader]
                    [-p pmbr] [-dn] device ...
       loaderupdate [-D destdir] [-L efilabel] [-b bootloader] [-e efiloader]
                    [-p pmbr] [-dn] -a
       loaderupdate [-D destdir] [-L efilabel] [-b bootloader] [-e efiloader]
                    [-p pmbr] [-n] -P [-a | device ...]
       loaderupdate -h
        -a, --all         Update loaders of all devices
        -b, --bootloader  The freebsd-boot loader to install, e.g. /boot/gptboot
        -d, --demo        Print the actions that would be performed
        -D, --destdir     The root containing /boot
        -e, --efiloader   The EFI loader to install, e.g. /boot/loader.efi
        -h, --help        Display the list of command arguments
        -L, --label       The EFI Boot Manager entry label
        -n, --noefi       Do not create EFI Boot Manager entries
        -P, --dump        Show the detected partitioning
        -p, --pmbr        The protective MBR image, e.g. /boot/pmbr
        -q, --quiet       Do not produce any additional output
ERROR: No device selected
# echo $?
4
#
Code:
        -d, --demo        Print the actions that would be performed
Das würde ich nicht "--demo" nennen sondern: "dry-run".
Ich schätze das wäre auch mit efibootmgr(8) konsistent. Dann müsste ich aber auch -d und -D tauschen.
 
Ich denke darüber nach --all komplett zu streichen oder nur in Verbindung mit --dump zu erlauben. Es ist halt doch ein recht gefährliches Flag.
 
Floppy Disk. Habs auf einer VMware VM getestet (die VM hat kein Floppy aktiv). Ich habe noch zwei andere Server.

Es gab eine Diskussion Floppy Disk Support zu 13.0 rauszuwerfen, weil der eh nicht mehr sinnvoll verwendet werden kann. Ob das passiert ist oder noch wird, weiß ich nicht. Zumindest spricht nichts dagegen Floppy auf eine Art Blacklist zu setzen und gar nicht erst für Loader Updates in Betracht zu ziehen.
 
Floppy Disk. Habs auf einer VMware VM getestet (die VM hat kein Floppy aktiv). Ich habe noch zwei andere Server. Da kann ich gleich auch mal noch schauen...


Ja würde in meinen Augen Sinn machen.
Da würde mich vor allem interessieren ob der Bug das Du keine Ausgabe ohne Argumente bekommst interessieren.
Es gab eine Diskussion Floppy Disk Support zu 13.0 rauszuwerfen, weil der eh nicht mehr sinnvoll verwendet werden kann. Ob das passiert ist oder noch wird, weiß ich nicht. Zumindest spricht nichts dagegen Floppy auf eine Art Blacklist zu setzen und gar nicht erst für Loader Updates in Betracht zu ziehen.
Ich denke ich habe eine zufriedenstellende Lösung gefunden bei der ich nichts blacklisten muss.

Hat hier jemand zufällig ein System mit MBR? Support einbauen wäre vertretbarer Aufwand, da gpart das ganz gut dokumentiert. Ich bräuchte nur den Output von gpart show und gpart backup vom entsprechenden Device.
 
Code:
root@work01:/usr/home/mr44er # gpart show
=>        63  1465149105  ada0  MBR  (699G)
          63           1        - free -  (512B)
          64  1465149104     1  freebsd  [active]  (699G)

=>         0  1465149104  ada0s1  BSD  (699G)
           0     4194304       1  freebsd-zfs  (2.0G)
     4194304     4194304       2  freebsd-swap  (2.0G)
     8388608  1456760496       4  freebsd-zfs  (695G)

root@work01:/usr/home/mr44er # gpart backup ada0
MBR 4
1 freebsd         64 1465149104   [active]
root@work01:/usr/home/mr44er # gpart backup ada0s1
BSD 8
1  freebsd-zfs          0    4194304 
2 freebsd-swap    4194304    4194304 
4  freebsd-zfs    8388608 1456760496 
root@work01:/usr/home/mr44er #
 
@mr44er Sehe ich das richtig, Du hast ZFS in ein bsdlabel isntalliert, das heißt die Kette wäre /boot/boot0 in ada0, /boot/boot1 in ada0s1, /boot/zfsboot in ada0s1a (mit dem dd Gefummel, das in zfsboot(8) beschrieben ist).

gpart(8) schweigt sich ja zu /boot/boot2 aus und schlägt statt /boot/boot1 die Installation von /boot/boot in ada0s1 vor. Da frage ich mich natürlich ob äquivalent dann das /boot/zfsboot nach ada0s1 gehört und das dd Gefrickel in zfsboot(8) einfach veraltet ist. Leider schweigt sich boot(8) zum Zweck von /boot/boot auch aus.
 
Ja, aber ich poste dennoch mal den Part aus der bsdinstall_log :)

DEBUG: /usr/libexec/bsdinstall/zfsboot: Last Chance!
DEBUG: zfs_create_boot: poolname=[zroot] vdev_type=[]
DEBUG: zfs_create_boot: Initializing temporary fstab(5) file...
DEBUG: zfs_create_boot: :> "/tmp/bsdinstall_etc/fstab"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: printf "$FSTAB_FMT" "# Device" "Mountpoint" "FStype" "Options" "Dump" "Pass#" >> "/tmp/bsdinstall_etc/fstab"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Expanding supplied size values...
DEBUG: zfs_create_boot: ZFSBOOT_SWAP_SIZE=[2g] swapsize=[2147483648]
DEBUG: zfs_create_boot: ZFSBOOT_BOOT_POOL_SIZE=[2g] bootsize=[2147483648]
DEBUG: zfs_create_boot: zpool destroy "zroot"
DEBUG: zfs_create_boot: retval=1 <output below>
cannot open 'zroot': no such pool
DEBUG: zfs_create_boot: Preparing disk partitions for ZFS pool...
DEBUG: zfs_create_boot: With 4K sectors...
DEBUG: zfs_create_boot: sysctl vfs.zfs.min_auto_ashift=12
DEBUG: zfs_create_boot: retval=0 <output below>
vfs.zfs.min_auto_ashift: 9 -> 12
DEBUG: zfs_create_diskpart: disk=[ada0] index=[0]
DEBUG: zfs_create_diskpart: Exporting ZFS pools...
DEBUG: zfs_create_diskpart: Detaching all GELI providers...
geli: Command 'status' not available; try 'load' first.
DEBUG: zfs_create_diskpart: Destroying all data/layouts on `ada0'...
DEBUG: zfs_create_diskpart: gpart destroy -F "ada0"
DEBUG: zfs_create_diskpart: retval=0 <output below>
ada0 destroyed
DEBUG: zfs_create_diskpart: graid delete "ada0"
DEBUG: zfs_create_diskpart: retval=1 <output below>
graid: Array 'ada0' not found.
DEBUG: zfs_create_diskpart: zpool labelclear -f "/dev/ada0"
DEBUG: zfs_create_diskpart: retval=1 <output below>
failed to read label from /dev/ada0
DEBUG: zfs_create_diskpart: gpart create -s gpt "ada0"
DEBUG: zfs_create_diskpart: retval=0 <output below>
ada0 created
DEBUG: zfs_create_diskpart: gpart destroy -F "ada0"
DEBUG: zfs_create_diskpart: retval=0 <output below>
ada0 destroyed
DEBUG: zfs_create_diskpart: Creating MBR layout...
DEBUG: zfs_create_diskpart: gpart create -s mbr "ada0"
DEBUG: zfs_create_diskpart: retval=0 <output below>
ada0 created
DEBUG: zfs_create_diskpart: gpart bootcode -b "/boot/mbr" "ada0"
DEBUG: zfs_create_diskpart: retval=0 <output below>
bootcode written to ada0
DEBUG: zfs_create_diskpart: gpart add -a 4k -t freebsd "ada0"
DEBUG: zfs_create_diskpart: retval=0 <output below>
ada0s1 added
DEBUG: zfs_create_diskpart: gpart set -a active -i 1 "ada0"
DEBUG: zfs_create_diskpart: retval=0 <output below>
active set on ada0s1
DEBUG: zfs_create_diskpart: zpool labelclear -f "/dev/ada0s1"
DEBUG: zfs_create_diskpart: retval=1 <output below>
failed to read label from /dev/ada0s1
DEBUG: zfs_create_diskpart: gpart destroy -F "ada0s1"
DEBUG: zfs_create_diskpart: retval=1 <output below>
gpart: arg0 'ada0s1': Invalid argument
DEBUG: zfs_create_diskpart: gpart create -s BSD "ada0s1"
DEBUG: zfs_create_diskpart: retval=0 <output below>
ada0s1 created
DEBUG: zfs_create_diskpart: gpart add -i 1 -t freebsd-zfs -s 2147483648b "ada0s1"
DEBUG: zfs_create_diskpart: retval=0 <output below>
ada0s1a added
DEBUG: zfs_create_diskpart: zpool labelclear -f "/dev/ada0s1a"
DEBUG: zfs_create_diskpart: retval=1 <output below>
failed to read label from /dev/ada0s1a
DEBUG: zfs_create_diskpart: geli detach -f "/dev/ada0s1d"
DEBUG: zfs_create_diskpart: retval=1 <output below>
geli: Class not found
DEBUG: zfs_create_diskpart: gpart add -a 4k -i 2 -t freebsd-swap -s 2147483648b "ada0s1"
DEBUG: zfs_create_diskpart: retval=0 <output below>
ada0s1b added
DEBUG: zfs_create_diskpart: zpool labelclear -f "/dev/ada0s1b"
DEBUG: zfs_create_diskpart: retval=1 <output below>
failed to read label from /dev/ada0s1b
DEBUG: zfs_create_diskpart: gpart add -a 4k -i 4 -t freebsd-zfs "ada0s1"
DEBUG: zfs_create_diskpart: retval=0 <output below>
ada0s1d added
DEBUG: zfs_create_diskpart: zpool labelclear -f "/dev/ada0s1d"
DEBUG: zfs_create_diskpart: retval=1 <output below>
failed to read label from /dev/ada0s1d
DEBUG: zfs_create_diskpart: dd if="/boot/zfsboot" of="/dev/ada0s1" count=1
DEBUG: zfs_create_diskpart: retval=0 <output below>
1+0 records in
1+0 records out
512 bytes transferred in 0.214886 secs (2383 bytes/sec)
DEBUG: zfs_create_diskpart: printf "$FSTAB_FMT" "/dev/ada0s1b" "none" "swap" "sw" "0" "0" >> "/tmp/bsdinstall_etc/fstab"
DEBUG: zfs_create_diskpart: retval=0 <no output>
DEBUG: zfs_create_boot: Setting up boot pool...
DEBUG: zfs_create_boot: For encrypted root disk...
DEBUG: zfs_create_boot: umount "/mnt"
DEBUG: zfs_create_boot: retval=1 <output below>
umount: /mnt: not a file system root directory
DEBUG: zfs_create_boot: mount -t tmpfs "none" "/mnt"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zpool create -o altroot=/mnt -m "/bootpool" -f "bootpool" ada0s1a
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: mkdir -p "/mnt/bootpool/boot"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: dd if="/dev/random" of="/mnt/bootpool/boot/encryption.key" bs=4096 count=1
DEBUG: zfs_create_boot: retval=0 <output below>
1+0 records in
1+0 records out
4096 bytes transferred in 0.000136 secs (30161559 bytes/sec)
DEBUG: zfs_create_boot: chmod go-wrx "/mnt/bootpool/boot/encryption.key"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: kldload aesni
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: f_dialog_max_size: dialog --print-maxsize = [MaxSize: 30, 80]
DEBUG: f_getvar: var=[height1] value=[8] r=0
DEBUG: f_getvar: var=[width1] value=[80] r=0
DEBUG: f_dialog_max_size: dialog --print-maxsize = [MaxSize: 30, 80]
DEBUG: f_getvar: var=[height2] value=[8] r=0
DEBUG: f_getvar: var=[width2] value=[54] r=0
DEBUG: f_dialog_max_size: dialog --print-maxsize = [MaxSize: 30, 80]
DEBUG: f_getvar: var=[height] value=[4] r=0
DEBUG: f_getvar: var=[width] value=[46] r=0
DEBUG: zfs_create_boot: geli init -b -B "/mnt/bootpool/boot/ada0s1d.eli" -e AES-XTS -J - -K "/mnt/bootpool/boot/encryption.key" -l 256 -s 4096 "ada0s1d"
DEBUG: zfs_create_boot: retval=0 <output below>

Metadata backup for provider ada0s1d can be found in /mnt/bootpool/boot/ada0s1d.eli
and can be restored with the following command:

# geli restore /mnt/bootpool/boot/ada0s1d.eli ada0s1d
DEBUG: zfs_create_boot: geli attach -j - -k "/mnt/bootpool/boot/encryption.key" "ada0s1d"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs unmount "bootpool"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: umount "/mnt"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Creating root pool...
DEBUG: zfs_create_boot: zpool create -o altroot=/mnt -O compress=lz4 -O atime=off -m none -f "zroot" ada0s1d.eli
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Creating ZFS datasets...
DEBUG: zfs_create_boot: zfs create -o mountpoint=none "zroot/ROOT"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs create -o mountpoint=/ "zroot/ROOT/default"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs create -o mountpoint=/tmp -o exec=on -o setuid=off "zroot/tmp"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs create -o mountpoint=/usr -o canmount=off "zroot/usr"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs create "zroot/usr/home"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs create -o setuid=off "zroot/usr/ports"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs create "zroot/usr/src"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs create -o mountpoint=/var -o canmount=off "zroot/var"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs create -o exec=off -o setuid=off "zroot/var/audit"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs create -o exec=off -o setuid=off "zroot/var/crash"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs create -o exec=off -o setuid=off "zroot/var/log"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs create -o atime=on "zroot/var/mail"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs create -o setuid=off "zroot/var/tmp"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Setting mountpoint for root of the pool...
DEBUG: zfs_create_boot: zfs set "mountpoint=/zroot" "zroot"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Modifying directory permissions...
DEBUG: zfs_create_boot: mkdir -p "/mnt/tmp"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: chmod 1777 "/mnt/tmp"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: mkdir -p "/mnt/var/tmp"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: chmod 1777 "/mnt/var/tmp"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Setting bootfs property...
DEBUG: zfs_create_boot: zpool set bootfs="zroot/ROOT/default" "zroot"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Temporarily exporting ZFS pool(s)...
DEBUG: zfs_create_boot: zpool export "zroot"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zpool export "bootpool"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Updating MBR boot loader on disks...
DEBUG: zfs_create_boot: dd if="/boot/zfsboot" of="/dev/ada0s1a" skip=1 seek=1024
DEBUG: zfs_create_boot: retval=0 <output below>
512+0 records in
512+0 records out
262144 bytes transferred in 0.070374 secs (3725018 bytes/sec)
DEBUG: zfs_create_boot: Re-importing ZFS pool(s)...
DEBUG: zfs_create_boot: zpool import -o altroot="/mnt" "zroot"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zpool import -o altroot="/mnt" -N "bootpool"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zfs mount "bootpool"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Creating /boot symlink for boot pool...
DEBUG: zfs_create_boot: ln -sf "bootpool/boot" "/mnt/boot"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Configuring zpool.cache for zroot...
DEBUG: zfs_create_boot: mkdir -p "/mnt/boot/zfs"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: zpool set cachefile="/mnt/boot/zfs/zpool.cache" "zroot"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: printf 'vfs.root.mountfrom="%s"\n' "zfs:zroot/ROOT/default" >> "/tmp/bsdinstall_boot/loader.conf.root"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Set canmount=noauto for the root of the pool...
DEBUG: zfs_create_boot: zfs set "canmount=noauto" "zroot/ROOT/default"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Configuring rc.conf(5)/loader.conf(5) additions...
DEBUG: zfs_create_boot: echo "zfs_enable=\"YES\"" >> "/tmp/bsdinstall_etc/rc.conf.zfs"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: echo "kern.geom.label.disk_ident.enable=\"0\"" >> "/tmp/bsdinstall_boot/loader.conf.zfs"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: echo "kern.geom.label.gptid.enable=\"0\"" >> "/tmp/bsdinstall_boot/loader.conf.zfs"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: echo "vfs.zfs.min_auto_ashift=12" >> "/tmp/bsdinstall_etc/sysctl.conf.zfs"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Configuring disk encryption...
DEBUG: zfs_create_boot: echo "aesni_load=\"YES\"" >> "/tmp/bsdinstall_boot/loader.conf.aesni"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: echo "geom_eli_load=\"YES\"" >> "/tmp/bsdinstall_boot/loader.conf.geli"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: printf 'geli_%s_keyfile0_load="%s"\n' ada0s1d YES >> "/tmp/bsdinstall_boot/loader.conf.ada0s1d"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: printf 'geli_%s_keyfile0_type="%s"\n' ada0s1d ada0s1d:geli_keyfile0 >> "/tmp/bsdinstall_boot/loader.conf.ada0s1d"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: printf 'geli_%s_keyfile0_name="%s"\n' ada0s1d "/boot/encryption.key" >> "/tmp/bsdinstall_boot/loader.conf.ada0s1d"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: Configuring zpool.cache for boot pool...
DEBUG: zfs_create_boot: zpool set cachefile="/mnt/boot/zfs/zpool.cache" "bootpool"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: echo "zpool_cache_load=\"YES\"" >> "/tmp/bsdinstall_boot/loader.conf.zfs"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: echo "zpool_cache_type=\"/boot/zfs/zpool.cache\"" >> "/tmp/bsdinstall_boot/loader.conf.zfs"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: echo "zpool_cache_name=\"/boot/zfs/zpool.cache\"" >> "/tmp/bsdinstall_boot/loader.conf.zfs"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: zfs_create_boot: echo "geom_eli_passphrase_prompt=\"YES\"" >> "/tmp/bsdinstall_boot/loader.conf.zfs"
DEBUG: zfs_create_boot: retval=0 <no output>
DEBUG: dialog.subr: DEBUG_SELF_INITIALIZE=[]
 
Sag das doch. Ich hab nicht die komplette Ausgabe kopiert. Somit alles OK. Wobei ich das nicht gut finde, wenn bei dem default Kommando einfach ein Error Code != 0 kommt.
 
Hmm, das ist bei gpart genau so. Mein Gedankengang ist dass es ein Fehler ist, wenn der Benutzer sich nicht klar ausdrückt. Deswegen habe ich auch keine Flags bei denen eines Priorität über ein anderes hat. Wenn sich etwas widerspricht, dann quitiere ich das mit einem Fehler.
 
Code:
root@freebsdpkg ~/tmp/bsd2/bsda2/src (git)-[master] # ./loaderupdate -Pa
NOTE: Cannot access device: fd0
NOTE: Cannot access device: cd0
fd0 bzw. cd0 würde ich ausblenden. Die Meldung verwirrt meiner Meinung mehr als sie nutzt.
Das sollte jetzt anders sein. Ich verwende jetzt die Schnittmenge aus gpart show und gstat -p um die Devices auszuwählen.

Code:
        -d, --demo        Print the actions that would be performed
Das würde ich nicht "--demo" nennen sondern: "dry-run".
Das habe ich auch umbenannt.
 
So. Habe das jetzt auch mal getestet. Die Ausgabe bei meinem Thinkpad x220 sieht so aus:
Code:
src/loaderupdate -Pa                                                                        :(
Boot Environment
----------------
destdir:                /
ostype:                 FreeBSD
kernel version:         FreeBSD 12.2-RELEASE r366954 GENERIC
kernel arch:            amd64
protective MBR:         /boot/pmbr
freebsd-boot loader:    /boot/gptzfsboot
EFI loader:             /boot/loader.efi

Device ada0
-----------
    install:            /boot/loader.efi > ada0p2:/efi/FreeBSD/bootamd64.efi
    EFI boot entry:     ada0/amd64/FreeBSD 12.2-RELEASE r366954 GENERIC

Soweit sieht das gut aus. Ich boote FreeBSD mittels rEFInd, daher das etwas unkonventionelle efi Verzeichnis.
Allerdings finde ich es seltsam, dass das Booter als "bootamd64.efi" kopiert wird und nicht als "bootx64.efi".
 
Soweit sieht das gut aus. Ich boote FreeBSD mittels rEFInd, daher das etwas unkonventionelle efi Verzeichnis.
Allerdings finde ich es seltsam, dass das Booter als "bootamd64.efi" kopiert wird und nicht als "bootx64.efi".
Das bootx64.efi ist der Name den Windows verwendet. Wenn das UEFI keine gültigen Einträge hat schaut es deshalb in der Regel da hin. Und diverse Installer, FreeBSD inklusive, sparen sich den Eintrag zu machen und installieren ihren Loader einfach da hin.
 
Wenn FreeBSD das auch macht, wäre es denn dann nicht sinnvoll, wenn Dein Script das auch macht?
 
Zurück
Oben