mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
Added probe for ZFS pool on partition
This commit is contained in:
parent
a1a153946a
commit
e07927fbe2
@ -127,16 +127,13 @@ probe_for_part()
|
||||
if [ -e "/dev/${DEV}s1a" ]; then
|
||||
# MBR UFS
|
||||
export PART="/dev/${DEV}s1a"
|
||||
probe_zfs_pool
|
||||
return 0
|
||||
elif [ -e "/dev/${DEV}p3" ]; then
|
||||
# GPT UFS
|
||||
export PART="/dev/${DEV}p3"
|
||||
probe_zfs_pool
|
||||
return 0
|
||||
elif [ "${DEV}" = "zroot" ]; then
|
||||
if zpool import | awk '{ print $1 " " $2 }' | grep -q "${DEV} ONLINE"; then
|
||||
export POOL="${DEV}"
|
||||
return 0
|
||||
fi
|
||||
elif [ -e "/dev/${DEV}s1" ]; then
|
||||
# MBR MSDOS
|
||||
export PART="/dev/${DEV}s1"
|
||||
@ -152,9 +149,41 @@ probe_for_part()
|
||||
return 1
|
||||
}
|
||||
|
||||
probe_zfs_pool()
|
||||
{
|
||||
zpool import -aNf
|
||||
local ZPCHK=$(zpool get -H cachefile)
|
||||
local ORIGINAL_IFS="${IFS}"
|
||||
local CPOOL=
|
||||
local zt=
|
||||
|
||||
IFS=$'\n'
|
||||
local PART_NAME=$(echo ${PART} | sed -e "s/.*\///")
|
||||
for zplist in ${ZPCHK}; do
|
||||
CPOOL=$(echo ${zplist} | awk '{ print $1 }')
|
||||
zt=$(zpool status ${CPOOL} | grep -c ${PART_NAME})
|
||||
if [ ${zt} -ne "0" ]; then
|
||||
export POOL=${CPOOL}
|
||||
zpool export ${CPOOL} >/dev/null 2>/dev/null
|
||||
else
|
||||
zt=$(mount | grep -w / | grep -c ${CPOOL})
|
||||
if [ ${zt} -eq "0" ]; then
|
||||
zpool export ${CPOOL} >/dev/null 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS="${ORIGINAL_IFS}"
|
||||
if [ -z "${POOL}" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
DEV=${1}
|
||||
DEVS=
|
||||
PART=
|
||||
POOL=
|
||||
|
||||
if [ -n "${DEV}" ]; then
|
||||
zfs_load
|
||||
@ -207,7 +236,17 @@ while : ; do
|
||||
|
||||
mkdir -p ${MNT}
|
||||
|
||||
if [ -n "${PART}" ]; then
|
||||
if [ -n "${POOL}" ]; then
|
||||
echo "Starting import for ZFS pool '${POOL}'."
|
||||
echo
|
||||
|
||||
zpool import -fNR ${MNT} ${POOL}
|
||||
if ! mount -t zfs ${POOL}/ROOT/default ${MNT}; then
|
||||
echo "The device could not be mounted."
|
||||
fi
|
||||
|
||||
break
|
||||
elif [ -n "${PART}" ]; then
|
||||
echo "Starting import for partition '${PART}'."
|
||||
echo
|
||||
|
||||
@ -226,17 +265,6 @@ while : ; do
|
||||
PART=
|
||||
fi
|
||||
|
||||
break
|
||||
elif [ -n "${POOL}" ]; then
|
||||
echo "Starting import for ZFS pool '${POOL}'."
|
||||
echo
|
||||
|
||||
zpool import -f -R ${MNT} ${POOL}
|
||||
if ! zfs mount ${POOL}/ROOT/default; then
|
||||
echo "The device could not be mounted."
|
||||
POOL=
|
||||
fi
|
||||
|
||||
break
|
||||
else
|
||||
echo "Something went wrong during partition selection."
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user