fs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/sh
  2. #INIT 20
  3. [[ $1 = autostart ]] || exit 0
  4. # activate swap
  5. [ -x /sbin/swapon ] && {
  6. grep swap /etc/fstab >/dev/null 2>&1
  7. if [ $? -eq 0 ];then
  8. logger -t '' "Activating swap"
  9. swapon -a
  10. fi
  11. }
  12. # activate any logical volumes
  13. [ -x /usr/sbin/lvm ] && {
  14. logger -t '' "Activating LVM volumes"
  15. lvm vgscan
  16. lvm vgchange -ay
  17. }
  18. # mount local filesystems
  19. fstypes="ext2 ext3 ext4 xfs vfat ntfs"
  20. for fs in $fstypes; do
  21. disks=$(grep -v "^#" /etc/fstab|grep $fs|awk '{ print $1 }')
  22. for disk in $disks; do
  23. logger -t 'Filesystem' "Found $disk with filesystem $fs"
  24. mnt=$(grep -v "^#" /etc/fstab|grep "$disk "|awk '{ print $2 }')
  25. grep $fs /proc/filesystems >/dev/null 2>&1
  26. if [ $? -eq 0 ];then
  27. [ -x /usr/sbin/fsck.$fs ] && {
  28. logger -t 'Filesystem' "checking $fs filesystem on $disk"
  29. fsck -p $disk >/dev/null 2>&1
  30. }
  31. logger -t 'Filesystem' "Mounting local filesystems"
  32. mkdir -p $mnt > /dev/null 2>&1
  33. mount $disk
  34. else
  35. logger -s -t 'Filesystem' "No $fs filesystem in kernel"
  36. fi
  37. done
  38. done
  39. exit 0