summaryrefslogtreecommitdiff
path: root/package/base-files/src/etc/init.d/fs
blob: 8bde402ecba304cdc8230c95867d3998b69a81f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
#INIT 20
[[ $1 = autostart ]] || exit 0

# activate swap
[ -x /sbin/swapon ] && { swapon -a; }

# activate any logical volumes
[ -x /usr/sbin/lvm ] && { lvm vgscan; lvm vgchange -ay; }

rootdisk=$(readlink /dev/root)
# strip partitions (f.e. mmcblk0p2, sda2, ..)
rootdisk=${rootdisk%p*}
rootdisk=${rootdisk%[1-9]}
rootparts=$(grep "^/dev/${rootdisk}" /etc/fstab|awk '{ print $1 }')

for part in $rootparts; do
	fstype=$(grep "^$part" /etc/fstab|awk '{ print $3 }')
	mnt=$(grep "^$part" /etc/fstab|awk '{ print $2 }')
	[ -x /usr/sbin/fsck.$fstype ] && {
		logger -t fs -s "Checking $fstype filesystem on $part"
		fsck -p -t $fstype $part
	}
	grep $fstype /proc/filesystems >/dev/null 2>&1
	if [ $? -eq 0 ];then
		mount $mnt
	else
		logger -t fs -s "Filesystem $fstype not in kernel"
		exit 1
	fi
done
exit 0