]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame_incremental - src/initscripts/init.d/checkfstab
checkfstab: dracut doesn't set CMDLINE.
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / checkfstab
... / ...
CommitLineData
1#!/bin/sh
2########################################################################
3# Begin $rc_base/init.d/checkfstab
4#
5# Description : Check and repair fstab if the drivename has changed
6#
7# Authors : Arne Fitzenreiter - arne_f@ipfire.org
8#
9# Version : 00.00
10#
11# Notes :
12#
13########################################################################
14
15. /etc/sysconfig/rc
16. ${rc_functions}
17
18case "${1}" in
19 start)
20 boot_mesg "Checking fstab bootdevice ..."
21 read CMDLINE < /proc/cmdline
22 ROOTPOS=`expr index "$CMDLINE" root=`
23 NEWROOT=`echo ${CMDLINE:$ROOTPOS} | cut -d"=" -f2 | cut -d" " -f1`;
24 OLDBOOT=`cat /etc/fstab | grep -m1 "/boot" | cut -d" " -f1 | cut -f1`;
25 OLDDRV=${OLDBOOT::`expr length $OLDBOOT`-1}
26 NEWDRV=${NEWROOT::`expr length $NEWROOT`-1}
27 if [ "$OLDDRV" == "$NEWDRV" ]; then
28 echo_ok;
29 exit 0;
30 fi
31 echo_failure;
32 boot_mesg "Warning! Bootdrive not match with fstab!"
33 boot_mesg
34 boot_mesg "Bootdrive: $NEWDRV"
35 boot_mesg "fstab-entry: $OLDDRV"
36 boot_mesg
37 boot_mesg "Attempt to repair it ..."
38 mount -o remount,rw /
39 sed -i -e "s|$OLDDRV|$NEWDRV|g" /etc/fstab
40 mount /boot
41 sed -i -e "s|$OLDDRV|$NEWDRV|g" /boot/grub/grub.conf
42 umount /boot
43 echo_ok;
44 exit 0;
45 ;;
46 *)
47 echo "Usage: ${0} {start}"
48 exit 1
49 ;;
50esac
51
52# End $rc_base/init.d/checkfstab