Fix BEADM DESTROY for 'static' boot environments.
This commit is contained in:
parent
cca014136e
commit
af3dbd80b7
25
beadm
25
beadm
|
|
@ -70,6 +70,25 @@ __be_mounted() { # 1=BE
|
||||||
mount 2> /dev/null | grep -q -E "^${1} " 2> /dev/null
|
mount 2> /dev/null | grep -q -E "^${1} " 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check if boot environment is a clone
|
||||||
|
__be_clone() { # 1=DATASET
|
||||||
|
if zfs list sys/ROOT/static 1> /dev/null 2> /dev/null
|
||||||
|
then
|
||||||
|
local ORIGIN="$( zfs list -H -o origin ${1} )"
|
||||||
|
if [ "${ORIGIN}" = "-" ]
|
||||||
|
then
|
||||||
|
# boot environment is not a clone
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
# boot environment is a clone
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# boot environment does not exist
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# create new boot environment
|
# create new boot environment
|
||||||
__be_new() { # 1=SOURCE 2=TARGET
|
__be_new() { # 1=SOURCE 2=TARGET
|
||||||
local SOURCE=$( echo ${1} | cut -d '@' -f 1 )
|
local SOURCE=$( echo ${1} | cut -d '@' -f 1 )
|
||||||
|
|
@ -364,6 +383,8 @@ EOF
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
if __be_clone ${POOL}/ROOT/${DESTROY}
|
||||||
|
then
|
||||||
# promote clones dependent on snapshots used by destroyed boot environment
|
# promote clones dependent on snapshots used by destroyed boot environment
|
||||||
zfs list -H -t all -o name,origin \
|
zfs list -H -t all -o name,origin \
|
||||||
| while read NAME ORIGIN
|
| while read NAME ORIGIN
|
||||||
|
|
@ -375,8 +396,11 @@ EOF
|
||||||
done
|
done
|
||||||
# get origins used by destroyed boot environment
|
# get origins used by destroyed boot environment
|
||||||
ORIGIN_SNAPSHOTS=$( zfs list -H -t all -o origin -r ${POOL}/ROOT/${DESTROY} | grep -v '^-$' | awk -F "@" '{print $2}' | sort -u )
|
ORIGIN_SNAPSHOTS=$( zfs list -H -t all -o origin -r ${POOL}/ROOT/${DESTROY} | grep -v '^-$' | awk -F "@" '{print $2}' | sort -u )
|
||||||
|
fi
|
||||||
# destroy boot environment
|
# destroy boot environment
|
||||||
zfs destroy -r ${POOL}/ROOT/${DESTROY}
|
zfs destroy -r ${POOL}/ROOT/${DESTROY}
|
||||||
|
if __be_clone ${POOL}/ROOT/${DESTROY}
|
||||||
|
then
|
||||||
# promote datasets dependent on origins used by destroyed boot environment
|
# promote datasets dependent on origins used by destroyed boot environment
|
||||||
ALL_ORIGINS=$( zfs list -H -t all -o name,origin )
|
ALL_ORIGINS=$( zfs list -H -t all -o name,origin )
|
||||||
echo "${ORIGIN_SNAPSHOTS}" \
|
echo "${ORIGIN_SNAPSHOTS}" \
|
||||||
|
|
@ -403,6 +427,7 @@ EOF
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
echo "Destroyed successfully"
|
echo "Destroyed successfully"
|
||||||
;;
|
;;
|
||||||
(*)
|
(*)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue