#!/bin/sh ######################################################################## # Begin $rc_base/init.d/checkfstab # # Description : Check and repair fstab if the drivename has changed # # Authors : Arne Fitzenreiter - arne_f@ipfire.org # # Version : 00.00 # # Notes : # ######################################################################## . /etc/sysconfig/rc . ${rc_functions} case "${1}" in start) boot_mesg "Checking fstab bootdevice ..." ROOTPOS=`expr index "$CMDLINE" root=` NEWROOT=`echo ${CMDLINE:$ROOTPOS} | cut -d"=" -f2 | cut -d" " -f1`; OLDBOOT=`cat /etc/fstab | grep -m1 "/boot" | cut -d" " -f1 | cut -f1`; OLDDRV=${OLDBOOT::`expr length $OLDBOOT`-1} NEWDRV=${NEWROOT::`expr length $NEWROOT`-1} if [ "$OLDDRV" == "$NEWDRV" ]; then echo_ok; exit 0; fi echo_failure; boot_mesg "Warning! Bootdrive not match with fstab!" boot_mesg boot_mesg "Bootdrive: $NEWDRV" boot_mesg "fstab-entry: $OLDDRV" boot_mesg boot_mesg "Attempt to repair it ..." mount -o remount,rw / sed -i -e "s|$OLDDRV|$NEWDRV|g" /etc/fstab mount /boot sed -i -e "s|$OLDDRV|$NEWDRV|g" /boot/grub/grub.conf umount /boot echo_ok; exit 0; ;; *) echo "Usage: ${0} {start}" exit 1 ;; esac # End $rc_base/init.d/checkfstab