Changeset 6320
- Timestamp:
- 02/14/10 00:24:22 (3 years ago)
- Location:
- pkg/frankie/main/distro-defaults/trunk
- Files:
-
- 3 edited
-
debian/changelog (modified) (1 diff)
-
hooks/parsix (modified) (4 diffs)
-
scripts/parsix (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pkg/frankie/main/distro-defaults/trunk/debian/changelog
r6319 r6320 1 distro-defaults (3.5.2) unstable; urgency=low 2 3 * Merged updates from fll-live-initramfs 2.2.2 4 5 -- Alan Baghumian <alan@memphis-mobile> Sat, 13 Feb 2010 15:21:32 -0800 6 1 7 distro-defaults (3.5.1) unstable; urgency=low 2 8 -
pkg/frankie/main/distro-defaults/trunk/hooks/parsix
r4807 r6320 13 13 14 14 # initramfs-tools prerequisite handling 15 PREREQS=" "15 PREREQS="nbd lvm" 16 16 17 17 prereqs() … … 29 29 . /usr/share/initramfs-tools/hook-functions 30 30 31 [ -s /etc/default/distro ] || exit 0 32 31 33 # distro-defaults 32 mkdir -p ${DESTDIR}/etc/default 33 # enforce live mode 34 sed 's/^FLL_DISTRO_MODE.*/FLL_DISTRO_MODE="live"/' \ 35 /etc/default/distro > ${DESTDIR}/etc/default/distro 36 37 sed 's/^FLL_DISTRO_MODE.*/FLL_DISTRO_MODE="live"/' \ 38 /etc/default/distro > ${DESTDIR}/scripts/distro 34 install -m 0644 -D /etc/default/distro \ 35 ${DESTDIR}/etc/default/distro 39 36 40 37 # filesystem unioning modules … … 42 39 manual_add_modules aufs 43 40 44 # squashfs , loop, sqlzma, unlzma41 # squashfs and loop 45 42 manual_add_modules squashfs 46 43 manual_add_modules loop 47 manual_add_modules sqlzma48 manual_add_modules unlzma49 44 50 45 # ms filesystem drivers 51 46 manual_add_modules vfat 52 47 manual_add_modules ntfs 53 54 # add fuse too55 manual_add_modules fuse56 48 57 49 # needed for vfat and iso9660 … … 60 52 manual_add_modules nls_iso8859-1 61 53 62 # RTC modules63 manual_add_modules rtc_cmos64 manual_add_modules rtc_core65 manual_add_modules rtc_lib66 67 54 # ensure maximum hardware support 68 55 auto_add_modules -
pkg/frankie/main/distro-defaults/trunk/scripts/parsix
r5256 r6320 2 2 3 3 ############################################################################### 4 # F.U.L.L.S.T.O.R.Y initramfs live media init functions4 # F.U.L.L.S.T.O.R.Y initramfs live media init functions 5 5 # 6 # Copyright:(C) 2007 Kel Modderman <kel@otaku42.de>7 # (C) 2007 Stefan Lippers-Hollmann <s.l-h@gmx.de>8 # License:GPLv26 # Copyright: (C) 2007 Kel Modderman <kel@otaku42.de> 7 # (C) 2007 Stefan Lippers-Hollmann <s.l-h@gmx.de> 8 # License: GPLv2 9 9 # 10 # F.U.L.L.S.T.O.R.Y Project Homepage:11 # http://developer.berlios.de/projects/fullstory12 ############################################################################### 13 # safety overrides - we want to esnure we know exactly what tool14 # is being used, it could be provided by klibc or busybox, but both15 # have functional differences10 # F.U.L.L.S.T.O.R.Y Project Homepage: 11 # http://developer.berlios.de/projects/fullstory 12 ############################################################################### 13 # safety overrides - we want to esnure we know exactly what tool 14 # is being used, it could be provided by klibc or busybox, but both 15 # have functional differences 16 16 ############################################################################### 17 17 mount() 18 18 { 19 # can loop mount files, klibc's mount cannot without first binding 20 # file to loop (block) device node with losetup 21 /bin/busybox mount "${@}" 22 return "${?}" 23 } 24 ############################################################################### 25 # utility function to help with identifying device strings within a list 26 ############################################################################### 27 fll_string_not_in_strings() 19 # can loop mount files, klibc's mount cannot without first binding 20 # file to loop (block) device node with losetup 21 /bin/busybox mount "${@}" 22 return "${?}" 23 } 24 25 freadlink() 28 26 { 29 VAR="${1}" 30 shift 31 32 for var in ${@}; do 33 [ "${VAR}" = "${var}" ] && return 1 34 done 35 36 return 0 37 } 38 ############################################################################### 39 # use information exported via proc and sysfs to make block device list 40 # bubble-sort cdrom devices to top of block device stack 27 # support canonicaliziation of path 28 /bin/busybox readlink -f "${@}" 29 return "${?}" 30 } 31 ############################################################################### 32 # use information exported via proc and sysfs to make block device list 33 # bubble-sort cdrom devices to top of block device stack 41 34 ############################################################################### 42 35 fll_finger_blockdevs() 43 36 { 44 unset FLL_PROBED_CDROMS 45 46 if [ "${FLL_FROMHD}" != "yes" ]; then 47 # 48 # cdrom detection via /proc/sys/dev/cdrom/info 49 # 50 if [ -f /proc/sys/dev/cdrom/info ]; then 51 FLL_PROBED_CDROMS="$(awk ' 52 /^drive name:/ { 53 for (i = NF; i >= 3; i--) { 54 print($i) 55 } 56 } 57 ' /proc/sys/dev/cdrom/info)" 58 fi 59 60 for cdrom in ${FLL_PROBED_CDROMS}; do 61 if [ -b "/dev/${cdrom}" ]; then 62 echo "/dev/${cdrom}" 63 fi 64 done 65 fi 66 67 # 68 # fromhd/fromiso/persist cheatcode required for additional block device detection 69 # 70 if [ "${FLL_FROMHD}" != "yes" ] && [ "${FLL_PERSIST}" != "yes" ]; then 71 return 0 72 fi 73 74 # 75 # generic block device detection 76 # 77 for dev in /sys/block/*; do 78 dev=${dev#/sys/block/} 79 80 case "${dev}" in 81 ram[0-9]*|loop[0-9]*|fd[0-9]*) 82 # 83 # skip ram, loop and floppy devices 84 # 85 continue 86 ;; 87 *) 88 if ! fll_string_not_in_strings "${dev}" ${FLL_PROBED_CDROMS}; then 89 # 90 # already identified as cdrom device 91 # 92 continue 93 fi 94 ;; 95 esac 96 97 # 98 # use shell wildcard to expand subdevices 99 # 100 for subdev in $(echo /dev/${dev}*); do 101 if [ -b "${subdev}" ]; then 102 echo "${subdev}" 103 fi 104 done 105 done 106 } 107 ############################################################################### 108 # identify filesystem type of block device 37 unset FINGERED 38 39 # 40 # cdrom device detection. we could glob /sys/block/ and use udevadm 41 # info output to identify devices with ID_CDOM=1 in environment, but 42 # that method has proven to be unreliable ... 43 # 44 if [ "${FLL_FROMHD}" != "yes" ] && [ -r /proc/sys/dev/cdrom/info ]; then 45 FINGERED=$(awk -F: ' 46 $1 == "drive name" && NF > 1 { 47 split($2, node, " ") 48 for (n in node) { 49 if (!system("test -b /dev/" node[n])) 50 cdrom[i++] = "/dev/" node[n] 51 } 52 } 53 END { 54 for (c in cdrom) 55 print cdrom[c] 56 } 57 ' /proc/sys/dev/cdrom/info) 58 59 # 60 # only detect non cdrom devices if fromhd/fromiso/persist 61 # cheatcode was used. 62 # 63 if [ "${FLL_PERSIST}" != "yes" ]; then 64 echo "${FINGERED}" 65 return 66 fi 67 fi 68 69 # 70 # disk device detection 71 # 72 for path in /sys/block/*; do 73 [ -e "${path}" ] || continue 74 75 disk=${path#/sys/block/} 76 77 if [ "${FINGERED}" ] && echo "${FINGERED}" | \ 78 grep -q -w "${disk}"; then 79 continue 80 fi 81 82 case "${disk}" in 83 ps3d*) 84 # 85 # udev seems to not know much about these 86 # special PS3 specific block devices, so 87 # avoid disk type checking 88 # 89 ;; 90 *) 91 udevadm info -q env -p "${path}" | \ 92 grep -q 'ID_TYPE=disk' || continue 93 ;; 94 esac 95 96 # 97 # use shell wildcard to expand partitions from sysfs hier 98 # 99 for sub_path in ${path}/${disk}[1-9]*; do 100 [ -e "${sub_path}" ] || continue 101 102 part="${sub_path#${path}/}" 103 104 if [ -b "/dev/${part}" ]; then 105 FINGERED="${FINGERED} /dev/${part}" 106 fi 107 done 108 109 # 110 # also attempt to probe the base device, in some cases this is 111 # the only partition 112 # 113 if [ -b "/dev/${disk}" ]; then 114 FINGERED="${FINGERED} /dev/${disk}" 115 fi 116 done 117 118 echo ${FINGERED} 119 } 120 ############################################################################### 121 # identify filesystem type of block device 109 122 ############################################################################### 110 123 fll_finger_fstype() 111 124 { 112 unset FSTYPE 113 114 # 115 # fstype, displays FSTYPE and FSSIZE 116 # 117 eval $(fstype < ${1} 2>/dev/null) 118 119 # 120 # try vol_id if fstype failed to detect FSTYPE 121 # 122 if ( [ -z "${FSTYPE}" ] || [ "${FSTYPE}" = "unknown" ] ) && \ 123 [ -x /lib/udev/vol_id ]; then 124 FSTYPE=$(/lib/udev/vol_id -t ${1} 2>/dev/null) 125 fi 126 127 if [ "${FSTYPE}" ] && [ "${FSTYPE}" != "unknown" ]; then 128 export FSTYPE 129 return 0 130 fi 131 132 return 1 133 } 134 ############################################################################### 135 # modprobe loop and wait for device node creation 125 unset FSTYPE 126 unset ID_FS_TYPE 127 128 eval $(/sbin/blkid -o udev -u filesystem -p ${1} | grep ^ID_FS_TYPE) 129 130 if [ "${ID_FS_TYPE}" ] ; then 131 FSTYPE="${ID_FS_TYPE}" 132 export FSTYPE 133 return 0 134 fi 135 136 return 1 137 } 138 ############################################################################### 139 # modprobe loop and wait for device node creation 136 140 ############################################################################### 137 141 fll_setup_dev_loop() 138 142 { 139 #140 # load loop device support141 #142 modprobe "${MODPROBE_OPTIONS}" loop143 144 #145 # loop around for max of 5 seconds and wait for /dev/loop* device nodes146 #147 LOOP_WAIT="10"148 149 while [ "${LOOP_WAIT}" -gt 0 ]; do150 for l in /dev/loop*; do151 if [ -e "${l}" ]; then152 return 0153 fi154 done155 sleep 1156 LOOP_WAIT=$(( ${LOOP_WAIT} - 1 ))157 done158 159 panic "${R}Unable to setup loop mounted device, no loop device nodes exist${N}"160 } 161 ############################################################################### 162 # generic mount function usage: fll_mount fs src mnt options143 # 144 # load loop device support 145 # 146 modprobe "${MODPROBE_OPTIONS}" loop 147 148 # 149 # loop around for max of 5 seconds and wait for /dev/loop* device nodes 150 # 151 LOOP_WAIT="10" 152 153 while [ "${LOOP_WAIT}" -gt 0 ]; do 154 for l in /dev/loop*; do 155 if [ -e "${l}" ]; then 156 return 0 157 fi 158 done 159 sleep 1 160 LOOP_WAIT=$(( ${LOOP_WAIT} - 1 )) 161 done 162 163 panic "${R}Unable to setup loop mounted device, no loop device nodes exist${N}" 164 } 165 ############################################################################### 166 # generic mount function usage: fll_mount fs src mnt options 163 167 ############################################################################### 164 168 fll_mount() 165 169 { 166 FS="${1}" 167 SRC="${2}" 168 DST="${3}" 169 shift 3 170 171 case "${FS}" in 172 iso9660|squashfs) 173 if [ -f "${SRC}" ] && [ ! -b "${SRC}" ]; then 174 fll_setup_dev_loop 175 FLL_MOUNT_OPTS="ro,loop" 176 else 177 FLL_MOUNT_OPTS="ro" 178 fi 179 ;; 180 ntfs) 181 if [ "${#}" -gt 0 ]; then 182 FLL_MOUNT_OPTS="${@},dmask=0022,fmask=0133" 183 else 184 FLL_MOUNT_OPTS="ro,dmask=0022,fmask=0133" 185 fi 186 ;; 187 vfat) 188 # 189 # we need this for FLL_IMAGE on DOS-filesystems 190 # 191 if [ "${#}" -gt 0 ]; then 192 FLL_MOUNT_OPTS="${@},shortname=winnt,umask=0" 193 else 194 FLL_MOUNT_OPTS="shortname=winnt,umask=0" 195 fi 196 ;; 197 suspend|swap|luks|lvm*) 198 # 199 # filesystem blacklist 200 # 201 return 1 202 ;; 203 *) 204 if [ "${#}" -gt 0 ]; then 205 FLL_MOUNT_OPTS="noatime,${@}" 206 fi 207 ;; 208 esac 209 210 if [ "${FLL_MOUNT_OPTS}" ]; then 211 mount -t ${FS} -o ${FLL_MOUNT_OPTS} ${SRC} ${DST} >/dev/null 2>&1 212 return "${?}" 213 else 214 mount -t ${FS} ${SRC} ${DST} >/dev/null 2>&1 215 return "${?}" 216 fi 217 } 218 ############################################################################### 219 # umount and remove a stack of mount points 170 FS="${1}" 171 SRC="${2}" 172 DST="${3}" 173 shift 3 174 175 unset FLL_MOUNT_OPTS 176 177 case "${FS}" in 178 iso9660|squashfs) 179 if [ -f "${SRC}" ] && [ ! -b "${SRC}" ]; then 180 fll_setup_dev_loop 181 FLL_MOUNT_OPTS="ro,loop" 182 else 183 FLL_MOUNT_OPTS="ro" 184 fi 185 ;; 186 ntfs) 187 if [ "${#}" -gt 0 ]; then 188 FLL_MOUNT_OPTS="${@},dmask=0022,fmask=0133" 189 else 190 FLL_MOUNT_OPTS="ro,dmask=0022,fmask=0133" 191 fi 192 ;; 193 vfat) 194 # 195 # we need this for FLL_IMAGE on DOS-filesystems 196 # 197 if [ "${#}" -gt 0 ]; then 198 FLL_MOUNT_OPTS="${@},shortname=winnt,umask=0" 199 else 200 FLL_MOUNT_OPTS="shortname=winnt,umask=0" 201 fi 202 ;; 203 suspend|swap|luks|lvm*) 204 # 205 # filesystem blacklist 206 # 207 return 1 208 ;; 209 *) 210 if [ "${#}" -gt 0 ]; then 211 FLL_MOUNT_OPTS="noatime,${@}" 212 fi 213 ;; 214 esac 215 216 if [ "${FLL_MOUNT_OPTS}" ]; then 217 mount -t ${FS} -o ${FLL_MOUNT_OPTS} ${SRC} ${DST} >/dev/null 2>&1 218 return "${?}" 219 else 220 mount -t ${FS} ${SRC} ${DST} >/dev/null 2>&1 221 return "${?}" 222 fi 223 } 224 ############################################################################### 225 # umount and remove a stack of mount points 220 226 ############################################################################### 221 227 fll_umount() 222 228 { 223 [ "${#}" -ge 1 ] || return 0 224 225 for m in ${@}; do 226 if grep -q "${m}" /proc/mounts; then 227 umount "${m}" && rmdir "${m}" 228 fi 229 done 230 } 231 ############################################################################### 232 # display processor name and highlights 229 [ "${#}" -ge 1 ] || return 0 230 231 for m in ${@}; do 232 grep -q "${m}" /proc/mounts || continue 233 234 umount "${m}" 2>/dev/null 235 236 # if a plain umount fails, try the lazy option 237 # if the lazy option fails then panic with error 238 if [ "${?}" -ne 0 ]; then 239 umount -l "${m}" || panic "failed to umount ${m}" 240 fi 241 242 rmdir "${m}" 243 done 244 } 245 ############################################################################### 246 # display processor name and highlights 233 247 ############################################################################### 234 248 fll_cpuinfo() 235 249 { 236 printf "${G}"237 awk -F: '238 /^processor/ { printf("Processor'${Y}'"$2"'${G}' is\t") }239 /^model name/ {240 gsub(/(\([Tt][Mm]\)|\([Rr]\))/,"",$2)241 gsub(/[ ]+/," ",$2)242 printf("'${W}'['${Y}'"$2"'${W}' ] ")243 }244 /^cpu MHz/ { printf("[ '${Y}'%d MHz'${W}' ] ", int($2)) }245 /^cache size/ { printf("['${Y}'"$2" Cache'${W}' ]") }246 /^$/ { printf("\n'${G}'") }247 ' /proc/cpuinfo248 printf "${N}"249 } 250 ############################################################################### 251 # calculate total, used and unused memory: MEMTOTAL MEMUSED MEMFREE250 printf "${G}" 251 awk -F: ' 252 /^processor/ { printf("Processor'${Y}'"$2"'${G}' is\t") } 253 /^model name/ { 254 gsub(/(\([Tt][Mm]\)|\([Rr]\))/,"",$2) 255 gsub(/[ ]+/," ",$2) 256 printf("'${W}'['${Y}'"$2"'${W}' ] ") 257 } 258 /^cpu MHz/ { printf("[ '${Y}'%d MHz'${W}' ] ", int($2)) } 259 /^cache size/ { printf("['${Y}'"$2" Cache'${W}' ]") } 260 /^$/ { printf("\n'${G}'") } 261 ' /proc/cpuinfo 262 printf "${N}" 263 } 264 ############################################################################### 265 # calculate total, used and unused memory: MEMTOTAL MEMUSED MEMFREE 252 266 ############################################################################### 253 267 fll_meminfo() 254 268 { 255 awk '256 /^MemTotal:/ { total=$2 }257 /^(MemFree|Buffers|Cached):/ { free+=$2 }258 END {259 printf("MEMTOTAL=%d\n",int(total) / 1024)260 printf("MEMFREE=%d\n",int(free) / 1024)261 printf("MEMUSED=%d\n",(int(total) - int(free)) / 1024)262 }263 ' /proc/meminfo264 } 265 ############################################################################### 266 # utility function to display update when cp'ing live media into ram269 awk ' 270 /^MemTotal:/ { total=$2 } 271 /^(MemFree|Buffers|Cached):/ { free+=$2 } 272 END { 273 printf("MEMTOTAL=%d\n", int(total) / 1024) 274 printf("MEMFREE=%d\n", int(free) / 1024) 275 printf("MEMUSED=%d\n", (int(total) - int(free)) / 1024) 276 } 277 ' /proc/meminfo 278 } 279 ############################################################################### 280 # utility function to display update when cp'ing live media into ram 267 281 ############################################################################### 268 282 fll_copy_with_perc() 269 283 { 270 if [ ! -f "${1}" ] || [ ! -d "${2}" ]; then271 return 1272 fi273 274 #275 # background the copy, grab the process id276 #277 cp "${1}" "${2}/${1##*/}" &278 279 awk -v pid="${!}" -v origfile="${1}" -v destfile="${2}/${1##*/}" '280 function size_of(file, cmd, size)281 {282 cmd = "du -s" file283 if ((cmd | getline) > 0) {284 size = int($1)285 close(cmd)286 if (size > 0)287 return size288 }289 290 return 0291 }292 293 BEGIN {294 do {295 if (system("test -f " destfile) == 0) {296 break297 }298 else if (system("sleep 1") == 0) {299 wait++300 }301 else {302 exit(1)303 }304 } while (wait < 15)305 306 size_dest = perc = 0307 size_orig = size_of(origfile)308 if (size_orig <= 0)309 exit(1)310 311 do {312 perc = int(100 * size_of(destfile) / size_orig)313 if (perc < 100) {314 printf("\r'${W}'['${G}'")315 for (i = 0; i <= perc; i += 2)316 printf("=")317 printf("'${W}'>")318 for (i = perc; i < 100; i += 2)319 printf(" ")320 printf("] ")321 printf("%02d%s", perc, "%")322 printf("'${N}'")323 }324 } while (system("test -d /proc/" pid) == 0 &&325 system("sleep 2") == 0)326 327 #328 # destfile size is > origfile size on tmpfs329 #330 if (size_of(destfile) >= size_orig) {331 printf("\r'${W}'['${G}'")332 for (i = 0; i <= 100; i += 2)333 printf("=")334 printf("='${W}'] ")335 printf("%s\n", "100%")336 printf("'${N}'")337 exit(0)338 }339 else {340 printf("'${R}'")341 printf("\nFailed to copy %s to ram\n", origfile)342 printf("'${N}'") 343 exit(1)344 }345 }'346 347 return ${?}348 } 349 ############################################################################### 350 # md5sum checker284 if [ ! -f "${1}" ] || [ ! -d "${2}" ]; then 285 return 1 286 fi 287 288 # 289 # background the copy, grab the process id 290 # 291 cp "${1}" "${2}/${1##*/}" & 292 293 awk -v pid="${!}" -v origfile="${1}" -v destfile="${2}/${1##*/}" ' 294 function size_of(file, cmd, size) 295 { 296 cmd = "ls -l " file 297 if ((cmd | getline) > 0) { 298 size = int($5 / 1024) 299 close(cmd) 300 if (size > 0) 301 return size 302 } 303 304 return 0 305 } 306 307 BEGIN { 308 do { 309 if (system("test -f " destfile) == 0) { 310 break 311 } 312 else if (system("sleep 1") == 0) { 313 wait++ 314 } 315 else { 316 exit(1) 317 } 318 } while (wait < 15) 319 320 size_dest = perc = 0 321 size_orig = size_of(origfile) 322 if (size_orig <= 0) 323 exit(1) 324 325 do { 326 perc = int(100 * size_of(destfile) / size_orig) 327 if (perc < 100) { 328 printf("\r'${W}'['${G}'") 329 for (i = 0; i <= perc; i += 2) 330 printf("=") 331 printf("'${W}'>") 332 for (i = perc; i < 100; i += 2) 333 printf(" ") 334 printf("] ") 335 printf("%02d%s", perc, "%") 336 printf("'${N}'") 337 } 338 } while (system("test -d /proc/" pid) == 0 && 339 system("sleep 2") == 0) 340 341 # 342 # destfile size is > origfile size on tmpfs 343 # 344 if (size_of(destfile) >= size_orig) { 345 printf("\r'${W}'['${G}'") 346 for (i = 0; i <= 100; i += 2) 347 printf("=") 348 printf("='${W}'] ") 349 printf("%s\n", "100%") 350 printf("'${N}'") 351 exit(0) 352 } 353 else { 354 printf("'${R}'") 355 printf("\nFailed to copy %s to ram\n", origfile) 356 printf("'${N}'") 357 exit(1) 358 } 359 }' 360 361 return ${?} 362 } 363 ############################################################################### 364 # md5sum checker 351 365 ############################################################################### 352 366 fll_md5sum_check() 353 367 { 354 if [ ! -f "${1}/md5sums" ]; then 355 printf "No md5sums file found on live media.\n" 356 return 1 357 fi 358 359 awk -v dir=${1} ' 360 { 361 sub(/^\*/, "", $2) 362 363 md5 = $1 364 file = $2 365 366 printf("'${W}'") 367 printf("* %s\n|--> %s\n`--> ", file, md5) 368 printf("'${N}'") 369 370 if (("md5sum " dir "/" file | getline) > 0) { 371 if (md5 == $1) { 372 printf("'${G}'") 373 printf("%s OK\n\n", $1) 374 printf("'${N}'") 375 next 376 } 377 else { 378 printf("'${R}'") 379 printf("%s FAILED\n\n", $1) 380 printf("'${N}'") 381 } 382 } 383 else { 384 printf("'${R}'") 385 printf("Unable to calculate md5sum!\n\n") 386 printf("'${N}'") 387 } 388 389 failed++ 390 } 391 392 END{ 393 if (failed) { 394 printf("'${R}'") 395 printf("*******************************\n") 396 printf("***** MD5SUM CHECK FAILED *****\n") 397 printf("*******************************\n") 398 printf("'${N}'") 399 exit(1) 400 } 401 402 exit(0) 403 }' "${1}/md5sums" 404 405 return ${?} 406 } 407 ############################################################################### 408 # define mountroot() for init 368 if [ ! -f "${1}/md5sums" ]; then 369 printf "No md5sums file found on live media.\n" 370 return 1 371 fi 372 373 awk -v dir=${1} ' 374 { 375 sub(/^\*/, "", $2) 376 377 md5 = $1 378 file = $2 379 380 printf("'${W}'") 381 printf("* %s\n|--> %s\n`--> ", file, md5) 382 printf("'${N}'") 383 384 if (("md5sum " dir "/" file | getline) > 0) { 385 if (md5 == $1) { 386 printf("'${G}'") 387 printf("%s OK\n\n", $1) 388 printf("'${N}'") 389 next 390 } 391 else { 392 printf("'${R}'") 393 printf("%s FAILED\n\n", $1) 394 printf("'${N}'") 395 } 396 } 397 else { 398 printf("'${R}'") 399 printf("Unable to calculate md5sum!\n\n") 400 printf("'${N}'") 401 } 402 403 failed++ 404 } 405 406 END{ 407 if (failed) { 408 printf("'${R}'") 409 printf("*******************************\n") 410 printf("***** MD5SUM CHECK FAILED *****\n") 411 printf("*******************************\n") 412 printf("'${N}'") 413 exit(1) 414 } 415 416 exit(0) 417 }' "${1}/md5sums" 418 419 return ${?} 420 } 421 ############################################################################### 422 # check matching kernel is present 423 ############################################################################### 424 fll_check_kernel() 425 { 426 kv=$(uname -r) 427 if [ -e $1/boot/vmlinuz-${kv} ] || [ -e $1/boot/vmlinux-${kv} ]; then 428 return 1 429 fi 430 return 0 431 } 432 ############################################################################### 433 # find and copy firmware 434 ############################################################################### 435 fll_firmware() { 436 # FLL_MOUNT_LOOP skips sleeping the first loop round 437 unset FLL_MOUNT_LOOP 438 # set FROMHD so hd's will be fingered 439 FLL_FROMHD_REAL="${FLL_FROMHD}" 440 FLL_FROMHD="yes" 441 # don't wait longer for firmware then root 442 # FLL_ROOTDELAY may already have been decreased 443 while [ "${FLL_ROOTDELAY}" -gt 0 ]; do 444 # sleep time, we skip sleeping for first pass 445 if [ "${FLL_MOUNT_LOOP}" ]; then 446 if [ "${FLL_MOUNT_LOOP}" -eq 1 ]; then 447 printf "${G}Waiting for up to ${Y}${FLL_ROOTDELAY}${G}s for devices to settle${N}...\n" 448 fi 449 sleep "${FLL_MOUNT_INTERVAL}" 450 FLL_ROOTDELAY=$(( ${FLL_ROOTDELAY} - ${FLL_MOUNT_INTERVAL} )) 451 fi 452 FLL_MOUNT_LOOP=$(( ${FLL_MOUNT_LOOP} + 1 )) 453 # FLL_FIRMDEVS holds the list of new devices to scan 454 unset FLL_FIRMDEVS 455 for dev in $(fll_finger_blockdevs); do 456 unset firmdevdone 457 for check in ${FLL_FIRMMNTS} ; do 458 if [ ${check} = ${dev##*/} ]; then 459 firmdevdone="Y" 460 break 461 fi 462 done 463 if [ -z "${firmdevdone}" ]; then 464 FLL_FIRMDEVS="${FLL_FIRMDEVS} ${dev}" 465 fi 466 done 467 # end loop if there is nothing new to check 468 if [ -z "${FLL_FIRMDEVS}" ]; then 469 continue 470 fi 471 # try each new device 472 for dev in ${FLL_FIRMDEVS}; do 473 # FLL_BLOCKMNT - tracks current mount point 474 unset FLL_BLOCKMNT 475 # determine filesystem type of block device 476 if fll_finger_fstype "${dev}" >/dev/null 2>&1; then 477 # setup mount point 478 FLL_BLOCKMNT="/fll/${dev##*/}" 479 mkdir -p "${FLL_BLOCKMNT}" 480 # mount block device on FLL_BLOCKMNT for probe 481 if fll_mount "${FSTYPE}" "${dev}" "${FLL_BLOCKMNT}" ro; then 482 # add dev name to FLL_FIRMMNTS to supress rechecking 483 FLL_FIRMMNTS="${FLL_FIRMMNTS} ${dev##*/}" 484 # check for firmware dir 485 if [ -d "${FLL_BLOCKMNT}/${FLL_IMAGE_DIR}/firmware" ]; then 486 FLL_FIRMWARE_FOUND="${dev}" 487 if cp -R ${FLL_BLOCKMNT}/${FLL_IMAGE_DIR}/firmware/* /${rootmnt}/lib/firmware ; then 488 printf "${G}Copied firmware from ${Y}${dev##*/}${N}\n" 489 fi 490 fi 491 fll_umount "${FLL_BLOCKMNT}" 492 fi 493 fi 494 # 495 # break dev and sleep loops if you have firmware 496 # 497 if [ "${FLL_FIRMWARE_FOUND}" ]; then 498 break 2 499 fi 500 done 501 done 502 # Restore real FROMHD value in case something else decides to use it 503 FLL_FROMHD="${FLL_FROMHD_REAL}" 504 if [ -z "${FLL_FIRMWARE_FOUND}" ]; then 505 echo "${R}Failed to find firmware directory${N}" 506 fi 507 } 508 ############################################################################### 509 # define mountroot() for init 409 510 ############################################################################### 410 511 mountroot() 411 512 { 412 #413 # colourful escape sequences414 #415 N="[0;39m"# Normal color416 R="[1;31m"# Failure message417 G="[1;32m"# Success message418 Y="[1;33m"# Variable Descriptions419 W="[1;37m"# Brackets420 421 #422 # force our arch string for i386423 #424 case "${DPKG_ARCH}" in425 i?86)426 FLL_ARCH="i686"427 ;;428 *)429 FLL_ARCH="${DPKG_ARCH}"430 ;;431 esac432 433 #513 # 514 # colourful escape sequences 515 # 516 N="[0;39m" # Normal color 517 R="[1;31m" # Failure message 518 G="[1;32m" # Success message 519 Y="[1;33m" # Variable Descriptions 520 W="[1;37m" # Brackets 521 522 # 523 # force our arch string for i386 524 # 525 case "${DPKG_ARCH}" in 526 i?86) 527 FLL_ARCH="i686" 528 ;; 529 *) 530 FLL_ARCH="${DPKG_ARCH}" 531 ;; 532 esac 533 534 # 434 535 # source distro-defaults 435 536 # 436 . /scripts/distro 437 438 # Create loop nodes 439 mknod /dev/loop0 b 7 0 440 mknod /dev/loop1 b 7 0 441 442 # 443 # parse fll options given on cmdline 444 # 445 for opt in $(cat /proc/cmdline); do 446 case "${opt}" in 447 fll=debug) 448 set -x 449 ;; 450 fromhd*) 451 FLL_FROMHD="yes" 452 # define dev node 453 case "${opt}" in 454 fromhd=*) 455 FLL_FROMHD_DEV="${opt#fromhd=}" 456 ;; 457 esac 458 ;; 459 fromiso*) 460 FLL_FROMHD="yes" 461 FLL_FROMISO="yes" 462 # define iso name 463 case "${opt}" in 464 fromiso=*) 465 FLL_MEDIA_NAME="${opt#fromiso=}" 466 ;; 467 esac 468 ;; 469 image_dir=*) 470 FLL_IMAGE_DIR="${opt#image_dir=}" 471 FLL_IMAGE_LOCATION="${FLL_IMAGE_DIR}/${FLL_IMAGE_FILE}" 472 ;; 473 image_name=*) 474 FLL_IMAGE_FILE="${opt#image_name=}" 475 FLL_IMAGE_LOCATION="${FLL_IMAGE_DIR}/${FLL_IMAGE_FILE}" 476 ;; 477 persist*) 478 FLL_PERSIST="yes" 479 FLL_PERSIST_FILE="${FLL_DISTRO_NAME}-rw" 480 case "${opt}" in 481 persist=*) 482 FLL_PERSIST_FILE="${opt#persist=}" 483 FLL_UNION_COWDIR="${opt#persist=}" 484 ;; 485 esac 486 ;; 487 quiet) 488 if [ -f /proc/sys/kernel/printk ]; then 489 echo "0" > /proc/sys/kernel/printk 490 fi 491 ;; 492 testcd|testdvd|md5sum) 493 FLL_MD5SUM_CHECK="yes" 494 ;; 495 toram) 496 FLL_TORAM="yes" 497 ;; 498 unionfs|aufs) 499 FLL_UNION_MODULE="${opt}" 500 ;; 501 esac 502 done 503 504 # 505 # print geeky informational messages 506 # 537 . /etc/default/distro 538 539 # 540 # parse fll options given on cmdline 541 # 542 for opt in $(cat /proc/cmdline); do 543 case "${opt}" in 544 firmware) 545 FLL_FIRMWARE="yes" 546 ;; 547 fll=debug) 548 set -x 549 ;; 550 fromhd*) 551 FLL_FROMHD="yes" 552 # define dev node 553 case "${opt}" in 554 fromhd=*) 555 FLL_FROMHD_DEV="${opt#fromhd=}" 556 ;; 557 esac 558 ;; 559 fromiso*) 560 FLL_FROMHD="yes" 561 FLL_FROMISO="yes" 562 # define iso name 563 case "${opt}" in 564 fromiso=*) 565 FLL_MEDIA_NAME="${opt#fromiso=}" 566 ;; 567 esac 568 ;; 569 image_dir=*) 570 FLL_IMAGE_DIR="${opt#image_dir=}" 571 FLL_IMAGE_LOCATION="${FLL_IMAGE_DIR}/${FLL_IMAGE_FILE}" 572 ;; 573 image_name=*) 574 FLL_IMAGE_FILE="${opt#image_name=}" 575 FLL_IMAGE_LOCATION="${FLL_IMAGE_DIR}/${FLL_IMAGE_FILE}" 576 ;; 577 persist*) 578 FLL_PERSIST="yes" 579 FLL_PERSIST_FILE="${FLL_DISTRO_NAME}-rw" 580 case "${opt}" in 581 persist=*) 582 FLL_PERSIST_FILE="${opt#persist=}" 583 FLL_UNION_COWDIR="${opt#persist=}" 584 ;; 585 esac 586 ;; 587 quiet) 588 if [ -f /proc/sys/kernel/printk ]; then 589 echo "0" > /proc/sys/kernel/printk 590 fi 591 ;; 592 testcd|testdvd|md5sum) 593 FLL_MD5SUM_CHECK="yes" 594 ;; 595 toram) 596 FLL_TORAM="yes" 597 ;; 598 unionfs|aufs) 599 FLL_UNION_MODULE="${opt}" 600 ;; 601 esac 602 done 603 604 # 605 # print geeky informational messages 606 # 507 607 printf "\n${W}Welcome to ${FLL_DISTRO_NAME} ${FLL_DISTRO_VER} '${FLL_DISTRO_CNAME}' (${FLL_ARCH})${N}\n\n" 508 608 509 # 510 # Print kernel info 511 # 512 #printf "${G}Linux Kernel\t${W}[ ${Y}$(uname -r)${W} ]${N}\n" 513 514 # 515 # Print CPU info 516 # 517 #fll_cpuinfo 518 519 # 520 # Print System Memory info 521 # 522 eval $(fll_meminfo) 523 printf "${G}System Memory\t${W}" 524 printf "[ ${Y}${MEMUSED}M used ${W}] " 525 printf "[ ${Y}${MEMFREE}M free${W} ] " 526 printf "[ ${Y}${MEMTOTAL}M total${W} ]" 527 printf "${N}\n" 528 529 # 530 # Run scripts in local-top, like lvm2 531 # 532 [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top" 533 run_scripts /scripts/local-top 534 [ "$quiet" != "y" ] && log_end_msg 535 536 # 537 # debug checkpoint 538 # 539 maybe_break fll-premount 540 541 # 542 # total time in seconds to do device scans for; rootdelay= on kernel cmdline 543 # upper limit on how long we wait for devices to show up before bailing out 544 # 545 if [ "${ROOTDELAY}" ] && [ "${ROOTDELAY}" -gt 0 ]; then 546 FLL_ROOTDELAY="${ROOTDELAY}" 547 else 548 FLL_ROOTDELAY="30" 549 fi 550 551 # 552 # interval between device scans 553 # 554 FLL_MOUNT_INTERVAL="3" 555 556 # 557 # these variables are created during $FLL_ROOTDELAY time loop 558 # 559 unset FLL_BLOCKDEVS_OLD FLL_MOUNT_LOOP 560 561 while [ "${FLL_ROOTDELAY}" -gt 0 ]; do 562 # 563 # refresh these for each loop 564 # 565 unset FLL_BLOCKDEVS FLL_BLOCKDEVS_NOW FLL_BLOCKDEVS_PROBED 566 567 # 568 # sleep time, we skip FLL_ROOTDELAY interval for first pass for extra fast boot 569 # 570 if [ "${FLL_MOUNT_LOOP}" ]; then 571 if [ "${FLL_MOUNT_LOOP}" = 1 ]; then 572 printf "${G}Waiting for up to ${Y}${FLL_ROOTDELAY}${G}s for devices to settle${N}...\n" 573 fi 574 sleep "${FLL_MOUNT_INTERVAL}" 575 FLL_ROOTDELAY=$(( ${FLL_ROOTDELAY} - ${FLL_MOUNT_INTERVAL} )) 576 fi 577 578 # 579 # mount loop counter, it enforces sleep interval on next loop 580 # 581 FLL_MOUNT_LOOP=$(( ${FLL_MOUNT_LOOP} + 1 )) 582 583 # 584 # determine block devices to be probed on this loop 585 # 586 if [ "${FLL_FROMHD_DEV}" ]; then 587 # 588 # user defined block device 589 # 590 case "${FLL_FROMHD_DEV}" in 591 LABEL=*) 592 FLL_BLOCKDEVS="/dev/disk/by-label/${FLL_FROMHD_DEV#LABEL=}" 593 ;; 594 UUID=*) 595 FLL_BLOCKDEVS="/dev/disk/by-uuid/${FLL_FROMHD_DEV#UUID=}" 596 ;; 597 *) 598 FLL_BLOCKDEVS="${FLL_FROMHD_DEV}" 599 ;; 600 esac 601 else 602 # 603 # current list of block devices that may be probed for live media 604 # 605 FLL_BLOCKDEVS_NOW=$(fll_finger_blockdevs) 606 # 607 # FLL_BLOCKDEVS_OLD accounts for all devices probed so, it appends a copy of 608 # FLL_BLOCKDEVS for every loop new devices are found 609 # FLL_BLOCKDEVS is always a list of new devices that have not been probed so far 610 # 611 if [ "${FLL_BLOCKDEVS_OLD}" ]; then 612 # 613 # compare all devices probed so far with list of devices discovered now 614 # 615 for dev in ${FLL_BLOCKDEVS_NOW}; do 616 if fll_string_not_in_strings ${dev} ${FLL_BLOCKDEVS_OLD}; then 617 # 618 # we have not yet probed these devices 619 # 620 FLL_BLOCKDEVS="${FLL_BLOCKDEVS} ${dev}" 621 fi 622 done 623 else 624 # 625 # no devices probed so far, probe all that are currently detectable at this time 626 # 627 FLL_BLOCKDEVS="${FLL_BLOCKDEVS_NOW}" 628 fi 629 fi 630 631 if [ -z "${FLL_BLOCKDEVS}" ]; then 632 continue 633 fi 634 635 for dev in ${FLL_BLOCKDEVS}; do 636 # 637 # FLL_BLOCKMNT - tracks current mount point 638 # 639 # FLL_DOUMOUNT - stack of mount points to be umounted at end of 640 # loop 641 # 642 # FLL_DOMOVEMOUNT - stack of mount points to be move mounted if the 643 # loop is broken 644 # 645 # FLL_MEDIA_FOUND - set only when we have the live media compressed 646 # filesystem located and mounted 647 # 648 unset FLL_BLOCKMNT FLL_DOUMOUNT FLL_DOMOVEMOUNT FLL_MEDIA_FOUND 649 650 # 651 # determine filesystem type of block device 652 # 653 if fll_finger_fstype "${dev}" >/dev/null 2>&1; then 654 if [ -z "${FLL_BLOCKDEVS_PROBED}" ]; then 655 printf "${G}Probing devices\t${N}" 656 fi 657 FLL_BLOCKDEVS_PROBED=$(( ${FLL_BLOCKDEVS_PROBED} + 1 )) 658 printf "${W}[${Y} ${dev##*/}${W} ]${N} " 659 # 660 # we have determined FSTYPE of the device, set FLL_BLOCKMNT 661 # 662 FLL_BLOCKMNT="/fll/${dev##*/}" 663 mkdir -p "${FLL_BLOCKMNT}" 664 # 665 # save origin of media in variable for persitency 666 # 667 if [ "${FLL_PERSIST}" = "yes" ]; then 668 FLL_PERSIST_BLOCKDEV="${dev}" 669 FLL_PERSIST_BLOCKFSTYPE="${FSTYPE}" 670 FLL_PERSIST_BLOCKMNT="${FLL_BLOCKMNT}" 671 fi 672 # 673 # mount block device on FLL_BLOCKMNT for probe 674 # 675 if fll_mount "${FSTYPE}" "${dev}" "${FLL_BLOCKMNT}" ro; then 676 # 677 # add current FLL_BLOCKMNT to FLL_DOMOVEMOUNT stack 678 # 679 FLL_DOMOVEMOUNT="${FLL_BLOCKMNT} ${FLL_DOMOVEMOUNT}" 680 # 681 # probe for iso image 682 # 683 if [ "${FLL_FROMISO}" = "yes" ]; then 684 if [ -f "${FLL_BLOCKMNT}/${FLL_MEDIA_NAME#/}" ]; then 685 # 686 # located iso, update dev description 687 # 688 FLL_MEDIA_FOUND="${dev}" 689 printf "\n\n" 690 printf "${G}Detected ${Y}${FLL_MEDIA_NAME}${G} " 691 printf "on ${Y}${FLL_MEDIA_FOUND##*/}${G}.${N}\n" 692 if fll_finger_fstype "${FLL_BLOCKMNT}/${FLL_MEDIA_NAME}" >/dev/null 2>&1; then 693 if [ "${FSTYPE}" != "iso9660" ]; then 694 panic "${Y}${FLL_MEDIA_NAME}${R} not an iso9660 filesystem${N}" 695 fi 696 mkdir -p /fll/fromiso 697 # 698 # loop mount iso on FLL_MEDIA_MOUNTPOINT 699 # 700 if fll_mount "${FSTYPE}" "${FLL_BLOCKMNT}/${FLL_MEDIA_NAME}" /fll/fromiso; then 701 if [ "${FLL_TORAM}" ]; then 702 # 703 # add block device mount point to umount stack 704 # 705 FLL_DOUMOUNT="${FLL_BLOCKMNT} ${FLL_DOUMOUNT}" 706 fi 707 # 708 # update FLL_BLOCKMNT, FLL_DOMOVEMOUNT stack, and dev description 709 # 710 FLL_BLOCKMNT="/fll/fromiso" 711 FLL_DOMOVEMOUNT="${FLL_BLOCKMNT} ${FLL_DOMOVEMOUNT}" 712 dev="iso" 713 else 714 fll_umount ${FLL_DOUMOUNT} 715 panic "${R}Failed to mount ${Y}${FSTYPE}${R} filesystem from iso image${N}" 716 fi 717 else 718 fll_umount ${FLL_DOUMOUNT} 719 panic "${R}Failed to identify filesystem type of iso${N}" 720 fi 721 fi 722 fi 723 # 724 # probe for compressed filesystem 725 # 726 if [ -f "${FLL_BLOCKMNT}/${FLL_IMAGE_LOCATION}" ]; then 727 # 728 # found FLL compressed filesystem 729 # set/update FLL_MEDIA_FOUND variable (possibly already set via fromiso) 730 # 731 if [ "${FLL_MEDIA_FOUND}" ]; then 732 printf "\n" 733 else 734 printf "\n\n" 735 fi 736 FLL_MEDIA_FOUND="${dev}" 737 # 738 # debug checkpoint 739 # 740 maybe_break fll-found 741 # 742 # md5sum check 743 # 744 if [ "${FLL_MD5SUM_CHECK}" = "yes" ]; then 745 printf "${G}Performing ${Y}md5sum${G} integrity check of live media${N}...\n\n" 746 if fll_md5sum_check ${FLL_BLOCKMNT}; then 747 printf "${G}All md5sums verified successfully.${N}\n\n" 748 else 749 fll_umount ${FLL_DOUMOUNT} 750 panic "${R}Failed md5sum check!${N}" 751 fi 752 fi 753 # 754 # prepare live filesystem 755 # 756 # Nasty hack, fll_finger_fstype can not detect squashfs-lzma 757 FSTYPE="squashfs" 758 if [ "${FSTYPE}" == "squashfs" ]; then 759 #if fll_finger_fstype "${FLL_BLOCKMNT}/${FLL_IMAGE_LOCATION}" >/dev/null 2>&1; then 760 printf "${G}Detected live ${Y}${FSTYPE}${G} " 761 printf "filesystem on ${Y}${FLL_MEDIA_FOUND}${N}\n" 762 # 763 # copy to tmpfs 764 # 765 if [ "${FLL_TORAM}" = "yes" ]; then 766 # 767 # required tmpfs size: compressed filesystem size + 10% buffer 768 # 769 eval $(fll_meminfo) 770 FLL_TORAM_FSSIZE=$(du -s "${FLL_BLOCKMNT}/${FLL_IMAGE_LOCATION}" | \ 771 awk '{ printf("%d\n", int($1 * 1.1 / 1024)) }') 772 # 773 # memory required to operate normally after iso has consumed memory 774 # at least 32M is required 775 # 776 FLL_TORAM_MEMREQ=$(( ${FLL_TORAM_FSSIZE} + 32 )) 777 # 778 # do we have enough free memory for toram? 779 # 780 if [ "${MEMFREE}" -gt "${FLL_TORAM_MEMREQ}" ]; then 781 # 782 # prepare tmpfs, aka ramdisk 783 # 784 mkdir -p /fll/toram 785 mount -n -t tmpfs -o size="${FLL_TORAM_FSSIZE}m" tmpfs /fll/toram 786 mkdir -p "/fll/toram/${FLL_IMAGE_DIR}" 787 # 788 # copy compressed filesystem to tmpfs 789 # 790 printf "${G}Copying live filesystem from ${Y}${dev}${G} to ${Y}ram${G}${N}...\n" 791 if fll_copy_with_perc "${FLL_BLOCKMNT}/${FLL_IMAGE_LOCATION}" "/fll/toram/${FLL_IMAGE_DIR}"; then 792 # 793 # add old mnt pnt to umount stack, update FLL_BLOCKMNT and dev 794 # 795 FLL_DOUMOUNT="${FLL_BLOCKMNT} ${FLL_DOUMOUNT}" 796 FLL_BLOCKMNT="/fll/toram" 797 FLL_DOMOVEMOUNT="${FLL_BLOCKMNT} ${FLL_DOMOVEMOUNT}" 798 dev="ram" 799 else 800 if [ "${FLL_FROMISO}" = "yes" ]; then 801 # 802 # we failed to copy iso contents to ram: reset FLL_DOUMOUNT stack 803 # 804 unset FLL_DOUMOUNT 805 fi 806 # 807 # umount the tmpfs or run-init will not be happy 808 # 809 rm -rf "/fll/toram/${FLL_IMAGE_DIR}" 810 fll_umount /fll/toram 811 printf "\n${G}Continuing boot from live media${N}...\n" 812 fi 813 else 814 printf "${R}Insufficient free memory to copy live media into memory${N}\n" 815 printf "${R}Required free memory: ${Y}${FLL_TORAM_MEMREQ}M${N}\n" 816 printf "\n${G}Continuing boot from live media${N}...\n" 817 if [ "${FLL_FROMISO}" = "yes" ]; then 818 # 819 # we failed to copy iso contents to ram: reset FLL_DOUMOUNT stack 820 # 821 unset FLL_DOUMOUNT 822 fi 823 fi 824 fi 825 # 826 # mount compressed filesystem, source directory: FLL_BLOCKMNT 827 # 828 mkdir -p "${FLL_MOUNTPOINT}" 829 if fll_mount "${FSTYPE}" "${FLL_BLOCKMNT}/${FLL_IMAGE_LOCATION}" "${FLL_MOUNTPOINT}"; then 830 if [ ! -e "${FLL_MOUNTPOINT}/boot/vmlinuz-$(uname -r)" ]; then 831 printf "${R}Kernel mismatch: ${Y}vmlinuz-$(uname -r)${R} not found on live filesystem.\n${N}" 832 printf "${R}Kernel(s) found on the live filesystem are:\n${N}" 833 for kernel in ${FLL_MOUNTPOINT}/boot/vmlinuz-*; do 834 [ -e "${kernel}" ] && printf "${Y}\t${kernel#*/boot/}\n${N}" 835 done 836 fll_umount ${FLL_DOUMOUNT} 837 printf "${R}You must use the correct vmlinuz version (and matching initrd.img) to boot successfully.\n${N}" 838 printf "${R}The correct vmlinuz and initrd.img files can be found in the /boot folder of live media.\n${N}" 839 panic 840 fi 841 printf "${G}Mounted ${Y}${FSTYPE}${G} filesystem on ${Y}${FLL_MOUNTPOINT}${N}\n\n" 842 FLL_DOMOVEMOUNT="${FLL_MOUNTPOINT} ${FLL_DOMOVEMOUNT}" 843 else 844 fll_umount ${FLL_DOUMOUNT} 845 panic "${R}Failed to mount ${Y}${FSTYPE}${R} filesystem${N}" 846 fi 847 else 848 fll_umount ${FLL_DOUMOUNT} 849 panic "${R}Failed to identify filesystem type of live media image${N}" 850 fi 851 else 852 # 853 # probe next device, add current mount to FLL_DOUMOUNT stack 854 # 855 FLL_DOUMOUNT="${FLL_BLOCKMNT} ${FLL_DOUMOUNT}" 856 fi 857 fi 858 fi 859 860 # 861 # umount mount points in FLL_DOUMOUNT stack 862 # 863 fll_umount ${FLL_DOUMOUNT} 864 865 # 866 # break upon successful mount of live-media 867 # 868 if [ "${FLL_MEDIA_FOUND}" ]; then 869 break 2 870 fi 871 done 872 873 # 874 # if we got here, we failed to find live media 875 # 876 877 if [ "${FLL_FROMHD_DEV}" ]; then 878 continue 879 fi 880 881 # 882 # keep account of what devices we have probed so far 883 # 884 FLL_BLOCKDEVS_OLD="${FLL_BLOCKDEVS_OLD} ${FLL_BLOCKDEVS}" 885 886 # 887 # start new probe line 888 # 889 printf "\n" 890 done 891 892 # 893 # panic on failure to detect live media 894 # 895 if [ -z "${FLL_MEDIA_FOUND}" ]; then 896 panic "${R}Failed to detect live media${N}" 897 fi 898 899 # 900 # debug checkpoint 901 # 902 maybe_break fll-postmount 903 904 # 905 # mount a tmpfs over $rootmnt, reserving 10% system memory 906 # Note: $rootmnt must be mounted with a fs != rootfs prior to run-init 907 # 908 printf "${G}Mounting virtual memory ${Y}tmpfs${G} filesystem on ${Y}${rootmnt}${G}${N}..." 909 if mount -n -t tmpfs -o size=90%,mode=755 tmpfs "${rootmnt}"; then 910 printf "\n" 911 else 912 panic "${R}Failed to mount tmpfs over ${Y}${rootmnt}${N}" 913 fi 914 915 # 916 # move all mounts in FLL_DOMOVEMOUNT stack to $rootmnt 917 # 918 if [ "${FLL_DOMOVEMOUNT}" ]; then 919 printf "${G}Moving all mounted filesystems to ${Y}${rootmnt}${G}${N}..." 920 for mnt in ${FLL_DOMOVEMOUNT}; do 921 if grep -q "${mnt}" /proc/mounts; then 922 mkdir -p "${rootmnt}${mnt}" 923 mount -n -o move "${mnt}" "${rootmnt}${mnt}" 924 fi 925 done 926 printf "\n" 927 fi 928 929 # 930 # sanity check, ${rootmnt}${FLL_MOUNTPOINT} _must_ exist 931 # 932 if [ ! -d "${rootmnt}${FLL_MOUNTPOINT}" ]; then 933 panic "${R}Failed to find ${Y}${FLL_MOUNTPOINT}${G} on ${Y}${rootmnt}${N}" 934 fi 935 936 if [ -z "${FLL_UNION_MODULE}" ]; then 937 FLL_UNION_MODULE="aufs" 938 fi 939 940 #if modprobe "${MODPROBE_OPTIONS}" "${FLL_UNION_MODULE}"; then 941 # : # union filesystem support 942 #else 943 # panic "${R}Failed to load union filesystem support: ${Y}${FLL_UNION_MODULE}${N}" 944 #fi 945 modprobe "${MODPROBE_OPTIONS}" "${FLL_UNION_MODULE}" >/dev/null 2>&1 946 947 # 948 # unioned filesystem mount points 949 # persist may already have set FLL_UNION_COWDIR 950 # 951 FLL_UNION_MOUNTPOINT="/fll/${FLL_UNION_MODULE}" 952 [ -z "$FLL_UNION_COWDIR" ] && FLL_UNION_COWDIR="/fll/cow" 953 954 # 955 # prepare COW union filesystem, handle persistency 956 # 957 if [ "${FLL_PERSIST}" = "yes" ] && [ "${FLL_PERSIST_BLOCKMNT}" ]; then 958 case "${FLL_PERSIST_BLOCKFSTYPE}" in 959 ext*|reiser*|xfs|jfs|msdos|vfat) 960 # 961 # FLL_PERSIST_BLOCKMNT points to position of mounted fielsystem before it was moved 962 # to the new root filesystem. Prepend ${rootmnt}. 963 # 964 FLL_UNION_COWMNTPNT="${rootmnt}${FLL_PERSIST_BLOCKMNT}" 965 mkdir -p "${FLL_UNION_COWMNTPNT}" 966 # 967 # remount original fs containing live media rw (toram would umount it) 968 # 969 if grep -q "${FLL_UNION_COWMNTPNT}" /proc/mounts && mount -o remount,rw "${FLL_UNION_COWMNTPNT}" || \ 970 fll_mount ${FLL_PERSIST_BLOCKFSTYPE} ${FLL_PERSIST_BLOCKDEV} ${FLL_UNION_COWMNTPNT} rw; then 971 printf "${G}Remounting persistent filesystem on ${Y}${FLL_PERSIST_BLOCKDEV##*/}${G}${N}...\n" 972 else 973 panic "${R}Failed to remount persistent filesystem on ${Y}${FLL_PERSIST_DEV##*/}${N}" 974 fi 975 # 976 # mount a persistent filesystem-in-a-file on microsoft filesystems 977 # 978 if [ "${FLL_PERSIST_BLOCKFSTYPE}" = "msdos" ] || [ "${FLL_PERSIST_BLOCKFSTYPE}" = "vfat" ]; then 979 if [ -f "${FLL_UNION_COWMNTPNT}/${FLL_PERSIST_FILE}" ] && \ 980 fll_finger_fstype "${FLL_UNION_COWMNTPNT}/${FLL_PERSIST_FILE}"; then 981 printf "${G}Mounting ${Y}${FLL_PERSIST_FILE}${G} filesystem-in-a-file${N}..." 982 # 983 # identify filesystem of loopback file, mount it and update FLL_UNION_COWMNTPNT 984 # 985 mkdir -p "${rootmnt}/fll/persist" 986 if fll_mount "${FSTYPE}" "${FLL_UNION_COWMNTPNT}/${FLL_PERSIST_FILE}" \ 987 "${rootmnt}/fll/persist" loop; then 988 printf "\n" 989 FLL_UNION_COWMNTPNT="${rootmnt}/fll/persist" 990 # 991 # We have now found a persistent file setup 992 # We can revert any custom cowdir set by persist 993 # 994 FLL_UNION_COWDIR="/fll/cow" 995 else 996 panic "${R}Failed to mount ${Y}${FLL_PERSIST_FILE}${R} persistent filesystem-in-a-file${N}" 997 fi 998 else 999 panic "${R}Invalid/missing ${Y}${FLL_PERSIST_FILE}${R} persistent filesystem-in-a-file${N}" 1000 fi 1001 fi 1002 ;; 1003 *) 1004 # 1005 # we could support vfat|msdos with a loop mounted ext* filesystem-in-a-file 1006 # 1007 panic "${R}Cannot create persistent filesystem with type ${Y}${FLL_PERSIST_BLOCKFSTYPE}${N}" 1008 ;; 1009 esac 1010 else 1011 FLL_UNION_COWMNTPNT="${rootmnt}" 1012 fi 1013 1014 mkdir -p "${rootmnt}${FLL_UNION_MOUNTPOINT}" "${FLL_UNION_COWMNTPNT}${FLL_UNION_COWDIR}" 1015 1016 # 1017 # union module specific options 1018 # 1019 case "${FLL_UNION_MODULE}" in 1020 aufs) 1021 FLL_UNION_OPTIONS="br:${FLL_UNION_COWMNTPNT}${FLL_UNION_COWDIR}:${rootmnt}${FLL_MOUNTPOINT}" 1022 ;; 1023 unionfs) 1024 FLL_UNION_OPTIONS="dirs=${FLL_UNION_COWMNTPNT}${FLL_UNION_COWDIR}=rw:${rootmnt}${FLL_MOUNTPOINT}=ro" 1025 ;; 1026 esac 1027 1028 # 1029 # mount the union COW filesystem 1030 # 1031 printf "${G}Mounting ${Y}${FLL_UNION_MODULE}${G} union filesystem${N}..." 1032 if mount -t "${FLL_UNION_MODULE}" -o "${FLL_UNION_OPTIONS}" "${FLL_UNION_MODULE}" "${rootmnt}${FLL_UNION_MOUNTPOINT}"; then 1033 printf "\n" 1034 else 1035 panic "${R}Failed to prepare ${Y}${FLL_UNION_MODULE}${R} union filesystem${N}" 1036 fi 1037 1038 # 1039 # debug checkpoint 1040 # 1041 maybe_break fll-unionmount 1042 1043 printf "${G}Preparing live filesystem on ${Y}${rootmnt}${G}${N}...\n" 1044 1045 # 1046 # create links on $rootmnt to real filesystem 1047 # 1048 for dir in ${rootmnt}${FLL_UNION_MOUNTPOINT}/*; do 1049 if [ -d "${dir}" ]; then 1050 case "${dir##*/}" in 1051 dev|proc|sys|tmp) 1052 # 1053 # these should stay out of the unioned filesystem mount point 1054 # keep them directly on the ramdisk, they are handled below 1055 # 1056 continue 1057 ;; 1058 *) 1059 # 1060 # link everything else to read-write unioned filesystem 1061 # 1062 if [ -L "${dir}" ]; then 1063 # 1064 # /lib64 -> /lib symlink handling 1065 # 1066 ln -sf "$(readlink ${dir})" "${rootmnt}/${dir##*/}" 1067 else 1068 # 1069 # bind mount links to read write union 1070 # 1071 mkdir -p "${rootmnt}/${dir##*/}" 1072 mount -n -o bind "${dir}" "${rootmnt}/${dir##*/}" 1073 fi 1074 ;; 1075 esac 1076 fi 1077 done 1078 1079 # 1080 # debug checkpoint 1081 # 1082 maybe_break fll-bindmount 1083 1084 # 1085 # prepare /proc /sys and /selinux 1086 # 1087 for dir in proc sys selinux; do 1088 mkdir -p "${rootmnt}/${dir}" 1089 done 1090 1091 # 1092 # tmp with correct permissions for users 1093 # 1094 mkdir -p -m 1777 "${rootmnt}/tmp" 1095 1096 # 1097 # prepare /dev 1098 # 1099 mkdir -p -m 0755 "${rootmnt}/dev" 1100 1101 # 1102 # debug checkpoint 1103 # 1104 maybe_break fll-bottom 1105 1106 # 1107 # alsa should not be persistent 1108 # 1109 rm -f ${rootmnt}/var/lib/alsa/asound.state 1110 1111 # 1112 # disable persistent udev rules. we have "persistency" logic for data but 1113 # we should remain hardware agnostic 1114 # 1115 rm -f ${rootmnt}/etc/udev/rules.d/z25_persistent-*.rules 1116 1117 # 1118 # disable movement of static $rootmnt/dev by scripts/init-bottom/udev 1119 # 1120 export no_static_dev="1" 1121 1122 # 1123 # workaround cosmetic issue with selinux on live boot. It is doubtful that 1124 # anyone would find selinux a useful feature to have on an live-cd 1125 # 1126 1127 export SELINUX_INIT=NO 1128 1129 printf "\n${G}Starting ${Y}init${G} process${N}...\n\n" 1130 } 1131 ############################################################################### 609 # 610 # Print kernel info 611 # 612 #printf "${G}Linux Kernel\t${W}[ ${Y}$(uname -r)${W} ]${N}\n" 613 614 # 615 # Print CPU info 616 # 617 #fll_cpuinfo 618 619 # 620 # Print System Memory info 621 # 622 eval $(fll_meminfo) 623 printf "${G}System Memory\t${W}" 624 printf "[ ${Y}${MEMUSED}M used ${W}] " 625 printf "[ ${Y}${MEMFREE}M free${W} ] " 626 printf "[ ${Y}${MEMTOTAL}M total${W} ]" 627 printf "${N}\n" 628 629 # 630 # Run scripts in local-top, like lvm2 631 # 632 [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top" 633 run_scripts /scripts/local-top 634 [ "$quiet" != "y" ] && log_end_msg 635 636 # 637 # debug checkpoint 638 # 639 maybe_break fll-premount 640 641 # 642 # total time in seconds to do device scans for; rootdelay= on kernel cmdline 643 # upper limit on how long we wait for devices to show up before bailing out 644 # 645 if [ "${ROOTDELAY}" ] && [ "${ROOTDELAY}" -gt 0 ]; then 646 FLL_ROOTDELAY="${ROOTDELAY}" 647 else 648 FLL_ROOTDELAY="30" 649 fi 650 651 # 652 # interval between device scans 653 # 654 FLL_MOUNT_INTERVAL="3" 655 656 # 657 # these variables are created during $FLL_ROOTDELAY time loop 658 # 659 unset FLL_MOUNT_LOOP 660 661 while [ "${FLL_ROOTDELAY}" -gt 0 ]; do 662 # 663 # refresh these for each loop 664 # 665 unset FLL_BLOCKDEVS 666 667 # 668 # sleep time, we skip FLL_ROOTDELAY interval for first pass for extra fast boot 669 # 670 if [ "${FLL_MOUNT_LOOP}" ]; then 671 if [ "${FLL_MOUNT_LOOP}" -eq 1 ]; then 672 printf "${G}Waiting for up to ${Y}${FLL_ROOTDELAY}${G}s for devices to settle${N}...\n" 673 fi 674 sleep "${FLL_MOUNT_INTERVAL}" 675 FLL_ROOTDELAY=$(( ${FLL_ROOTDELAY} - ${FLL_MOUNT_INTERVAL} )) 676 fi 677 678 # 679 # mount loop counter, it enforces sleep interval on next loop 680 # 681 FLL_MOUNT_LOOP=$(( ${FLL_MOUNT_LOOP} + 1 )) 682 683 # 684 # determine block devices to be probed on this loop 685 # 686 if [ "${FLL_FROMHD_DEV}" ]; then 687 # 688 # user defined block device 689 # 690 case "${FLL_FROMHD_DEV}" in 691 LABEL=*) 692 FLL_BLOCKDEVS="/dev/disk/by-label/${FLL_FROMHD_DEV#LABEL=}" 693 ;; 694 UUID=*) 695 FLL_BLOCKDEVS="/dev/disk/by-uuid/${FLL_FROMHD_DEV#UUID=}" 696 ;; 697 /dev/mapper/*) 698 lvm vgchange -aly --ignorelockingfailure 699 FLL_BLOCKDEVS="${FLL_FROMHD_DEV}" 700 ;; 701 *) 702 FLL_BLOCKDEVS="${FLL_FROMHD_DEV}" 703 ;; 704 esac 705 else 706 # 707 # current list of block devices that may be probed for live media 708 # 709 FLL_BLOCKDEVS=$(fll_finger_blockdevs) 710 fi 711 712 if [ -z "${FLL_BLOCKDEVS}" ]; then 713 continue 714 fi 715 716 FLL_BLOCKDEVS_PROBED=false 717 718 for dev in ${FLL_BLOCKDEVS}; do 719 # 720 # FLL_BLOCKMNT - tracks current mount point 721 # 722 # FLL_DOUMOUNT - stack of mount points to be umounted at end of 723 # loop 724 # 725 # FLL_DOMOVEMOUNT - stack of mount points to be move mounted if the 726 # loop is broken 727 # 728 # FLL_MEDIA_FOUND - set only when we have the live media compressed 729 # filesystem located and mounted 730 # 731 unset FLL_BLOCKMNT FLL_DOUMOUNT FLL_DOMOVEMOUNT FLL_MEDIA_FOUND 732 733 # 734 # determine filesystem type of block device 735 # 736 if fll_finger_fstype "${dev}" >/dev/null 2>&1; then 737 if ! ${FLL_BLOCKDEVS_PROBED}; then 738 printf "${G}Probing devices\t${N}" 739 FLL_BLOCKDEVS_PROBED=true 740 fi 741 printf "${W}[${Y} ${dev#/dev/}${W} ]${N} " 742 # 743 # we have determined FSTYPE of the device, set FLL_BLOCKMNT 744 # 745 FLL_BLOCKMNT="/fll/${dev##*/}" 746 mkdir -p "${FLL_BLOCKMNT}" 747 # 748 # save origin of media in variable for persitency 749 # 750 if [ "${FLL_PERSIST}" = "yes" ]; then 751 FLL_PERSIST_BLOCKDEV="${dev}" 752 FLL_PERSIST_BLOCKFSTYPE="${FSTYPE}" 753 FLL_PERSIST_BLOCKMNT="${FLL_BLOCKMNT}" 754 fi 755 # 756 # mount block device on FLL_BLOCKMNT for probe 757 # 758 if fll_mount "${FSTYPE}" "${dev}" "${FLL_BLOCKMNT}" ro; then 759 # 760 # add current FLL_BLOCKMNT to FLL_DOMOVEMOUNT stack 761 # 762 FLL_DOMOVEMOUNT="${FLL_BLOCKMNT} ${FLL_DOMOVEMOUNT}" 763 # 764 # probe for iso image 765 # 766 if [ "${FLL_FROMISO}" = "yes" ]; then 767 if [ -f "${FLL_BLOCKMNT}/${FLL_MEDIA_NAME#/}" ]; then 768 # 769 # located iso, update dev description 770 # 771 FLL_MEDIA_FOUND="${dev}" 772 printf "\n\n" 773 printf "${G}Detected ${Y}${FLL_MEDIA_NAME}${G} " 774 printf "on ${Y}${FLL_MEDIA_FOUND#/dev/}${G}.${N}\n" 775 if fll_finger_fstype "${FLL_BLOCKMNT}/${FLL_MEDIA_NAME}" >/dev/null 2>&1; then 776 if [ "${FSTYPE}" != "iso9660" ]; then 777 panic "${Y}${FLL_MEDIA_NAME}${R} not an iso9660 filesystem${N}" 778 fi 779 mkdir -p /fll/fromiso 780 # 781 # loop mount iso on FLL_MEDIA_MOUNTPOINT 782 # 783 if fll_mount "${FSTYPE}" "${FLL_BLOCKMNT}/${FLL_MEDIA_NAME}" /fll/fromiso; then 784 if [ "${FLL_TORAM}" ]; then 785 # 786 # add block device mount point to umount stack 787 # 788 FLL_DOUMOUNT="${FLL_BLOCKMNT} ${FLL_DOUMOUNT}" 789 fi 790 # 791 # update FLL_BLOCKMNT, FLL_DOMOVEMOUNT stack 792 # 793 FLL_BLOCKMNT="/fll/fromiso" 794 FLL_DOMOVEMOUNT="${FLL_BLOCKMNT} ${FLL_DOMOVEMOUNT}" 795 else 796 fll_umount ${FLL_DOUMOUNT} 797 panic "${R}Failed to mount ${Y}${FSTYPE}${R} filesystem from iso image${N}" 798 fi 799 else 800 fll_umount ${FLL_DOUMOUNT} 801 panic "${R}Failed to identify filesystem type of iso${N}" 802 fi 803 printf "\n" 804 fi 805 fi 806 # 807 # probe for compressed filesystem 808 # 809 if [ -f "${FLL_BLOCKMNT}/${FLL_IMAGE_LOCATION}" ]; then 810 # 811 # found FLL compressed filesystem 812 # set/update FLL_MEDIA_FOUND variable (possibly already set via fromiso) 813 # 814 if [ -z "${FLL_MEDIA_FOUND}" ]; then 815 printf "\n\n" 816 FLL_MEDIA_FOUND="${dev}" 817 fi 818 # 819 # debug checkpoint 820 # 821 maybe_break fll-found 822 # 823 # md5sum check 824 # 825 if [ "${FLL_MD5SUM_CHECK}" = "yes" ]; then 826 printf "${G}Performing ${Y}md5sum${G} integrity check of live media${N}...\n\n" 827 if fll_md5sum_check ${FLL_BLOCKMNT}; then 828 printf "${G}All md5sums verified successfully.${N}\n\n" 829 else 830 fll_umount ${FLL_DOUMOUNT} 831 panic "${R}Failed md5sum check!${N}" 832 fi 833 fi 834 # 835 # prepare live filesystem 836 # 837 if fll_finger_fstype "${FLL_BLOCKMNT}/${FLL_IMAGE_LOCATION}" >/dev/null 2>&1; then 838 printf "${G}Detected live ${Y}${FSTYPE}${G} " 839 if [ "${FLL_FROMISO}" = "yes" ]; then 840 printf "filesystem on ${Y}${FLL_MEDIA_NAME}${N}\n" 841 else 842 printf "filesystem on ${Y}${FLL_MEDIA_FOUND}${N}\n" 843 fi 844 # 845 # copy to tmpfs 846 # 847 if [ "${FLL_TORAM}" = "yes" ]; then 848 # 849 # required tmpfs size: compressed filesystem size + 10% buffer 850 # 851 eval $(fll_meminfo) 852 # ls -l returns units in Bytes, divide by (1024*1024) to convert to MB 853 FLL_TORAM_FSSIZE=$(ls -l "${FLL_BLOCKMNT}/${FLL_IMAGE_LOCATION}" | \ 854 awk '{ printf("%d\n", int($5 * 1.1 / 1048576)) }') 855 # 856 # memory required to operate normally after iso has consumed memory 857 # at least 32M is required 858 # 859 FLL_TORAM_MEMREQ=$(( ${FLL_TORAM_FSSIZE} + 32 )) 860 # 861 # do we have enough free memory for toram? 862 # 863 if [ "${MEMFREE}" -gt "${FLL_TORAM_MEMREQ}" ]; then 864 # 865 # prepare tmpfs, aka ramdisk 866 # 867 mkdir -p /fll/toram 868 mount -n -t tmpfs -o size="${FLL_TORAM_FSSIZE}m" tmpfs /fll/toram 869 mkdir -p "/fll/toram/${FLL_IMAGE_DIR}" 870 # 871 # copy compressed filesystem to tmpfs 872 # 873 printf "${G}Copying live filesystem from ${Y}${dev#/dev/}${G} to ${Y}ram${G}${N}...\n" 874 if fll_copy_with_perc "${FLL_BLOCKMNT}/${FLL_IMAGE_LOCATION}" "/fll/toram/${FLL_IMAGE_DIR}"; then 875 # 876 # add old mnt pnt to umount stack, update FLL_BLOCKMNT 877 # 878 FLL_DOUMOUNT="${FLL_BLOCKMNT} ${FLL_DOUMOUNT}" 879 FLL_BLOCKMNT="/fll/toram" 880 FLL_DOMOVEMOUNT="${FLL_BLOCKMNT} ${FLL_DOMOVEMOUNT}" 881 else 882 if [ "${FLL_FROMISO}" = "yes" ]; then 883 # 884 # we failed to copy iso contents to ram: reset FLL_DOUMOUNT stack 885 # 886 unset FLL_DOUMOUNT 887 fi 888 # 889 # umount the tmpfs or run-init will not be happy 890 # 891 rm -rf "/fll/toram/${FLL_IMAGE_DIR}" 892 fll_umount /fll/toram 893 printf "\n${G}Continuing boot from live media${N}...\n" 894 fi 895 else 896 printf "${R}Insufficient free memory to copy live media into memory${N}\n" 897 printf "${R}Required free memory: ${Y}${FLL_TORAM_MEMREQ}M${N}\n" 898 printf "\n${G}Continuing boot from live media${N}...\n" 899 if [ "${FLL_FROMISO}" = "yes" ]; then 900 # 901 # we failed to copy iso contents to ram: reset FLL_DOUMOUNT stack 902 # 903 unset FLL_DOUMOUNT 904 fi 905 fi 906 fi 907 # 908 # mount compressed filesystem, source directory: FLL_BLOCKMNT 909 # 910 mkdir -p "${FLL_MOUNTPOINT}" 911 if fll_mount "${FSTYPE}" "${FLL_BLOCKMNT}/${FLL_IMAGE_LOCATION}" "${FLL_MOUNTPOINT}"; then 912 if fll_check_kernel "${FLL_MOUNTPOINT}" ; then 913 printf "${R}Kernel mismatch: ${Y}kernel $(uname -r)${R} not found on live filesystem.\n${N}" 914 printf "${R}Kernel(s) found on the live filesystem are:\n${N}" 915 for kernel in ${FLL_MOUNTPOINT}/boot/vmlinu[xz]-*; do 916 [ -e "${kernel}" ] && printf "${Y}\t${kernel#*/boot/}\n${N}" 917 done 918 fll_umount ${FLL_DOUMOUNT} 919 printf "${R}You must use the correct linux version (and matching initrd.img) to boot successfully.\n${N}" 920 printf "${R}The correct linux and initrd.img files can be found in the /boot folder of live media.\n${N}" 921 panic 922 fi 923 printf "${G}Mounted ${Y}${FSTYPE}${G} filesystem on ${Y}${FLL_MOUNTPOINT}${N}\n\n" 924 FLL_DOMOVEMOUNT="${FLL_MOUNTPOINT} ${FLL_DOMOVEMOUNT}" 925 else 926 fll_umount ${FLL_DOUMOUNT} 927 panic "${R}Failed to mount ${Y}${FSTYPE}${R} filesystem${N}" 928 fi 929 else 930 fll_umount ${FLL_DOUMOUNT} 931 panic "${R}Failed to identify filesystem type of live media image${N}" 932 fi 933 else 934 # 935 # probe next device, add current mount to FLL_DOUMOUNT stack 936 # 937 FLL_DOUMOUNT="${FLL_BLOCKMNT} ${FLL_DOUMOUNT}" 938 fi 939 fi 940 fi 941 942 # 943 # umount mount points in FLL_DOUMOUNT stack 944 # 945 fll_umount ${FLL_DOUMOUNT} 946 947 # 948 # break upon successful mount of live-media 949 # 950 if [ "${FLL_MEDIA_FOUND}" ]; then 951 break 2 952 fi 953 done 954 955 # 956 # if we got here, we failed to find live media 957 # 958 959 if [ "${FLL_FROMHD_DEV}" ]; then 960 continue 961 fi 962 963 # 964 # start new probe line 965 # 966 printf "\n" 967 done 968 969 # 970 # panic on failure to detect live media 971 # 972 if [ -z "${FLL_MEDIA_FOUND}" ]; then 973 panic "${R}Failed to detect live media${N}" 974 fi 975 976 # 977 # debug checkpoint 978 # 979 maybe_break fll-postmount 980 981 # 982 # mount a tmpfs over $rootmnt, reserving 10% system memory 983 # Note: $rootmnt must be mounted with a fs != rootfs prior to run-init 984 # 985 printf "${G}Mounting virtual memory ${Y}tmpfs${G} filesystem on ${Y}${rootmnt}${G}${N}..." 986 if mount -n -t tmpfs -o size=90%,mode=755 tmpfs "${rootmnt}"; then 987 printf "\n" 988 else 989 panic "${R}Failed to mount tmpfs over ${Y}${rootmnt}${N}" 990 fi 991 992 # 993 # move all mounts in FLL_DOMOVEMOUNT stack to $rootmnt 994 # 995 if [ "${FLL_DOMOVEMOUNT}" ]; then 996 printf "${G}Moving all mounted filesystems to ${Y}${rootmnt}${G}${N}..." 997 for mnt in ${FLL_DOMOVEMOUNT}; do 998 if grep -q "${mnt}" /proc/mounts; then 999 mkdir -p "${rootmnt}${mnt}" 1000 mount -n -o move "${mnt}" "${rootmnt}${mnt}" 1001 fi 1002 done 1003 printf "\n" 1004 fi 1005 1006 # 1007 # sanity check, ${rootmnt}${FLL_MOUNTPOINT} _must_ exist 1008 # 1009 if [ ! -d "${rootmnt}${FLL_MOUNTPOINT}" ]; then 1010 panic "${R}Failed to find ${Y}${FLL_MOUNTPOINT}${G} on ${Y}${rootmnt}${N}" 1011 fi 1012 1013 if [ -z "${FLL_UNION_MODULE}" ]; then 1014 FLL_UNION_MODULE="aufs" 1015 fi 1016 1017 modprobe "${MODPROBE_OPTIONS}" "${FLL_UNION_MODULE}" >/dev/null 2>&1 1018 1019 # 1020 # unioned filesystem mount points 1021 # persist may already have set FLL_UNION_COWDIR 1022 # 1023 FLL_UNION_MOUNTPOINT="/fll/${FLL_UNION_MODULE}" 1024 [ -z "$FLL_UNION_COWDIR" ] && FLL_UNION_COWDIR="/fll/cow" 1025 1026 # 1027 # prepare COW union filesystem, handle persistency 1028 # 1029 if [ "${FLL_PERSIST}" = "yes" ] && [ "${FLL_PERSIST_BLOCKMNT}" ]; then 1030 case "${FLL_PERSIST_BLOCKFSTYPE}" in 1031 ext*|reiser*|xfs|jfs|msdos|vfat) 1032 # 1033 # FLL_PERSIST_BLOCKMNT points to position of mounted fielsystem before it was moved 1034 # to the new root filesystem. Prepend ${rootmnt}. 1035 # 1036 FLL_UNION_COWMNTPNT="${rootmnt}${FLL_PERSIST_BLOCKMNT}" 1037 mkdir -p "${FLL_UNION_COWMNTPNT}" 1038 # 1039 # remount original fs containing live media rw (toram would umount it) 1040 # 1041 if grep -q "${FLL_UNION_COWMNTPNT}" /proc/mounts && mount -o remount,rw "${FLL_UNION_COWMNTPNT}" || \ 1042 fll_mount ${FLL_PERSIST_BLOCKFSTYPE} ${FLL_PERSIST_BLOCKDEV} ${FLL_UNION_COWMNTPNT} rw; then 1043 printf "${G}Remounting persistent filesystem on ${Y}${FLL_PERSIST_BLOCKDEV#/dev/}${G}${N}...\n" 1044 else 1045 panic "${R}Failed to remount persistent filesystem on ${Y}${FLL_PERSIST_DEV#/dev/}${N}" 1046 fi 1047 # 1048 # mount a persistent filesystem-in-a-file on microsoft filesystems 1049 # 1050 if [ "${FLL_PERSIST_BLOCKFSTYPE}" = "msdos" ] || [ "${FLL_PERSIST_BLOCKFSTYPE}" = "vfat" ]; then 1051 if [ -f "${FLL_UNION_COWMNTPNT}/${FLL_PERSIST_FILE}" ] && \ 1052 fll_finger_fstype "${FLL_UNION_COWMNTPNT}/${FLL_PERSIST_FILE}"; then 1053 printf "${G}Mounting ${Y}${FLL_PERSIST_FILE}${G} filesystem-in-a-file${N}..." 1054 # 1055 # identify filesystem of loopback file, mount it and update FLL_UNION_COWMNTPNT 1056 # 1057 mkdir -p "${rootmnt}/fll/persist" 1058 if fll_mount "${FSTYPE}" "${FLL_UNION_COWMNTPNT}/${FLL_PERSIST_FILE}" \ 1059 "${rootmnt}/fll/persist" loop; then 1060 printf "\n" 1061 FLL_UNION_COWMNTPNT="${rootmnt}/fll/persist" 1062 # 1063 # We have now found a persistent file setup 1064 # We can revert any custom cowdir set by persist 1065 # 1066 FLL_UNION_COWDIR="/fll/cow" 1067 else 1068 panic "${R}Failed to mount ${Y}${FLL_PERSIST_FILE}${R} persistent filesystem-in-a-file${N}" 1069 fi 1070 else 1071 panic "${R}Invalid/missing ${Y}${FLL_PERSIST_FILE}${R} persistent filesystem-in-a-file${N}" 1072 fi 1073 fi 1074 ;; 1075 *) 1076 # 1077 # we could support vfat|msdos with a loop mounted ext* filesystem-in-a-file 1078 # 1079 panic "${R}Cannot create persistent filesystem with type ${Y}${FLL_PERSIST_BLOCKFSTYPE}${N}" 1080 ;; 1081 esac 1082 else 1083 FLL_UNION_COWMNTPNT="${rootmnt}" 1084 fi 1085 1086 mkdir -p "${rootmnt}${FLL_UNION_MOUNTPOINT}" "${FLL_UNION_COWMNTPNT}${FLL_UNION_COWDIR}" 1087 1088 # 1089 # union module specific options 1090 # 1091 case "${FLL_UNION_MODULE}" in 1092 aufs) 1093 FLL_UNION_OPTIONS="br:${FLL_UNION_COWMNTPNT}${FLL_UNION_COWDIR}:${rootmnt}${FLL_MOUNTPOINT}" 1094 ;; 1095 unionfs) 1096 FLL_UNION_OPTIONS="dirs=${FLL_UNION_COWMNTPNT}${FLL_UNION_COWDIR}=rw:${rootmnt}${FLL_MOUNTPOINT}=ro" 1097 ;; 1098 esac 1099 1100 # 1101 # mount the union COW filesystem 1102 # 1103 printf "${G}Mounting ${Y}${FLL_UNION_MODULE}${G} union filesystem${N}..." 1104 if mount -t "${FLL_UNION_MODULE}" -o "${FLL_UNION_OPTIONS}" "${FLL_UNION_MODULE}" "${rootmnt}${FLL_UNION_MOUNTPOINT}"; then 1105 printf "\n" 1106 else 1107 panic "${R}Failed to prepare ${Y}${FLL_UNION_MODULE}${R} union filesystem${N}" 1108 fi 1109 1110 # 1111 # debug checkpoint 1112 # 1113 maybe_break fll-unionmount 1114 1115 printf "${G}Preparing live filesystem on ${Y}${rootmnt}${G}${N}...\n" 1116 1117 # 1118 # create links on $rootmnt to real filesystem 1119 # 1120 for dir in ${rootmnt}${FLL_UNION_MOUNTPOINT}/*; do 1121 if [ -d "${dir}" ]; then 1122 case "${dir##*/}" in 1123 dev|media|proc|sys|tmp) 1124 # 1125 # these should stay out of the unioned filesystem mount point 1126 # keep them directly on the ramdisk, they are handled below 1127 # 1128 continue 1129 ;; 1130 *) 1131 # 1132 # link everything else to read-write unioned filesystem 1133 # 1134 if [ -L "${dir}" ]; then 1135 # 1136 # /lib64 -> /lib symlink handling 1137 # 1138 ln -sf "$(readlink ${dir})" "${rootmnt}/${dir##*/}" 1139 else 1140 # 1141 # bind mount links to read write union 1142 # 1143 mkdir -p "${rootmnt}/${dir##*/}" 1144 mount -n -o bind "${dir}" "${rootmnt}/${dir##*/}" 1145 fi 1146 ;; 1147 esac 1148 fi 1149 done 1150 1151 # Scan for firmware if requested 1152 if [ -n "$FLL_FIRMWARE" ]; then 1153 # FLL_FIRMWARE_FOUND is set once the firmware is found (and copied) 1154 unset FLL_FIRMWARE_FOUND 1155 # start by checking mounted fs 1156 # they have been moved by now to ${rootmnt}/fll/ 1157 # FLL_FIRMMNTS holds "devices" which have been checked 1158 unset FLL_FIRMMNTS 1159 for dev in $(ls -d ${rootmnt}/fll/*) ; do 1160 if [ -d ${dev} ]; then 1161 FLL_FIRMMNTS="${FLL_FIRMMNTS} ${dev##*/}" 1162 if [ -d ${dev}/${FLL_IMAGE_DIR}/firmware ]; then 1163 FLL_FIRMWARE_FOUND="${dev}" 1164 if cp -r ${dev}/${FLL_IMAGE_DIR}/firmware/* ${rootmnt}/lib/firmware/ ; then 1165 printf "${G}Copied firmware from ${Y}${dev##*/}${N}\n" 1166 fi 1167 break 1168 fi 1169 fi 1170 done 1171 # means firmware is not on a mounted fs 1172 if [ -z "${FLL_FIRMWARE_FOUND}" ]; then 1173 fll_firmware 1174 fi 1175 fi 1176 1177 # 1178 # debug checkpoint 1179 # 1180 maybe_break fll-bindmount 1181 1182 # 1183 # prepare /dev /media /proc /sys and /selinux 1184 # 1185 for dir in dev media proc sys selinux; do 1186 mkdir -p -m 0755 "${rootmnt}/${dir}" 1187 done 1188 1189 # 1190 # tmp with correct permissions for users 1191 # 1192 mkdir -m 1777 "${rootmnt}/tmp" 1193 1194 #printf "${G}Reconfiguring ${Y}sysvinit runlevels${G} for live boot${N}...\n" 1195 # 1196 # sanitise live SysV runlevel configuration 1197 # 1198 #if [ ! -f "${rootmnt}/etc/default/fll-init" ]; then 1199 # panic "${R}fll-init initscript blacklist not found${N}" 1200 #fi 1201 1202 #while read i; do 1203 # if [ -x "${rootmnt}/etc/init.d/${i}" ]; then 1204 # rm -f ${rootmnt}/etc/rc[0-6S]\.d/[SK]??${i} 1205 # fi 1206 #done < "${rootmnt}/etc/default/fll-init" 1207 1208 #rm -f ${rootmnt}/etc/rc[06].d/K??irqbalance 1209 1210 # 1211 # debug checkpoint 1212 # 1213 maybe_break fll-bottom 1214 1215 # 1216 # alsa should not be persistent 1217 # 1218 rm -f ${rootmnt}/var/lib/alsa/asound.state 1219 1220 # 1221 # disable persistent udev rules. we have "persistency" logic for data but 1222 # we should remain hardware agnostic 1223 # 1224 rm -f ${rootmnt}/etc/udev/rules.d/70-persistent-*.rules 1225 1226 # 1227 # canonicalize device node if symlink to get correct kernel name for device 1228 # currently, this is only done for /dev/disk/by-* symlinks, but it could 1229 # be done for any symlink ([ -L "${FLL_MEDIA_FOUND}" ]), however this 1230 # seems to cause problem for /dev/sr0|/dev/scd0 links 1231 # 1232 case "${FLL_MEDIA_FOUND}" in 1233 /dev/disk/by-*) 1234 FLL_MEDIA_FOUND="$(freadlink ${FLL_MEDIA_FOUND})" 1235 ;; 1236 esac 1237 1238 # 1239 # create udev rule for persistent symlink to device live media was found on 1240 # 1241 printf "KERNEL==\"%s\", SYMLINK+=\"fll\"\n" \ 1242 "${FLL_MEDIA_FOUND#/dev/}" > ${rootmnt}/etc/udev/rules.d/70-fll-live.rules 1243 printf "KERNEL==\"%s\", ENV{ID_CDROM}==\"?*\", SYMLINK+=\"fll-cdrom\"\n" \ 1244 "${FLL_MEDIA_FOUND#/dev/}" >> ${rootmnt}/etc/udev/rules.d/70-fll-live.rules 1245 1246 # 1247 # disable movement of static $rootmnt/dev by scripts/init-bottom/udev 1248 # 1249 export no_static_dev="1" 1250 1251 # 1252 # if there is no framebuffer, clear our output to avoid corruption 1253 # later when preparing the console keymap 1254 # 1255 if [ -f /proc/fb ] && [ -z "$(cat /proc/fb)" ]; then 1256 clear 1257 else 1258 printf "\n${G}Starting ${Y}init${G} process${N}...\n\n" 1259 fi 1260 } 1261 ###############################################################################
Note: See TracChangeset
for help on using the changeset viewer.


