Skip to content

Commit

Permalink
Remove zpool altroot from mountpoint when creating datasets.
Browse files Browse the repository at this point in the history
If `${ZPOOL}` has `altroot` set, `${ZROOTFS}` can only be mounted
under `altroot`. This means `${BASEFS}` _must_ begin with `altroot`.

In `poudriere.conf`, the setting would look something like:
`BASEFS=<altroot>/rest/of/path`.

However, `altroot` is always prepended to whatever path is set to
`mountpoint` at the time of dataset creation. What happens is that
`${ZROOTFS}` is actually mounted on `<altroot>${BASEFS}`, while
`poudriere` thinks it's on `${BASEFS}`.

To fix the problem, simply check if `altroot` is set and remove it
from `mountpoint` when creating datasets. Their `mountpoint`s will
then be prepended with `altroot`, which matches `poudriere`'s internal
records.
  • Loading branch information
kostaslambda committed Nov 5, 2022
1 parent 137c376 commit cfa99e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/share/poudriere/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ get_data_dir() {
# Explicitly set properties for values diverging from top dataset
zfs create -p -o atime=off \
-o compression=on \
-o mountpoint=${BASEFS} \
-o mountpoint="$(remove_altroot ${BASEFS})" \
${ZPOOL}${ZROOTFS}
zfs create ${ZPOOL}${ZROOTFS}/jails
zfs create ${ZPOOL}${ZROOTFS}/ports
Expand Down
14 changes: 12 additions & 2 deletions src/share/poudriere/include/fs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.

remove_altroot() {
[ $# -ne 1 ] && eargs remove_altroot mountpoint
local mountpoint altroot
mountpoint="$1"
altroot=
[ -n "${NO_ZFS}" ] || altroot=$(zpool get -Ho value altroot "${ZPOOL}")

echo "${mountpoint}" | sed "s,^${altroot},,"
}

createfs() {
[ $# -ne 3 ] && eargs createfs name mnt fs
local name mnt fs
Expand All @@ -37,7 +47,7 @@ createfs() {
if ! zfs create -p \
-o compression=on \
-o atime=off \
-o mountpoint=${mnt} ${fs}; then
-o mountpoint="$(remove_altroot ${mnt})" ${fs}; then
echo " fail"
err 1 "Failed to create FS ${fs}"
fi
Expand Down Expand Up @@ -294,7 +304,7 @@ clonefs() {
zfs_to=${fs}/${name}
fi

zfs clone -o mountpoint=${mnt} \
zfs clone -o mountpoint="$(remove_altroot ${mnt})" \
-o sync=disabled \
-o atime=off \
-o compression=off \
Expand Down

0 comments on commit cfa99e9

Please sign in to comment.