From nobody Sat Sep 7 08:36:40 2024 X-Original-To: freebsd-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 4X15zx65QJz5V5Xm for ; Sat, 07 Sep 2024 08:36:45 +0000 (UTC) (envelope-from cryintothebluesky@gmail.com) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X15zx3t5Cz4MNc; Sat, 7 Sep 2024 08:36:45 +0000 (UTC) (envelope-from cryintothebluesky@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-374c326c638so1931854f8f.2; Sat, 07 Sep 2024 01:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725698202; x=1726303002; darn=freebsd.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=I0DT95i/6tFyPcobzdg+afm/oJypZEsxQiZMFV//B8A=; b=hyHCtIffMpGnSpVD41OkUIEONozm3HJkTSDPXBTksvRNR4np6KIsfyVlJ86lxTPngv faqNIz0MrRX/QG+ZuFHa9UbZ+wRqlfcHiql01B8DiR1LYCrcB7Nr8zHpdMtguOSVgNuI YFFPCYRUh8L9YsplvYhCsBi1a1hXkqP1uQFMCzaUvv4970eV8TN8M8msy9msmZWbTCxf YoPx+ciVI7ryHHqQO3Q/BPYChJEDfAUocOfP5PqR/j7hwERovCTgqCTmsUxsG5GhgUyD mjOZ5bGjZ8514LmdeALfcbyBu4wF285OO7omIo3OCOgeDc6pZBwusSsVCmC3DCsuyDRj 9YDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725698202; x=1726303002; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I0DT95i/6tFyPcobzdg+afm/oJypZEsxQiZMFV//B8A=; b=NQ0Pp5/RrsmLuPE99uvhkyjqYv9FZZ2ufNb8PSUgsYeqU+668F6H7Mr9Ixg1Lup7LE UZpl6WdlLaf3Ja7TQ7ZxJy+UxjTOeGVIQE9Lgx8aup+OPHTjQosYx35tZGYkYv5bfNdg mnEK2IoTgyWay4rQr4YQPfRASBv3zwF+qNvNZNUqDppc7E9sfe3avj/5OTEw7Bx1MZOc 9FE99cfBcTh+UNMe+Y3GRAot4SI9gkyhC5hdB6ZLxQBHSmnV1l1aSXHXHAAmwhlm5bJx pRZiJYR7z7WYPAoCoxps3VNGdhoZWyvK/cNilVB+Z6/coLMAKckpuBi5gtU2Q6vFLZrn bwhQ== X-Gm-Message-State: AOJu0Yz3EPPixihKRgMvDc6aBmCNmhuaraMDgdinh0FVdWQF2pKTgb2Q 8igdLQjhK5M87LvwgVRMHYUXeQ/w9ddMMySGAof4z6uiQZQjfpfvK/DUsg== X-Google-Smtp-Source: AGHT+IEMOf/sWci6HjsBITB1GbqWfMNUlL3T+0eMG42n04hWVc4fymwgEW5zK8roqDeIdvkBlDgM+w== X-Received: by 2002:adf:f610:0:b0:371:82ec:206f with SMTP id ffacd0b85a97d-378895c71b8mr3488732f8f.16.1725698201444; Sat, 07 Sep 2024 01:36:41 -0700 (PDT) Received: from z600.home.lan (41.129.159.143.dyn.plus.net. [143.159.129.41]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956654f4sm864018f8f.43.2024.09.07.01.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Sep 2024 01:36:41 -0700 (PDT) Date: Sat, 7 Sep 2024 09:36:40 +0100 From: Sad Clouds To: Dag-Erling =?ISO-8859-1?Q?Sm=F8rgrav?= Cc: freebsd-questions@FreeBSD.org Subject: Re: How to upgrade custom release Message-Id: <20240907093640.7609a9739e757c658357451b@gmail.com> In-Reply-To: <86o7501u8o.fsf@ltc.des.dev> References: <20240905190801.990f63880ba706a56a065a34@gmail.com> <86o7501u8o.fsf@ltc.des.dev> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: freebsd-questions@freebsd.org Sender: owner-freebsd-questions@FreeBSD.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Queue-Id: 4X15zx3t5Cz4MNc On Fri, 06 Sep 2024 21:01:59 +0200 Dag-Erling Sm=F8rgrav wrote: > Sad Clouds writes: > > Hello, could anyone please suggest a good way to upgrade FreeBSD base > > system which was built with custom options in src.conf. >=20 > https://wiki.freebsd.org/PkgBase >=20 Hello, I've looked at this page before, however at the bottom there is a long list of "unresolved issues" which is understandable, since this is still work in progress. As you mentioned, there are some rough edges, hence I've been looking for a simpler solution and then some time later I can try pkgbase. The pkgbase wiki page mentions .pkgsave files, as it does not appear to support merging of /etc files. Manually restoring or merging those .pkgsave files is not ideal. Maybe etcupdate is the recommended solution here? Or maybe pkgbase will implement something similar at a later stage? I think I almost managed to figure it out. I specifically avoid using ZFS, so designed a solution around UFS: 1) Create partitions during first install gpart destroy -F da0 gpart create -s gpt da0 gpart add -t efi -l "efi" -a 1M -s 64M da0 gpart add -t freebsd-ufs -l "root" -a 1M -s 32G da0 gpart add -t freebsd-ufs -l "root-rescue" -a 1M -s 4G da0 ... etc The root-rescue is a backup partition with FreeBSD install used to perform upgrades and to recover damaged data from UFS snapshots 2) Boot into root-rescue in order to upgrade root Boot rescue from loader when bootloader OK on root partition: OK lsdev OK set currdev=3Ddisk0p3 OK boot Boot rescue from loader when bootloader damaged on root partition: Press Esc before bootloader is loaded, then boot: 0:ad(0p3)/boot/loader Mount root on /mnt and var on /mnt/var 3) Create UFS snapshots before running upgrades snapshot=3D"/mnt/.snap/latest" mksnap_ffs ${snapshot}.tmp && chflags nodump ${snapshot}.tmp mv ${snapshot}.tmp ${snapshot} ls -lho /mnt/.snap/ If upgrade goes wrong, snapshot can be restored with dump: snapshot=3D"/mnt/.snap/latest" ufsdir=3D"/mnt" rm -rf ${ufsdir}/*; chflags -R 0 ${ufsdir}/*; rm -rf ${ufsdir}/*; (cd ${ufsdir} && dump -0 -a -h 0 -C 16 -b 64 -f - ${snapshot} | restore -xu= vf -) rm -f ${snapshot}.tmp 4) Upgrade base binaries There is no postinstall script to delete obsolete files, so remove all existing binaries and extract new ones. Small custom script is required for this to avoid mistakes. Run "rm -rf" on binaries under /mnt, i.e. bin, sbin, lib, etc. Extract new kernel and base under /mnt, excluding files in like etc, root, var and a few others. 5) Run etcupdate # View current modifications in /etc before update etcupdate -d /mnt/var/db/etcupdate -D /mnt/etc diff # Extract etcupdate tree from new base.txz tar -xpf base.txz ./var/db/etcupdate/current # Create etcupdate archive of new files to merge tar -C ./var/db/etcupdate/current -jcf etcupdate.tar.bz2 ./ rm -rf ./var # Run etcupdate merging new files etcupdate -d /mnt/var/db/etcupdate -D /mnt/etc -F -t etcupdate.tar.bz2