Advertisement
Guest User

backstore noloop

a guest
Mar 14th, 2011
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.01 KB | None | 0 0
  1. diff --git a/initramfs/init b/initramfs/init
  2. index 779bd62..dc49222 100755
  3. --- a/initramfs/init
  4. +++ b/initramfs/init
  5. @@ -723,13 +723,9 @@ sysresccd_stage1_nfs()
  6.     fi
  7.  }
  8.  
  9. -# find the device that contains a file with that path: ${SUBDIR}/${LOOPDAT}
  10. -sysresccd_find_file() # $1=devtype, $2=filepath $3=mountdir, $4=mode
  11. +sysresccd_find_devices() # $1=devtype
  12.  {
  13. -   devtype="$1"   # on which devices should we search that file
  14. -   filepath="$2"  # path of the file we are looking for (eg: "/sysrcd.dat")
  15. -   mountdir="$3"  # where to mount the device if we find it
  16. -   mountmode="$4" # mount mode: either 'ro' or 'rw'
  17. +   devtype="$1"
  18.  
  19.     case "${devtype}" in
  20.     auto) # all devices
  21. @@ -755,15 +751,29 @@ sysresccd_find_file() # $1=devtype, $2=filepath $3=mountdir, $4=mode
  22.         if [ -b "${target}" ]
  23.         then
  24.             searchdevices="${target}"
  25. -       elif [ -b "/dev/disk/by-label/${uuid}" ]
  26. +       elif [ -b "/dev/disk/by-label/${label}" ]
  27.         then
  28. -           searchdevices="/dev/disk/by-label/${uuid}"
  29. +           searchdevices="/dev/disk/by-label/${label}"
  30.         fi
  31.         ;;
  32.     *) # specific device name (eg: "/dev/sda1")
  33.         searchdevices="${devtype}"
  34.         ;;
  35.     esac
  36. +  
  37. +   echo "${searchdevices}"
  38. +   return 1
  39. +}
  40. +
  41. +# find the device that contains a file with that path: ${SUBDIR}/${LOOPDAT}
  42. +sysresccd_find_file() # $1=devtype, $2=filepath $3=mountdir, $4=mode
  43. +{
  44. +   devtype="$1"   # on which devices should we search that file
  45. +   filepath="$2"  # path of the file we are looking for (eg: "/sysrcd.dat")
  46. +   mountdir="$3"  # where to mount the device if we find it
  47. +   mountmode="$4" # mount mode: either 'ro' or 'rw'
  48. +
  49. +   searchdevices="$(sysresccd_find_devices ${devtype})"
  50.  
  51.     SEARCHDEVICE='' # result returned
  52.     mkdir -p ${mountdir}
  53. @@ -995,28 +1005,57 @@ sysresccd_stage3_normal() # "backstore" + "aufs" + "mount --move"
  54.     if [ "${BACKSTORE_CMD}" != 'off' ]
  55.     then
  56.         BACKSTORE_DEVTYPE='rmdev' # by default search backstores only on removable devices
  57. +       BACKSTORE_NOLOOP=''
  58.         for curopt in $(echo ${BACKSTORE_CMD} | sed -e 's!,! !g')
  59.         do
  60.             case "${curopt}" in
  61.                 alldev)
  62.                     BACKSTORE_DEVTYPE='auto' # search for backstores on all types of devices
  63.                     ;;
  64. +               UUID\=*)
  65. +                   BACKSTORE_DEVTYPE=${curopt}
  66. +                   ;;
  67. +               LABEL\=*)
  68. +                   BACKSTORE_DEVTYPE=${curopt}
  69. +                   ;;
  70. +               noloop)
  71. +                   BACKSTORE_NOLOOP='1' # uses a device as backstore
  72. +                   ;;
  73.                 *)
  74.                     BACKSTORE_DAT=${curopt} # search for backstores on that particular device
  75.                     ;;
  76.             esac
  77.         done
  78.  
  79. -       good_msg "Searching for ${SUBDIR}/${BACKSTORE_DAT} on devices..."
  80. -       if sysresccd_find_file ${BACKSTORE_DEVTYPE} ${SUBDIR}/${BACKSTORE_DAT} ${BACKSTORE_MNT} 'rw'
  81. +       if [ -n "${BACKSTORE_NOLOOP}" ]
  82.         then
  83. -           good_msg "Backing store ${SUBDIR}/${BACKSTORE_DAT} found on ${SEARCHDEVICE}"
  84. -           if ! mount ${BACKSTORE_MNT}/${SUBDIR}/${BACKSTORE_DAT} ${BACKSTORE_MEM}
  85. +           case "${BACKSTORE_DEVTYPE}" in
  86. +               UUID\=* | LABEL\=* )
  87. +                   good_msg "Mounting device ${BACKSTORE_DEVTYPE} as backing store"
  88. +                   BACKSTORE_DEV="$(sysresccd_find_devices ${BACKSTORE_DEVTYPE})"
  89. +                   if ! mount ${BACKSTORE_DEV} ${BACKSTORE_MEM}
  90. +                   then
  91. +                       sysresccd_panic "Cannot mount the backstore device ${BACKSTORE_DEV}"
  92. +                   fi
  93. +                   BACKSTORE_FOUND='1'
  94. +                   ;;
  95. +               rmdev | auto | * )
  96. +                   sysresccd_panic "UUID or LABEL needed to mount a block device as backing store"
  97. +                   ;;
  98. +           esac
  99. +       else
  100. +           good_msg "Searching for ${SUBDIR}/${BACKSTORE_DAT} on devices..."
  101. +           if sysresccd_find_file ${BACKSTORE_DEVTYPE} ${SUBDIR}/${BACKSTORE_DAT} ${BACKSTORE_MNT} 'rw'
  102.             then
  103. -               sysresccd_panic "Cannot mount the loopback backstore file ${SUBDIR}/${BACKSTORE_DAT}"
  104. +               good_msg "Backing store ${SUBDIR}/${BACKSTORE_DAT} found on ${SEARCHDEVICE}"
  105. +               if ! mount ${BACKSTORE_MNT}/${SUBDIR}/${BACKSTORE_DAT} ${BACKSTORE_MEM}
  106. +               then
  107. +                   sysresccd_panic "Cannot mount the loopback backstore file ${SUBDIR}/${BACKSTORE_DAT}"
  108. +               fi
  109. +               BACKSTORE_FOUND='1'
  110.             fi
  111. -           BACKSTORE_FOUND='1'
  112.         fi
  113. +
  114.     fi
  115.  
  116.     # 2. store modifications in a tmpfs filesystem if there is no backstore
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement