On Wed, Jul 27, 2011 at 6:37 AM, Nishchaya Bahuguna
<nishchaya.bahug...@oracle.com> wrote:
> Hi,
>
> I have a query regarding the zfs rename command.
>
> There are 5 zones and my requirement is to change the zone paths using zfs
> rename.
>
> + zoneadm list -cv
> ID NAME             STATUS     PATH                           BRAND    IP
>  0 global               running    /                                 native
>   shared
> 34 public               running    /txzone/public              native
> shared
> 35 internal             running    /txzone/internal           native
> shared
> 36 restricted           running    /txzone/restricted         native
> shared
> 37 needtoknow      running    /txzone/needtoknow    native   shared
> 38 sandbox              running    /txzone/sandbox           native   shared
>
> A whole root zone <public> was configured and installed. Rest of the 4 zones
> were cloned from <public>.
>
> zoneadm -z <zoneName> clone public
>
> zfs get origin lists the origin as <public> for all 4 zones.
>
> I run zfs rename on 4 of these clone'd zones and it throws a device busy
> error because of parent-child relationship.

I think you are getting the device busy error for a different reason.
I just did the following:

zfs create -o mountpoint=/zones rpool/zones
zonecfg -z z1 'create; set zonepath=/zones/z1'
zoneadm -z z1 install
zonecfg -z z1c1 'create -t z1; set zonepath=/zones/z1c1'
zonecfg -z z1c2 'create -t z1; set zonepath=/zones/z1c2'
zoneadm -z z1c1 clone z1
zoneadm -z z1c2 clone z2

At this point, I have the following:

bash-3.2# zfs list -r -o name,origin rpool/zones
NAME                      ORIGIN
rpool/zones               -
rpool/zones/z1            -
rpool/zones/z1@SUNWzone1  -
rpool/zones/z1@SUNWzone2  -
rpool/zones/z1c1          rpool/zones/z1@SUNWzone1
rpool/zones/z1c2          rpool/zones/z1@SUNWzone2

Next, I decide that I would like z1c1 to be rpool/new/z1c1 instead of
it's current place.  Note that this will also change the mountpoint
which breaks the zone.

bash-3.2# zfs create -o mountpoint=/new rpool/new
bash-3.2# zfs rename rpool/zones/z1c1 rpool/new/z1c1
bash-3.2# zfs list -o name,origin -r /new
NAME            ORIGIN
rpool/new       -
rpool/new/z1c1  rpool/zones/z1@SUNWzone1

To get a "device busy" error, I need to cause a situation where the
zonepath cannot be unmounted.  Having the zone running is a good way
to do that:

bash-3.2# zoneadm -z z1c2 boot
WARNING: zone z1c1 is installed, but its zonepath /zones/z1c1 does not exist.
bash-3.2# zfs rename rpool/zones/z1c2 rpool/new/z1c2
cannot unmount '/zones/z1c2': Device busy

> I guess that can be handled with zfs promote because promote would swap the
> parent and child.

You would need to do this to rename a dataset that the origin (one
that is cloned) not the clones.  That is, if you wanted to rename the
dataset for your public zone or I wanted to rename the dataset for z1,
then you would need to promote the datasets for all of the clones.
This is a known issue.

6472202 'zfs rollback' and 'zfs rename' require that clones be unmounted

> So, how do I make it work when there are multiple zones cloned from a single
> parent? Is there a way that zfs rename can work for ALL the zones rather
> than working with two zones at a time?

As I said above.

>
> Also, is there a command line option available for sorting the datasets in
> correct dependency order?

"zfs list -r -o name,origin" is a good starting point.  I suspect that
it doesn't give you exactly the output you are looking for.

FWIW, the best way to achieve what you are after without breaking the
zones is going to be along the lines of:

zlogin z1c1 init 0
zoneadm -z z1c1 detach
zfs rename rpool/zones/z1c1 rpool/new/z1c1
zoneadm -z z1c1 'set zonepath=/new/z1c1'
zoneadm -z z1c1 attach
zoneadm -z z1c1 boot

-- 
Mike Gerdts
http://mgerdts.blogspot.com/
_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to