summaryrefslogtreecommitdiff
path: root/package/base-files/files/init.d/fs
diff options
context:
space:
mode:
Diffstat (limited to 'package/base-files/files/init.d/fs')
-rwxr-xr-xpackage/base-files/files/init.d/fs50
1 files changed, 50 insertions, 0 deletions
diff --git a/package/base-files/files/init.d/fs b/package/base-files/files/init.d/fs
new file mode 100755
index 000000000..55e2c3449
--- /dev/null
+++ b/package/base-files/files/init.d/fs
@@ -0,0 +1,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