aufs-mount.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/sh
  2. . /lib/dracut-lib.sh
  3. data=$(getarg aufs_root)
  4. if [ ! -z "$data" ] ; then
  5. skip_dirs=$(getarg rfreeze_skip_dirs)
  6. # we can have either "aufs_root=UUID=" or "aufs_root=DIR="
  7. case $data in
  8. *UUID=* )
  9. echo "AAA"
  10. UUID=${data#UUID=}
  11. DIR=""
  12. ;;
  13. *DIR=* )
  14. UUID=""
  15. DIR=${data#DIR=}
  16. ;;
  17. esac
  18. mount -t tmpfs tmpfs /sysroot/tmp
  19. mkdir /sysroot/tmp/xinos
  20. mkdir /sysroot/tmp/sysroot-rw
  21. mkdir /sysroot/tmp/sysroot-ro
  22. mount -o bind /sysroot /sysroot/tmp/sysroot-ro
  23. RES=0
  24. if [ ! -z "$UUID" ] ; then
  25. /sbin/fsck.ext2 -y /dev/disk/by-uuid/$UUID
  26. mount /dev/disk/by-uuid/$UUID /sysroot/tmp/sysroot-rw && RES=1
  27. fi
  28. if [ ! -z "$DIR" ] ; then
  29. RES=1
  30. fi
  31. if [ "$RES" = 0 ] ; then
  32. mount -n -t tmpfs tmpfs /sysroot/tmp/sysroot-rw
  33. fi
  34. if [ ! -z "$skip_dirs" ] ; then
  35. SKIP_DIRS=${skip_dirs//:/ }
  36. else
  37. SKIP_DIRS="dev home lost+found media mnt proc run sys tmp"
  38. fi
  39. for d in `ls /sysroot `
  40. do
  41. skip_dir=0
  42. if [ ! -d "/sysroot/$d" ] ; then
  43. continue
  44. fi
  45. for sd in $SKIP_DIRS
  46. do
  47. if [ $d = $sd ] ; then
  48. skip_dir=1
  49. fi
  50. done
  51. if [ $skip_dir = 1 ] ; then
  52. continue
  53. fi
  54. if [ ! -e "/sysroot/tmp/sysroot-rw/$d" ] ; then
  55. if [ $d = "root" ] ; then
  56. mkdir -m 750 "/sysroot/tmp/sysroot-rw/$d"
  57. else
  58. mkdir -m 755 "/sysroot/tmp/sysroot-rw/$d"
  59. fi
  60. fi
  61. if [ ! -d "/sysroot/tmp/sysroot-rw/$d" ] ; then
  62. continue
  63. fi
  64. if [ ! -z "$DIR" ] ; then
  65. mount -o bind /sysroot/$DIR/$d /sysroot/tmp/sysroot-rw/$d
  66. fi
  67. mount -n -t aufs -o nowarn_perm,noatime,xino=/sysroot/tmp/xinos/$d.xino.aufs,dirs=/sysroot/tmp/sysroot-rw/$d=rw:/sysroot/$d=rr none /sysroot/$d
  68. done
  69. # cp -f /etc/halt /sysroot/etc/init.d/halt
  70. # cp -f /etc/functions /sysroot/etc/init.d/functions
  71. # mount -n -t aufs -o noatime,xino=/xinos/sysroot.xino.aufs,dirs=/sysroot-rw=rw:/sysroot=rr none /sysroot
  72. fi # if [ ! -z "$data" ]