X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=scripts%2Flive;h=e0663b6920e47e5f2608a721473344c889e404d0;hb=d8df882369aad68caf3ac39692e2196e932ef15b;hp=952d4796ce4a0bf6c1a1328573a217dbb33a5b6a;hpb=3f02456e392ead3abf36bc181692fcb75c8f16f3;p=live-boot-grml.git diff --git a/scripts/live b/scripts/live index 952d479..e0663b6 100755 --- a/scripts/live +++ b/scripts/live @@ -244,13 +244,18 @@ Arguments () export PERSISTENT ;; - persistent=*) - PERSISTENT="${ARGUMENT#persistent=}" - if [ -z "${PERSISTENT}" ] - then - PERSISTENT="Yes" - fi - export PERSISTENT + persistent-encryption=*) + PERSISTENT_ENCRYPTION="${ARGUMENT#*=}" + export PERSISTENT_ENCRYPTION + ;; + + persistent-media=*) + PERSISTENT_MEDIA="${ARGUMENT#*=}" + export PERSISTENT_MEDIA + ;; + persistent-method=*) + PERSISTENT_METHOD="${ARGUMENT#*=}" + export PERSISTENT_METHOD ;; persistent-path=*) @@ -258,6 +263,11 @@ Arguments () export PERSISTENT_PATH ;; + persistent-storage=*) + PERSISTENT_STORAGE="${ARGUMENT#persistent-storage=}" + export PERSISTENT_STORAGE + ;; + persistent-subtext=*) root_persistence="${root_persistence}-${ARGUMENT#persistent-subtext=}" home_persistence="${home_persistence}-${ARGUMENT#persistent-subtext=}" @@ -380,6 +390,18 @@ Arguments () UNIONTYPE="aufs" export UNIONTYPE fi + + if [ -n "${PERSISTENT}" ] && [ -z "${PERSISTENT_METHOD}" ] + then + PERSISTENT_METHOD="snapshot,overlay" + export PERSISTENT_METHOD + fi + + if [ -n "${PERSISTENT}" ] && [ -z "${PERSISTENT_STORAGE}" ] + then + PERSISTENT_STORAGE="filesystem,file" + export PERSISTENT_STORAGE + fi } is_live_path () @@ -480,7 +502,16 @@ is_nice_device () { sysfs_path="${1#/sys}" - if /lib/udev/path_id "${sysfs_path}" | egrep -q "ID_PATH=(usb|pci-|platform-sata_mv|platform-orion-ehci|platform-mmc|platform-mxsdhci|)" + if [ -e /lib/udev/path_id ] + then + # squeeze + PATH_ID="/lib/udev/path_id" + else + # wheezy/sid (udev >= 174) + PATH_ID="/sbin/udevadm test-builtin path_id" + fi + + if "${PATH_ID}" "${sysfs_path}" | egrep -q "ID_PATH=(usb|pci-[^-]*-(ide|sas|scsi|usb|virtio)|platform-sata_mv|platform-orion-ehci|platform-mmc|platform-mxsdhci)" then return 0 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$' @@ -1028,26 +1059,6 @@ do_snap_copy () fi } -find_snap () -{ - # Look for ${snap_label}.* in block devices - snap_label="${1}" - black_listed_devices="${2}" - white_listed_devices="${3}" - - if [ "${PERSISTENT}" != "nofiles" ] - then - # search for image files - snapdata=$(find_files "${PERSISTENT_PATH}${snap_label}.squashfs ${PERSISTENT_PATH}${snap_label}.cpio.gz ${PERSISTENT_PATH}${snap_label}.ext2 ${PERSISTENT_PATH}${snap_label}.ext3 ${PERSISTENT_PATH}${snap_label}.ext4 ${PERSISTENT_PATH}${snap_label}.jffs2" "${black_listed_devices}" "${white_listed_devices}") - fi - - if [ -z "${snapdata}" ] - then - snapdata=$(find_cow_device "${snap_label}" "${black_listed_devices}" "${white_listed_devices}") - fi - echo "${snapdata}" -} - try_snap () { # copy the contents of previously found snapshot to ${snap_mount} @@ -1199,7 +1210,7 @@ setup_unionfs () if [ "${UNIONTYPE}" = "aufs" ] then - roopt="rr" + roopt="rr+wh" noxino_opt="noxino," elif [ "${UNIONTYPE}" = "unionfs-fuse" ] then @@ -1324,6 +1335,7 @@ setup_unionfs () # Looking for "${root_persistence}" device or file if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ] then + if [ -z "${QUICKUSBMODULES}" ] then # Load USB modules @@ -1351,30 +1363,58 @@ setup_unionfs () done fi - # search for label and files (this could be hugely optimized) - cowprobe=$(find_cow_device "${root_persistence}" "${blacklistdev}" "${whitelistdev}") - if [ -b "${cowprobe}" ] + case "${PERSISTENT_MEDIA}" in + removable) + whitelistdev="$(removable_dev)" + ;; + removable-usb) + whitelistdev="$(removable_usb_dev)" + ;; + *) + whitelistdev="" + ;; + esac + + if echo ${PERSISTENT_METHOD} | grep -qw overlay then - # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots - # makes sense to have both persistence for /cow and /home mounted, maybe also with - # snapshots to be sure to really store some e.g key config files, - # but not on the same media - blacklistdev="${cowprobe}" - PERSISTENCE_IS_ON="1" - export PERSISTENCE_IS_ON + overlays="${root_persistence} ${home_persistence}" fi - # homecow just mount something on /home, this should be generalized some way - homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}" "${whitelistdev}") - if [ -b "${homecow}" ] + + if echo ${PERSISTENT_METHOD} | grep -qw snapshot + then + snapshots="${root_snapshot_label} ${home_snapshot_label}" + fi + + + for media in $(find_persistent_media "${overlays}" "${snapshots}" "${blacklistdev}" "${whitelistdev}") + do + media="$(echo ${media} | tr ":" " ")" + case ${media} in + ${root_persistence}=*) + cowprobe="${media#*=}" + ;; + ${home_persistence}=*) + homecow="${media#*=}" + ;; + ${root_snapshot_label}=*) + root_snapdata="${media#*=}" + ;; + ${home_snapshot_label}=*) + # This second type should be removed when snapshot will get smarter, + # hence when "/etc/live-snapshot*list" will be supported also by + # ext2|ext3|ext4|jffs2 snapshot types. + home_snapdata="${media#*=}" + ;; + *) + ;; + esac + done + + if [ -b "${cowprobe}" ] || [ -b "${homecow}" ] then PERSISTENCE_IS_ON="1" export PERSISTENCE_IS_ON fi - root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}" "${whitelistdev}") - # This second type should be removed when snapshot will get smarter, - # hence when "/etc/live-snapshot*list" will be supported also by - # ext2|ext3|ext4|jffs2 snapshot types. - home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}" "${whitelistdev}") if [ -b "${cowprobe}" ] then @@ -1387,7 +1427,6 @@ setup_unionfs () fsck -y ${cowdevice} fi else - log_warning_msg "Unable to find the persistent medium" cowdevice="tmpfs" cow_fstype="tmpfs" cow_mountopt="rw,noatime,mode=755" @@ -1665,7 +1704,7 @@ check_dev () echo ${mountpoint} return 0 else - umount ${mountpoint} + umount ${mountpoint} 2>/dev/null fi fi