Comments (5)
Its the same as on Solaris, the ${poolname}/ROOT/${be} where ${be} is actual root dataset.
The ${poolname}/ROOT is the place where all BE's are kept.
The ${ROOTFS} is uset tofor ${poolname}/ROOT/${bootedbe}, the BE that was booted currently.
Regards,
vermaden
from beadm.
You can also zfs rename
your datasets to use /ROOT/
from beadm.
Here is a patch for current version to overcome hardcoded root dataset name:
--- /usr/local/sbin/beadm.orig 2013-01-26 12:16:59.169127793 +0200
+++ /usr/local/sbin/beadm 2013-01-26 12:45:20.503124821 +0200
@@ -127,7 +127,7 @@
done << EOF
$( zfs get -o name,property,value -s local,received -H all ${FS} | awk '!/[\t ]canmount[\t ]/' )
EOF
- DATASET=$( echo ${FS} | awk '{print $1}' | sed -E s/"^${POOL}/ROOT/${SOURCE##/}"/"${POOL}/ROOT/${2##/}"/g )
+ DATASET=$( echo ${FS} | awk '{print $1}' | sed -E s/"^${POOL}/${BEDS}/${SOURCE##/}"/"${POOL}/${BEDS}/${2##/}"/g )
if [ "${OPTS}" = "-o = " ]
then
local OPTS=""
@@ -151,12 +151,14 @@
POOL=$( echo ${ROOTFS} | awk -F '/' '{print $1}' )
-if ! zfs list ${POOL}/ROOT 1> /dev/null 2> /dev/null
+if [ $( echo ${ROOTFS} | awk -F '/' '{print NF}' ) -lt 3 ]
then
echo "ERROR: This system is not configured for boot environments"
exit 1
fi
+BEDS=$( echo ${ROOTFS} | awk -F '/' '{print $2}' )
+
BOOTFS=$( zpool list -H -o bootfs ${POOL} )
if [ -z "${BOOTFS}" -o "${BOOTFS}" = "-" ]
@@ -184,6 +186,7 @@
esac
done
awk -v POOL="${POOL}"
+ -v BEDS="${BEDS}"
-v ROOTFS="${ROOTFS}"
-v BOOTFS="${BOOTFS}"
-v OPTION_a="${OPTION_a}"
@@ -218,7 +221,7 @@
return NEW
}
BEGIN {
- BENAME_BEGINS_WITH = POOL "/ROOT"
+ BENAME_BEGINS_WITH = POOL "/" BEDS
MULTIPLIER["K"] = 1
MULTIPLIER["M"] = 1024
MULTIPLIER["G"] = 1048576
@@ -374,24 +377,24 @@
then
__usage
fi
- __be_exist ${POOL}/ROOT/${3}
- if zfs list -H -o name ${POOL}/ROOT/${4} 1> /dev/null 2> /dev/null
+ __be_exist ${POOL}/${BEDS}/${3}
+ if zfs list -H -o name ${POOL}/${BEDS}/${4} 1> /dev/null 2> /dev/null
then
echo "ERROR: Boot environment '${4}' already exists"
exit 1
fi
- __be_new ${POOL}/ROOT/${3} ${POOL}/ROOT/${4}
+ __be_new ${POOL}/${BEDS}/${3} ${POOL}/${BEDS}/${4}
;;
(2)
if __be_snapshot ${2}
then
- if ! zfs snapshot -r ${POOL}/ROOT/${2} 1> /dev/null 2> /dev/null
+ if ! zfs snapshot -r ${POOL}/${BEDS}/${2} 1> /dev/null 2> /dev/null
then
echo "ERROR: Cannot create '${2}' recursive snapshot"
exit 1
fi
else
- __be_new ${ROOTFS} ${POOL}/ROOT/${2}
+ __be_new ${ROOTFS} ${POOL}/${BEDS}/${2}
fi
;;
()
@@ -406,15 +409,15 @@
then
__usage
fi
- __be_exist ${POOL}/ROOT/${2}
- if [ "${BOOTFS}" = "${POOL}/ROOT/${2}" ]
+ __be_exist ${POOL}/${BEDS}/${2}
+ if [ "${BOOTFS}" = "${POOL}/${BEDS}/${2}" ]
then
echo "Already activated"
exit 0
else
- if __be_mounted ${POOL}/ROOT/${2}
+ if __be_mounted ${POOL}/${BEDS}/${2}
then
- MNT=$( mount | grep -E "^${POOL}/ROOT/${2} " | awk '{print $3}' )
+ MNT=$( mount | grep -E "^${POOL}/${BEDS}/${2} " | awk '{print $3}' )
if [ "${MNT}" != "/" ]
then
# boot environment is not current root and its mounted
@@ -424,7 +427,7 @@
fi
fi
# do not change root (/) mounted boot environment mountpoint
- if [ "${ROOTFS}" != "${POOL}/ROOT/${2}" ]
+ if [ "${ROOTFS}" != "${POOL}/${BEDS}/${2}" ]
then
TMPMNT=$( mktemp -d -t BE-${2} )
if ! mkdir -p ${TMPMNT} 2> /dev/null
@@ -435,7 +438,7 @@
MOUNT=0
while read FS MNT TYPE OPTS DUMP FSCK;
do
- if [ "${FS}" = "${POOL}/ROOT/${2}" ]
+ if [ "${FS}" = "${POOL}/${BEDS}/${2}" ]
then
MOUNT=${MNT}
break
@@ -445,9 +448,9 @@
EOF
if [ ${MOUNT} -eq 0 ]
then
- zfs set canmount=noauto ${POOL}/ROOT/${2}
- zfs set mountpoint=${TMPMNT} ${POOL}/ROOT/${2}
- zfs mount ${POOL}/ROOT/${2}
+ zfs set canmount=noauto ${POOL}/${BEDS}/${2}
+ zfs set mountpoint=${TMPMNT} ${POOL}/${BEDS}/${2}
+ zfs mount ${POOL}/${BEDS}/${2}
else
TMPMNT=${MOUNT}
fi
@@ -457,32 +460,32 @@
then
LOADER_CONFIGS="${LOADER_CONFIGS} ${TMPMNT}/boot/loader.conf.local"
fi
- sed -i '' -E s/"^vfs.root.mountfrom=.
$"/"vfs.root.mountfrom="zfs:${POOL}/ROOT/${2##/}""/g ${LOADER_CONFIGS}
+ sed -i '' -E s/"^vfs.root.mountfrom=.
$"/"vfs.root.mountfrom="zfs:${POOL}/${BEDS}/${2##/}""/g ${LOADER_CONFIGS}
if [ ${MOUNT} -eq 0 ]
then
- zfs umount ${POOL}/ROOT/${2}
- zfs set mountpoint=legacy ${POOL}/ROOT/${2}
+ zfs umount ${POOL}/${BEDS}/${2}
+ zfs set mountpoint=legacy ${POOL}/${BEDS}/${2}
fi
fi
- if ! zpool set bootfs=${POOL}/ROOT/${2} ${POOL} 1> /dev/null 2> /dev/null
+ if ! zpool set bootfs=${POOL}/${BEDS}/${2} ${POOL} 1> /dev/null 2> /dev/null
then
echo "ERROR: Failed to activate '${2}' boot environment"
exit 1
fi
fi
# execute ZFS LIST only once
- ZFS_LIST=$( zfs list -H -o name -r ${POOL}/ROOT )
+ ZFS_LIST=$( zfs list -H -o name -r ${POOL}/${BEDS} )
# disable automatic mount on all inactive boot environments
echo "${ZFS_LIST}"
- | grep -v "^${POOL}/ROOT/${2}$"
- | grep -v "^${POOL}/ROOT/${2}/"
+ | grep -v "^${POOL}/${BEDS}/${2}$"
+ | grep -v "^${POOL}/${BEDS}/${2}/"
| while read NAME
do
zfs set canmount=noauto ${NAME}
done
# enable automatic mount for active boot environment and promote it
echo "${ZFS_LIST}"
- | grep -E "^${POOL}/ROOT/${2}(/|$)"
+ | grep -E "^${POOL}/${BEDS}/${2}(/|$)"
| while read NAME
do
zfs set canmount=on ${NAME}
@@ -501,7 +504,7 @@
else
DESTROY=${3}
fi
- __be_exist ${POOL}/ROOT/${DESTROY}
+ __be_exist ${POOL}/${BEDS}/${DESTROY}
case ${#} in
(2)
echo "Are you sure you want to destroy '${2}'?"
@@ -519,7 +522,7 @@
__usage
;;
esac
- if [ "${BOOTFS}" = "${POOL}/ROOT/${DESTROY}" ]
+ if [ "${BOOTFS}" = "${POOL}/${BEDS}/${DESTROY}" ]
then
echo "ERROR: Cannot destroy active boot environment"
exit 1
@@ -527,32 +530,32 @@
case ${CHOICE} in
(Y|y|[Yy][Ee][Ss])
# destroy snapshot or boot environment
- if __be_snapshot ${POOL}/ROOT/${DESTROY}
+ if __be_snapshot ${POOL}/${BEDS}/${DESTROY}
then
# destroy desired snapshot
- if ! zfs destroy -r ${POOL}/ROOT/${DESTROY} 1> /dev/null 2> /dev/null
+ if ! zfs destroy -r ${POOL}/${BEDS}/${DESTROY} 1> /dev/null 2> /dev/null
then
echo "ERROR: Snapshot '${2}' is origin for other boot environment"
exit 1
fi
else
- if __be_clone ${POOL}/ROOT/${DESTROY}
+ if __be_clone ${POOL}/${BEDS}/${DESTROY}
then
# promote clones dependent on snapshots used by destroyed boot environment
zfs list -H -t all -o name,origin
| while read NAME ORIGIN
do
- if echo "${ORIGIN}" | grep -q -E "${POOL}/ROOT/${DESTROY}(/.
@|@)" 2> /dev/null
+ if echo "${ORIGIN}" | grep -q -E "${POOL}/${BEDS}/${DESTROY}(/.*@|@)" 2> /dev/null
then
zfs promote ${NAME}
fi
done
# 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}/${BEDS}/${DESTROY} | grep -v '^-$' | awk -F "@" '{print $2}' | sort -u )
fi
# check if boot environment was created from existing snapshot
- ORIGIN=$( zfs list -H -o origin ${POOL}/ROOT/${DESTROY} )
- CREATION=$( zfs list -H -o creation ${POOL}/ROOT/${DESTROY} )
+ ORIGIN=$( zfs list -H -o origin ${POOL}/${BEDS}/${DESTROY} )
+ CREATION=$( zfs list -H -o creation ${POOL}/${BEDS}/${DESTROY} )
CREATION=$( date -j -f "%a %b %d %H:%M %Y" "${CREATION}" +"%Y-%m-%d-%H:%M" )
SNAPSHOT_NAME=$( echo "${ORIGIN}" | cut -d '@' -f 2 | sed -E 's/:[0-9]{2}$//g' )
if [ "${2}" = "-F" ]
@@ -577,9 +580,9 @@
CHOICE=1
fi
# destroy boot environment
- zfs destroy -r ${POOL}/ROOT/${DESTROY}
+ zfs destroy -r ${POOL}/${BEDS}/${DESTROY}
# check if boot environment is a clone
- if __be_clone ${POOL}/ROOT/${DESTROY}
+ if __be_clone ${POOL}/${BEDS}/${DESTROY}
then
# promote datasets dependent on origins used by destroyed boot environment
ALL_ORIGINS=$( zfs list -H -t all -o name,origin )
@@ -624,18 +627,18 @@
then
__usage
fi
- __be_exist ${POOL}/ROOT/${2}
- if [ "${BOOTFS}" = "${POOL}/ROOT/${2}" ]
+ __be_exist ${POOL}/${BEDS}/${2}
+ if [ "${BOOTFS}" = "${POOL}/${BEDS}/${2}" ]
then
echo "ERROR: Renaming active boot environment is not supported"
exit 1
fi
- if zfs list -H -o name ${POOL}/ROOT/${3} 2> /dev/null
+ if zfs list -H -o name ${POOL}/${BEDS}/${3} 2> /dev/null
then
echo "ERROR: Boot environment '${3}' already exists"
exit 1
fi
- zfs rename ${POOL}/ROOT/${2} ${POOL}/ROOT/${3}
+ zfs rename ${POOL}/${BEDS}/${2} ${POOL}/${BEDS}/${3}
echo "Renamed successfully"
;;
@@ -649,10 +652,10 @@
else
__usage
fi
- __be_exist "${POOL}/ROOT/${2}"
- if __be_mounted "${POOL}/ROOT/${2}"
+ __be_exist "${POOL}/${BEDS}/${2}"
+ if __be_mounted "${POOL}/${BEDS}/${2}"
then
- MNT=$( mount | grep -E "^${POOL}/ROOT/${2} " | awk '{print $3}' )
+ MNT=$( mount | grep -E "^${POOL}/${BEDS}/${2} " | awk '{print $3}' )
echo "Boot environment '${2}' is already mounted at '${MNT}'"
exit 1
fi
@@ -661,19 +664,19 @@
echo "ERROR: Cannot create '${TARGET}' mountpoint"
exit 1
fi
- if ! mount -t zfs ${POOL}/ROOT/${2} ${TARGET}
+ if ! mount -t zfs ${POOL}/${BEDS}/${2} ${TARGET}
then
echo "ERROR: Cannot mount '${2}' at '${TARGET}' mountpoint"
exit 1
fi
- PREFIX=$( echo ${POOL}/ROOT/${2}/ | sed 's///\//g' )
- zfs list -H -o name,mountpoint -r ${POOL}/ROOT/${2}
+ PREFIX=$( echo ${POOL}/${BEDS}/${2}/ | sed 's///\//g' )
+ zfs list -H -o name,mountpoint -r ${POOL}/${BEDS}/${2}
| grep -v -E "[:space:]$"
| sort -n
- | grep -E "^${POOL}/ROOT/${2}/"
+ | grep -E "^${POOL}/${BEDS}/${2}/"
| while read FS MOUNTPOINT
do
- if [ "{FS}" != "${POOL}/ROOT/${2}" ]
+ if [ "{FS}" != "${POOL}/${BEDS}/${2}" ]
then
INHERIT=$( zfs get -H -o source mountpoint ${FS} )
if [ "${INHERIT}" = "local" ]
@@ -714,17 +717,17 @@
else
__usage
fi
- __be_exist "${POOL}/ROOT/${2}"
- if ! __be_mounted "${POOL}/ROOT/${2}"
+ __be_exist "${POOL}/${BEDS}/${2}"
+ if ! __be_mounted "${POOL}/${BEDS}/${2}"
then
echo "Boot environment '${2}' is not mounted"
exit 1
fi
MOUNT=$( mount )
- MOUNTPOINT=$( echo "${MOUNT}" | grep -m 1 "^${POOL}/ROOT/${2} on " | awk '{print $3}' )
+ MOUNTPOINT=$( echo "${MOUNT}" | grep -m 1 "^${POOL}/${BEDS}/${2} on " | awk '{print $3}' )
echo "${MOUNT}"
| awk '{print $1}'
- | grep -E "^${POOL}/ROOT/${2}(/|$)"
+ | grep -E "^${POOL}/${BEDS}/${2}(/|$)"
| sort -n -r
| while read FS
do
from beadm.
Thanks for the PATCH dpslavov, I will look into it in my next free time window.
Regards,
vermaden
from beadm.
I have just merged Your patch ... yep it took a while ;)
Regards,
vermaden
from beadm.
Related Issues (20)
- beadm is mounting canmount=no filesystems
- Multiple ZFS pools HOT 5
- BE name ending with colon not bootable on FreeBSD. HOT 3
- Preparing filesystem to benefit from beadm with 10.2 HOT 1
- Create /boot/entropy when activating new BE HOT 7
- Need to escape paths before passing them to sed. HOT 6
- Create new / set active BEs to canmount=noauto to ease backups. HOT 5
- Implement "beadm create -o"
- Implement "beadm create -d" HOT 2
- Nickname support not documented well HOT 1
- Implement "beadm activate -t/-T" HOT 1
- Getting asked weird question by beadm HOT 3
- beadm fails with gawk HOT 3
- PATH needs restriction in beadm HOT 3
- Feature request: Automatically adjust legacy mounts in fstab
- Calculating Boot Environment space HOT 1
- unable to roll back to the initial BE HOT 2
- reroot: active on reboot (R), next boot once (T) HOT 3
- reroot: if no environment is specified, reroot the active on reboot (R) environment HOT 2
- csh completion HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from beadm.