zpool create -o altroot=/xyz -O mountpoint=/mnt ignores the mountpoint option
There is some code in libzfs_dataset.c:zpool_create() that assumes that if altroot is set we should always set the mountpoint of the root file system to "/".
- Violates what the man page says about altroot: "If set, this directory is prepended to any mount points within the pool." (it says nothing about changing the mountpoint property of the root file system, it implies the root file system's mount point should be '$altroot/$rootfs_mntpnt')
- Is inconsistent with the behavior of setting altroot when importing a pool (which does end up with the root file system's mount point at '$altroot/$rootfs_mntpnt').
- Causes you to be unable to import the pool in the future without specifying an altroot since doing so would try to mount over "/" (and fail since / is not empty).
- Cannot be worked around at creation time, any attempt to specify a mountpoint while using altroot will be ignored.
To clearly show the difference the old behavior does this:
$ zpool create -o altroot=/altroot test cXtXdX $ zfs get -Ho value mountpoint test /altroot
$ zpool create -o altroot=/altroot -O mountpoint=/my/mount/point test cXtXdX $ zfs get -Ho value mountpoint test /altroot
The suggested new behavior would do this:
$ zpool create -o altroot=/altroot test cXtXdX $ zfs get -Ho value mountpoint test /altroot/test
$ zpool create -o altroot=/altroot -O mountpoint=/my/mount/point test cXtXdX $ zfs get -Ho value mountpoint test /altroot/my/mount/point
The behavior of zpool import remains unchanged and more closely matches the suggested new behavior for zpool create.
The Solaris ZFS administration guide (http://docs.oracle.com/cd/E19082-01/817-2271/gbcgl/index.html) describes this "feature" as a way to mount removable media, but it really doesn't make mounting removable media any easier than not setting mountpoint to / would. The examples also show both the inability to import the pool without an altroot and the fact that zpool import behaves differently, although the text doesn't mention either issue. It seems like they are documenting around buggy behavior.
We should just make the 'zpool create' behavior consistent with 'zpool import', the old behavior can be achieved by specifying the '-O mountpoint=/' option to zpool create. This seems like an uncommon enough case that most people won't be affected by the behavior change.
Updated by Christopher Siden about 6 years ago
- Status changed from In Progress to Closed
commit 8b71377 Author: Will Andrews <firstname.lastname@example.org> Date: Tue Jun 11 10:13:47 2013 3745 zpool create should treat -O mountpoint and -m the same 3811 zpool create -o altroot=/xyz -O mountpoint=/mnt ignores the mountpoint option Reviewed by: Matthew Ahrens <email@example.com> Approved by: Christopher Siden <firstname.lastname@example.org>