FstabMounts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # This file is part of the 'dragora-installer'.
  2. #
  3. # Purpose: Make mount points and mount non-root filesystems from fstab.
  4. # Make declared mount points from fstab, exclude:
  5. # commentaries, root, and possible swapfile.
  6. makeMountPoints()
  7. {
  8. grep -E -v '^#|swap|/ ' "${SUBTMPDIR}/fstab" | \
  9. awk '{ print substr($2,2) }' | while read -r directory
  10. do
  11. test -n "$directory" || continue
  12. # Make sure to translate converted blank spaces (\040)
  13. # into common spaces for directory creation (see MakeFS)
  14. directory="$(printf '%s' "$directory" | tr '\\040' ' ')"
  15. if test ! -d "/media/dragora-root/${directory}"
  16. then
  17. mkdir -p -- "/media/dragora-root/${directory}"
  18. fi
  19. done
  20. }
  21. mountNonRoot()
  22. {
  23. if test -s "${SUBTMPDIR}/fstab"
  24. then
  25. awk '!/^#/ && !/\/ / && !/swap/ && !/fd0/ && !/tmp/{ print $1,$2 }' \
  26. "${SUBTMPDIR}/fstab" | while IFS=" " read -r device mntpoint
  27. do
  28. umount "$device" > /dev/null 2>&1 || true
  29. mntpoint="$(printf '%s' "$mntpoint" | tr '\\040' ' ')"
  30. mntpoint="/media/dragora-root/${mntpoint}"
  31. echo ""
  32. umount -v "$device" || true
  33. mount -v "$device" "$mntpoint" || exit $?
  34. sleep 2
  35. done
  36. fi
  37. }
  38. dialog --colors \
  39. --backtitle "\\ZbNon-root partition(s)" \
  40. --title "NON-ROOT MOUNTS" --sleep 2 \
  41. --infobox "Preparing to mount the rest of the file systems..." 3 54
  42. makeMountPoints
  43. mountNonRoot
  44. if test ! -e /media/dragora-root/etc/fstab
  45. then
  46. # Copy fstab into the root partition
  47. mkdir -p -- /media/dragora-root/etc || true
  48. cp -f -- "${SUBTMPDIR}/fstab" /media/dragora-root/etc/
  49. else
  50. # Offer the possibility to overwrite the fstab file only if
  51. # there is a difference, since there is no point in asking to
  52. # overwrite the (newly) created and copied file
  53. if test \
  54. "$(cmp -s "${SUBTMPDIR}/fstab" /media/dragora-root/etc/fstab; printf $?)" = "1"
  55. then
  56. dialog --no-shadow --colors \
  57. --backtitle "\\ZbFile system table (fstab)" \
  58. --title "EXISTING FILE SYSTEM TABLE" \
  59. --cr-wrap --yesno \
  60. "A file system table already exists on the mounted root partition:
  61. /media/dragora-root/etc/fstab
  62. Overwrite this file only if:
  63. - This is a new installation.
  64. - You are installing a new kernel image.
  65. - To create a boot disk with a new kernel.
  66. In this case, you must configure the system to boot properly.
  67. Do not overwrite the file system table if you are adding
  68. software to the existing system...
  69. Do you want to replace the existing fstab with the new one?
  70. " 19 69 || { unset makeMountPoints mountNonRoot ; return 0; }
  71. mkdir -p -- /media/dragora-root/etc || true
  72. cp -f -- "${SUBTMPDIR}/fstab" /media/dragora-root/etc/
  73. fi
  74. fi
  75. unset makeMountPoints mountNonRoot