From nobody@FreeBSD.org  Thu Sep  5 18:48:21 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTP id 318D2E42
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  5 Sep 2013 18:48:21 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 048D02875
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  5 Sep 2013 18:48:21 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r85ImKY0046109
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 5 Sep 2013 18:48:20 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r85ImK7s046104;
	Thu, 5 Sep 2013 18:48:20 GMT
	(envelope-from nobody)
Message-Id: <201309051848.r85ImK7s046104@oldred.freebsd.org>
Date: Thu, 5 Sep 2013 18:48:20 GMT
From: ShelLuser <pl@catslair.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: zpool sets wrong mountpoint when using altroot
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         181847
>Category:       bin
>Synopsis:       zpool(8) sets wrong mountpoint when using altroot
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 05 18:50:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Fri Sep  6 06:40:00 UTC 2013
>Originator:     ShelLuser
>Release:        9.2-RC3
>Organization:
>Environment:
FreeBSD fbsd.intranet.lan 9.2-RC3 FreeBSD 9.2-RC3 #0 r254795: Sun Aug 25 00:42:01 UTC 2013   root@bake.isc.freebsd.org:/usr/obj/usr/src/sys/GENERIC   i306

>Description:
Being curious I downloaded FreeBSD-9.2-RC3-i386-bootonly, setup a FreeBSD virtual machine using VirtualBox 4.2.16 and then followed the procedure explained here to setup a ZFS only system:

http://forums.freebsd.org/showthread.php?t=31557

I've followed this procedure several times on FreeBSD 9.1-RELEASE and can confirm that it works.

However, when I try to create the ZFS pool the command now complains that it cannot create the mount point:

# zpool create -f -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot /dev/gpt/disk0
cannot mount '/mnt/zroot': failed to create mountpoint

Which I think is not the way it's suppose to behave. When looking at the current ZFS filesystem you'll notice that it tried to mount the filesystem on /zroot instead of / :

# zfs list -o name,mountpoint
NAME   MOUNTPOINT
zroot  /mnt/zroot

The reason why I think this to be incorrect: by default (so without using -R) the mountpoint for a new pool is /pool (where 'pool' is the name of the pool itself). But if you specify a different mountpoint wouldn't it make more sense that it replaces the default mountpoint instead of being prepended to it? At least when you're using zpool instead of zfs.

This is also mentioned in the zpool manualpage under the 'create' option (I quote):

"Unless the -R option is specified, the default mount point is
 "/pool".  The mount point must not exist or must be empty, or else
 the root dataset cannot be mounted. This can be overridden with the
-m option."

I wasn't sure if I should report it, but because the behaviour of zpool changed so drastically I figured I'd better do so anyway, at the risk that this behaviour is intended. (I did not write this PR on a whim).

>How-To-Repeat:
Install FreeBSD as normal and follow the instructions in this thread:

http://forums.freebsd.org/showthread.php?t=31557

Or simply create a new ZFS pool and specify an altroot, either using -o altroot=/altroot or by using -R /altroot.

Previously the newly created filesystem would get assigned to / as the mountpoint, now it always uses the default mountpoint.

>Fix:
# zpool create -R /mnt -m / zroot /dev/gpt/disk0

Instead of the previously mentioned:

# zpool create -R /mnt zroot /dev/gpt/disk0

Or if you already experienced the error message then the previous behaviour can be achieved by changing the mountpoint for the newly created filesystem to /.

# zfs set mountpoint=/ zroot


>Release-Note:
>Audit-Trail:

From: Anton Sayetsky <vsjcfm@gmail.com>
To: ShelLuser <pl@catslair.org>, bug-followup@freebsd.org
Cc:  
Subject: Re: bin/181847: zpool sets wrong mountpoint when using altroot
Date: Fri, 6 Sep 2013 09:33:56 +0300

 Hi,
 You're wrong. Mountpoint for newly created ZFS pool is
 ${ROOTDIR}/${POOLNAME}. So if you set the altroot to /mnt, mountpoint
 will be /mnt/${POOLNAME}.
 If you want to set exact mountpoint, you should use -m switch rather
 than -R. It is an _expected_ behavior.
>Unformatted:
