summaryrefslogtreecommitdiff
path: root/package/base-files/files/init.d/fs
blob: 55e2c34491846ad49602ff8c5baaee1c9c7719dd (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
#INIT 10
[[ $1 = autostart ]] || exit 0

# activate swap
[ -x /sbin/swapon ] && {
	grep swap /etc/fstab >/dev/null 2>&1
	if [ $? -eq 0 ];then
		logger -t 'SWAP' "Activating swap"
		swapon -a
	fi
}

# activate any logical volumes
[ -x /usr/sbin/lvm ] && {
	logger -t 'LVM' "Activating LVM volumes"
	lvm vgscan
	lvm vgchange -ay
}

# mount local filesystems
fstypes="ext2 ext3 ext4 xfs vfat ntfs ntfs-3g"
for fs in $fstypes; do
	procfs=$fs
	if [ $fs = "ntfs-3g" ];then
		procfs=fuse
	fi
	disks=$(grep -v "^#" /etc/fstab|grep "${fs}[[:blank:]]"|awk '{ print $1 }')
	for disk in $disks; do
		logger -t 'Filesystem' "Found $disk with filesystem $fs"
		mnt=$(grep -v "^#" /etc/fstab|grep "${disk}[[:blank:]]"|awk '{ print $2 }')
		grep $procfs /proc/filesystems >/dev/null 2>&1
		if [ $? -eq 0 ];then
			[ -x /usr/sbin/fsck.$fs ] && {
				logger -t 'Filesystem' "checking $fs filesystem on $disk"
				fsck -p $disk >/dev/null 2>&1
			}
			mkdir -p $mnt > /dev/null 2>&1
			if [ -b $disk ]; then
				logger -t 'Filesystem' "Mounting $disk to $mnt"
				mount $disk
			else
				logger -t 'Filesystem' "Skipping mounting $disk, device file missing"
			fi
		else
			logger -t 'Filesystem' "No $procfs filesystem in kernel"
		fi
	done
done
exit 0