Date: Sat, 7 Sep 2024 09:36:40 +0100 From: Sad Clouds <cryintothebluesky@gmail.com> To: Dag-Erling =?ISO-8859-1?Q?Sm=F8rgrav?= <des@FreeBSD.org> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 06 Sep 2024 21:01:59 +0200 Dag-Erling Sm=F8rgrav <des@FreeBSD.org> wrote: > Sad Clouds <cryintothebluesky@gmail.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20240907093640.7609a9739e757c658357451b>