Welcome to Machine Unix

Search Below

Promoting a ZFS File System

This came up at work a while ago when I was trying to troubleshoot an issue with a particular zone I was working with. Although promoting a zfs file system is a very well documented bits of ZFS, it just could not stop me from blogging about it. I have a file system resides on ZFS which happens to be a Solaris zone. Normally, if you are doing application testing in your installations on top of a solaris zone, you could take a snapshot of the FS, and if things go bad you can just rollback and everything is fine, like the following procedure.

[root@merlin]# zfs snapshot rpool/zones/zdev@040411

[root@merlin]# zlogin zdev

[root@zdev]# ./install my_application

……things go bad here…..you are confused and not able to come back to original state……

[root@zdev] # exit

[root@merlin]# zfs rollback rpool/zones/zdev@040411

So at this point, things are dandy and you are back where you are started. You can even destroy the snapshot if you like and move on with your life. However, what if you want to leave the zone in its original state and do a testing in its clone? Sure thing, you can clone the zone but things get interesting when you want to get rid of the snapshot:

[root@merlin]# zfs snapshot rpool/zones/zdev@040411

[root@merlin]# zfs clone rpool/zones/zdev@040411 rpool/zones/zprod

[root@merlin]# zfs destroy rpool/zones/zdev@040411

cannot destroy ‘rpool/zones/zdev@040411′: snapshot has dependent clones
use ‘-R’ to destroy the following datasets:

Oops, the system is telling you to remove the clone you just created to get rid of the snapshot which really defeated the purpose. So, with “zfs promote” the idea is to gain independence from the originating dataset so that you can basically do whatever you like to do with it. So before the promote operation:

[root@merlin]# zfs list


rpool/zones/zdev                        96.0M  71.9G  96.0M  /zones/zdev
rpool/zones/zdev@040411        0      –  96.0M  –
rpool/zones/zprod                       0  71.9G  96.0M  /zones/zprod

Let’s see what happens after using promote:

[root@merlin]# zfs promote rpool/zones/zprod


rpool/zones/zdev                          0  71.9G  96.0M  /zones/zdev
rpool/zones/zprod                        96.0M  71.9G  96.0M  /zones/zprod
rpool/zones/zprod@040411       0      –  96.0M  –

This is very cool, not only zprod is now independent of the snapshot but it also gained or rather it was switched to carry on with the snapshot. You can now set up your /etc/index file and /etc/zones/zprod.xml to actually get the cloned zone to installed state and boot it. This will lead you to have two zones running in your system, namely zdev and zprod. You can now even do normal zone operations on zdev to uninstall and delete the configuration files to reduce the system running on only single zone with way settings and configurations you wanted.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>