BLog

ImprintImpressum
PrivacyDatenschutz
DisclaimerHaftung
Downloads 

Tracking FreeBSD CURRENT installations from Snapshots

freebsd-update(8) is limited to RELEASE installations, and therefore updating CURRENT is somewhat demanding. The FreeBSD Handbook suggests Synchronizing (the) Source and then Rebuilding (the) World. Certainly, this is feasible on fast hardware, however this is not a viable option on the various ARM devices.

For example, compilation of the devel/subversion port from sources takes hours on my BeagleBone Black - I need it with SASL support. Compiling the latest lldb-6.0.0 (svn) takes more than 48 hours, and I do this only because with that one, single stepping through my code on the BBB is possible. Now imagine building world on the BBB - I didn’t even try it. Instead I demonstrate here a method, which I found to be much less painful.

  1. Place the following content into the file /usr/local/etc/pkg/repos/FreeBSD.conf:
    FreeBSD: {
      url: "pkg+https://pkg.FreeBSD.org/${ABI}/latest",
    }
  2. Install sysutils/clone:
    pkg install clone
  3. Back-up the working installation

    Technically this is not exactly necessary, however, I learned the hard way that there is no guarantee that CURRENT snapshots do work: https://lists.freebsd.org/pipermail/freebsd-arm/2017-February/015730.html.

    In my network I got a FreeBSD file server wich exports a NFSv4 share for storing the BBB backups into /bbb/images. On this one I create an empty image having enough space for receiving the whole content of the working UFS partition on the BBB.

    On the FreeBSD file server:

    cd /bbb/images
    dd if=/dev/zero of=bbb-2018-07-07.img bs=1m count=4096

    On the BeagleBone Black:

    mount_nfs -o noatime,readahead=4,intr,soft,nfsv4 server:/bbb/images /mnt
    mdconfig -a -u 0 -t vnode -f /mnt/bbb-2018-07-07.img
    bsdlabel -w md0 auto
    newfs -nU /dev/md0a
    tunefs -a enable -m 0 /dev/md0a
    mount -o noatime /dev/md0a /media
    
    clone -c rwoff / /media
    
    umount /media
    mdconfig -d -u 0
    umount /mnt
  4. Update the working FreeBSD installation using the latest Snapshot

    On the FreeBSD file server:

    cd /bbb/images
    fetch ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/arm/armv7/ISO-IMAGES/12.0/FreeBSD-12.0-CURRENT-arm-armv7-BEAGLEBONE-20180628-r335760.img.xz
    xz -d FreeBSD-12.0-CURRENT-arm-armv7-BEAGLEBONE-20180628-r335760.img.xz

    I utilize the synchronization mode (-s flag) of clone(1) excluding my customizations from the cloning operation by the way of the -x flag. Anyway, /dev, /media, /mnt, /proc, /root, /tmp, /usr/local, /usr/home and /var would be left untouched by the following updating procedure.

    Shutdown the BeagleBone Black, remove the SD card and start it from the internal MMC, then insert the SD card again. The UFS startup volume on my FreeBSD-12-BBB-SD-card is named /dev/ufs/SYSTEM, and the boot loader U-Boot is on /dev/label/BOOT. Important You need to verify the volume names of your setup before continuing.

    Mount the snapshot image on /media:

    mount_nfs -o noatime,readahead=4,intr,soft,nfsv4 server:/tm/images /mnt
    mdconfig -a -u 0 -t vnode -f /mnt/FreeBSD-12.0-CURRENT-arm-armv7-BEAGLEBONE-20180628-r335760.img
    mount -o noatime,ro /dev/md0s2a /media
    Check the file system of the UFS volume on the SD card and mount it on /back:
    fsck_ufs -fy /dev/ufs/SYSTEM
    mkdir -p /back
    mount -o noatime /dev/ufs/SYSTEM /back
    setenv DST /back
    Clone the user-invariant system files from the mounted snapshot image to the mounted UFS volume of the SD card:
    clone -s -x $DST/usr/home:$DST/usr/local:$DST/usr/ports:$DST/usr/obj:$DST/usr/src /media/usr $DST/usr
    clone -s /media/sbin $DST/sbin
    clone -s /media/rescue $DST/rescue
    clone -s /media/bin $DST/bin
    clone -s /media/libexec $DST/libexec
    clone -s /media/lib $DST/lib
    clone -s -x $DST/etc/crontab:$DST/etc/csh.login:$DST/etc/exports:$DST/etc/fstab:$DST/etc/group:$DST/etc/localtime:$DST/etc/master.passwd:$DST/etc/motd:$DST/etc/ntp.conf:$DST/etc/passwd:$DST/etc/pwd.db:$DST/etc/rc.conf:$DST/etc/rc.local:$DST/etc/resolv.conf:$DST/etc/spwd.db:$DST/etc/ssh:$DST/etc/ssl:$DST/etc/sysctl.conf:$DST/etc/unbound /media/etc $DST/etc
    clone -s -x $DST/boot/dtbo:$DST/boot/loader.conf:$DST/boot:modules:$DST/boot/msdos /media/boot $DST/boot
    
    umount /back
    umount /media
  5. Update the U-Boot system on the boot loader volume of the SD card, here /dev/label/BOOT:
    mount_msdosfs -o noatime /dev/md0s1 /media
    mount_msdosfs -o noatime /dev/label/BOOT /back
    
    cp -p /media/* /back/
    
    umount /back
    umount /media
    mdconfig -d -u 0
    umount /mnt
  6. Restart the system. It should now come up with the updated FreeBSD:
    FreeBSD 12.0-CURRENT (GENERIC) #0 r335760: Thu Jun 28 17:21:10 UTC 2018

Keywords: BeagleBone, FreeBSD, Tracking-Current

Copyright © Dr. Rolf Jansen - 2018-07-07 17:30:31

PROMOTION