Readonly /usr is not a supported or recomended configuration.

This is adding a lot of scripting that we don't everyone to run.

I disagree strongly with this direction of OpenBSD having undocumented
(undocumentable?) little behaviours that allow root to configure their
machine in novel non-default ways and it will still work because there
piles of of trashy shell scripts which cope with the weird situations,
which under 1% of users will use.

I disagree with this flexiblity being a strength, I think it is very
fragile when we encourage users to do bizzare things to their machines
which they (also) will not include in future bug reports.

Klemens Nanni <[email protected]> wrote:

> On Tue, Nov 08, 2022 at 11:10:19AM +0000, Klemens Nanni wrote:
> > More read-only filesystems mean less fsck during boot after crashes.
> > Especially on crappy machines like the Pinebook Poop, I keep /usr
> > read-only and run with this diff so I still get a relinked kernel.
> > 
> > rc's reorder_libs() already does the same remount dance, but for
> > multiple directories/filesystems.
> > 
> > My diff works as expected with read-write and read-only /usr as well as
> > interrupting /usr/libexec/reorder_kernel runs with ^C, i.e. a failed run
> > will correctly mount /usr ro again if it was ro before the run.
> > 
> > Feedback? OK?
> 
> Ping.
> 
> Index: libexec/reorder_kernel/reorder_kernel.sh
> ===================================================================
> RCS file: /cvs/src/libexec/reorder_kernel/reorder_kernel.sh,v
> retrieving revision 1.13
> diff -u -p -r1.13 reorder_kernel.sh
> --- libexec/reorder_kernel/reorder_kernel.sh  7 Nov 2022 15:55:56 -0000       
> 1.13
> +++ libexec/reorder_kernel/reorder_kernel.sh  14 Nov 2022 19:33:25 -0000
> @@ -27,13 +27,32 @@ LOGFILE=$KERNEL_DIR/$KERNEL/relink.log
>  PROGNAME=${0##*/}
>  SHA256=/var/db/kernel.SHA256
>  
> -# Silently skip if on a NFS mounted filesystem.
> -df -t nonfs $KERNEL_DIR >/dev/null 2>&1
> +# Silently skip if on NFS, otherwise remount the filesystem read-write.
> +DEV=$(df -t ffs $KERNEL_DIR 2>/dev/null | awk 'NR == 2 { print $1 }')
> +MP=$(mount | grep ^$DEV)
> +RO=false
> +if [[ $MP == *read-only* ]]; then
> +     MP=${MP%% *}
> +     mount -u -w $MP
> +     RO=true
> +fi
> +
> +restore_mount() {
> +     if $RO; then
> +             # Close the logfile to unbusy $MP by switching back to console.
> +             exec 1>/dev/console
> +             exec 2>&1
> +             mount -u -r $MP
> +     fi
> +}
>  
>  # Install trap handlers to inform about success or failure via syslog.
>  ERRMSG='failed'
> -trap 'trap - EXIT; logger -st $PROGNAME "$ERRMSG" >/dev/console 2>&1' ERR
> -trap 'logger -t $PROGNAME "kernel relinking done"' EXIT
> +trap 'trap - EXIT
> +     logger -st $PROGNAME "$ERRMSG" 2>/dev/console
> +     restore_mount' ERR
> +trap 'logger -t $PROGNAME "kernel relinking done"
> +     restore_mount' EXIT
>  
>  # Create kernel compile dir and redirect stdout/stderr to a logfile.
>  mkdir -m 700 -p $KERNEL_DIR/$KERNEL
> 

Reply via email to