From nobody Mon Aug 1 07:40:00 2022 X-Original-To: questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Lx95G0G9Bz4Xq4M for ; Mon, 1 Aug 2022 07:40:18 +0000 (UTC) (envelope-from dpchrist@holgerdanske.com) Received: from holgerdanske.com (holgerdanske.com [184.105.128.27]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "holgerdanske.com", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Lx95D6bM4z3PTW for ; Mon, 1 Aug 2022 07:40:16 +0000 (UTC) (envelope-from dpchrist@holgerdanske.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=holgerdanske.com; s=nov-20210719-112354; t=1659339608; bh=k16sdHN3WbWCwB3ziIa0qlXmK58Qt3pt1v5pOgEQgnw=; h=Received:Message-ID:Date:MIME-Version:User-Agent:Subject: Content-Language:To:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; b=19Up/D9/1aDOvcYnpZAckhH2oNoyD/78DzahzQj2NeLTm2Ny5mnBuTGecyVlQukCO KpgHeAWPOzBJZZla7rc3PlvjJi28SLuAr8O1X+uDSsE3SYiQ0Tzegn60OoJyZ/Ggzf ws2F6cDw+1RbE2dAm/xO0Jdju0J+R5ydnqbDyL/sxunMWCx1EpiNcrjvSsTcxMOHne a6IiamH/bVaoL+MhE/UaF7AFJB3LO3ZDlhRw/dKb6uKRcrUA6KOrbTsHgux8KFKWRL Ea6P1ZCV2i+wLPJTE3ChFZcZQuANQ7VGqOVBP+9NLycZCDc/jhmn1sF6yoed1uD/4T gB6qdz/oSSv/aj1W4OkazcLKJ7NXrlDAFTUrpHqi7FCViP1VjXCCkhXp4oHRmOQUf/ fG88YRsKxc3DYtuZlJGsEhoK8T9qDfgO0V85Zz+JXwGNbBBmMYqJqoeiFVMzlEFITB /9xdrWhgfoz5zjR73KmufzkmF8NbJSCT/nZuQ/CXqbnOCc4hUrp2lNbTLOBih78ucj UBqNB/LWOq1QH/JYLxgJ6cfVzZ73sVrVSWKf+obEvczJpNuUrKmI8YmBorPyKkf+P/ iNrbFi+oMHk8152coL98gF07UtL8uvze4vCw5ZNazPc0PesdRsoo8LkDjcomC3dTOP V20/APpeCIrqc5V1Uy8Ob6Tg= Received: from 99.100.19.101 (99-100-19-101.lightspeed.frokca.sbcglobal.net [99.100.19.101]) by holgerdanske.com with ESMTPSA (TLS_AES_128_GCM_SHA256:TLSv1.3:Kx=any:Au=any:Enc=AESGCM(128):Mac=AEAD) (SMTP-AUTH username dpchrist@holgerdanske.com, mechanism PLAIN) for ; Mon, 1 Aug 2022 00:40:08 -0700 Message-ID: Date: Mon, 1 Aug 2022 00:40:00 -0700 List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: zpool upgrade "don't forget to update boot code" Content-Language: en-US To: questions@freebsd.org References: From: David Christensen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4Lx95D6bM4z3PTW X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=holgerdanske.com header.s=nov-20210719-112354 header.b="19Up/D9/"; dmarc=pass (policy=none) header.from=holgerdanske.com; spf=pass (mx1.freebsd.org: domain of dpchrist@holgerdanske.com designates 184.105.128.27 as permitted sender) smtp.mailfrom=dpchrist@holgerdanske.com X-Spamd-Result: default: False [-4.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; DMARC_POLICY_ALLOW(-0.50)[holgerdanske.com,none]; R_SPF_ALLOW(-0.20)[+a]; R_DKIM_ALLOW(-0.20)[holgerdanske.com:s=nov-20210719-112354]; MIME_GOOD(-0.10)[text/plain]; DKIM_TRACE(0.00)[holgerdanske.com:+]; ASN(0.00)[asn:6939, ipnet:184.104.0.0/15, country:US]; MLMMJ_DEST(0.00)[questions@freebsd.org]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; TO_DN_NONE(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[questions@freebsd.org]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On 7/31/22 02:23, David Christensen wrote: > FreeBSD-12.1-RELEASE-amd64-memstick.img > Partitioning Auto (ZFS) > Pool Type/Disks stripe: 1 disk > ada0 > Pool Name soho2_zroot > Force 4K Sectors YES > Encrypt Disks YES > Partition Scheme MBR (BIOS) > Swap Size 2g > Mirror Swap YES > Encrypt Swap YES > >>> Install Proceed with installation > Encryption passphrase ******* > # gpart show -p ada0 > => 63 117231345 ada0 MBR (56G) > 63 1985 - free - (993K) > 2048 29360128 ada0s1 freebsd [active] (14G) > > # gpart show -p ada0s1 > => 0 29360128 ada0s1 BSD (14G) > 0 4194304 ada0s1a freebsd-zfs (2.0G) > 4194304 4194304 ada0s1b freebsd-swap (2.0G) > 8388608 20971520 ada0s1d freebsd-zfs (10G) > # zpool upgrade soho2_zroot > This system supports ZFS pool feature flags. > > Enabled the following features on 'soho2_zroot': > allocation_classes > > If you boot from pool 'soho2_zroot', don't forget to update boot code. > Assuming you use GPT partitioning and da0 is your boot disk > the following command will do it: > > gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0 STFW here is information about MBR: https://en.wikipedia.org/wiki/Master_boot_record Crawling a recent FreeBSD installer (FreeBSD12.3-RELEASE-amd64-memstick) /usr/libexec/bsdinstall/zfsboot to see how it sets up boot code for MBR partitioning, ZFS boot, and encrypted ZFS root: DD_WITH_OPTIONS='dd if="%s" of="%s" %s' GPART_BOOTCODE='gpart bootcode -b "%s" "%s"' zfs_create_diskpart() { case "$ZFSBOOT_PARTITION_SCHEME" in MBR) f_dprintf "$funcname: Creating MBR layout..." # # 1. Create MBR layout (no labels) # f_eval_catch $funcname gpart "$GPART_BOOTCODE" /boot/mbr \ $disk || return $FAILURE AIUI the above runs the following command: # gpart bootcode -b /boot/mbr ada0 So, gpart(8) installed the FreeBSD MBR partitioning scheme bootloader into the OS drive master boot record bootstrap code area. AIUI this fulfills FreeBSD boot process stage 0. Looking at /boot/mbr, this file is before my installation date. So, I do not need to update: # ll /boot/mbr -r--r--r-- 1 root wheel 512 2019/10/31 21:29:42 /boot/mbr Continuing the crawl: # # 5. Add freebsd-zfs partition for zroot # f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ /boot/zfsboot /dev/${disk}s1 count=1 || return $FAILURE ;; esac # $ZFSBOOT_PARTITION_SCHEME AIUI the above runs the following command: # dd if=/boot/zfsboot of=/dev/ada0s1 count=1 So, dd(1) installed the first block of /boot/zfsboot into the first block of ada0s1. AIUI this fulfills FreeBSD boot process stage 1. Looking at /boot/zfsboot, this file is after my installation date. # ll /boot/zfsboot -r--r--r-- 1 root wheel 262656 2022/01/30 20:51:01 /boot/zfsboot Comparing, they are identical. So, I do not need to update: 2022-07-31 23:45:51 toor@f3 ~ # cmp -n 512 /boot/zfsboot /dev/ada0s1 2022-07-31 23:46:48 toor@f3 ~ # echo $? 0 Continuing the crawl: case "$ZFSBOOT_PARTITION_SCHEME" in MBR) f_dprintf "$funcname: Creating MBR layout..." # NB: zpool will use s1a (no labels) bootpart=s1a swappart=s1b targetpart=s1d mbrindex=4 esac # $ZFSBOOT_PARTITION_SCHEME zfs_create_boot() { # 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 "convenient hole" after # the ZFS internal metadata for disk in $disks; do f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ /boot/zfsboot /dev/$disk$bootpart \ "skip=1 seek=1024" || return $FAILURE done AIUI the above runs the following command: # dd if=/boot/zfsboot of=/dev/ada0s1a skip=1 seek=1024 So, dd(1) installed the second and remaining blocks of /boot/zfsboot into ada0s1a starting at byte offset 1024. AIUI this fulfills FreeBSD boot process stage 2. Comparing, they differ: 2022-07-31 23:59:07 toor@f3 ~ # cmp -i 512:1024 /boot/zfsboot /dev/ada0s1a /boot/zfsboot /dev/ada0s1a differ: char 1, line 1 2022-08-01 00:04:22 toor@f3 ~ # hexdump -C -s 512 -n 16 /boot/zfsboot 00000200 eb 0e 42 54 58 01 02 80 f6 0f b0 06 00 20 00 00 |..BTX........ ..| 00000200 eb 0e 42 54 58 01 02 80 f6 0f b0 06 00 20 00 00 |..BTX........ ..| 00000210 2022-08-01 00:05:02 toor@f3 ~ # hexdump -C -s 1024 -n 16 /dev/ada0s1a 00000400 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000400 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000410 So, to "update boot code" after upgrading my ZFS boot and root pools, I need to repeat the stage 2 step performed by the FreeBSD installer for my configuration: # dd if=/boot/zfsboot of=/dev/ada0s1a skip=1 seek=1024 Can anybody confirm the above analysis and conclusion before I try it? David