Hello, I use read only /usr also, I don't like a script changing mount options without a warning. If it's read-only reorder_kernel should fail. I just put a symlink from /usr/share/relink to /var/relink and everything works fine... With mount_mfs we could have a temporary directory but where has gone mfs ?
Le mar. 8 nov. 2022 à 12:11, Klemens Nanni <[email protected]> a écrit : > 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? > > Index: 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 > --- reorder_kernel.sh 7 Nov 2022 15:55:56 -0000 1.13 > +++ reorder_kernel.sh 8 Nov 2022 11:02:42 -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 nonfs $KERNEL_DIR 2>/dev/null | awk 'NR == 2 { print $1 }') > +MP=$(mount -t ffs | 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 > > -- Thomas de Grivel https://www.kmx.io
