Advertisement
Fighter19

Automount hook

Apr 22nd, 2012
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. run_hook ()
  2. {
  3. export HOST="/host"
  4. export UNION="/new_root"
  5. mkdir -p /host
  6. case ${real_root} in loop\=*)
  7. loop=${real_root/loop=}
  8. if [ -e $loop ]; then
  9. fstype=$(blkid -u filesystem -o value -s TYPE -p "${loop}")
  10. if [ "${readwrite}" = "no" ]; then rwopt="ro"; else rwopt="rw"; fi #Checks whether it is writeable
  11. #mount -t $fstype -o $rwopt $loop $HOST #Mounting doesn't work for ntfs so using 3g to mount
  12. ntfs-3g $loop $HOST
  13. echo ntfs-3g $loop $HOST
  14. if [ -f $HOST/$loopfile ]; then
  15. loopfile="$HOST/$loopfile"
  16. fstype=$(blkid -u filesystem -o value -s TYPE -p "${loopfile}")
  17. if [ "${fstype}" = "squashfs" ]; then rwopt="ro"; fi
  18. mount -t $fstype -o $rwopt $loopfile $UNION
  19. mkdir -p $UNION$HOST
  20. mkdir -p $UNION$loop
  21. mount -o bind $HOST $UNION/host
  22. MOUNTED=1
  23. fi
  24. fi
  25. ;;
  26. esac
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement