Adventures in ZFS: Rename a Zpool

Adventures in ZFS: Rename a Zpool

Renaming a zpool is not as intuitive as I would expect, but it is still pretty simple.  We accomplish this through a three step process, export the zpool, import the zpool (using a new name), validate our mountpoints are how we want them (probably using the new zpool name).

Now why might I want to rename it?  That is simple, perhaps it is simply for organization or perhaps you already have a zpool by that name, or perhaps you use zpool mirrors as a method of backup (break the mirror rename one side, rebuild mirror with a new disk maintaining the previous copy offline).

Export the Zpool

The first step is to obviously export the pool, if the source system is not available any longer (perhaps) you just have drives, then this can be skipped but it is definitely recommended.

# zpool export tank

Import the Zpool

Here we can rename tank to newtank on the import as demonstrated below.

# zpool import tank newtank

If for some reason you did not cleanly export the pool prior to performing the input you will need to use the -f as demonstrated below.  Please use caution as you are literally overriding the warning that the pool is active.  If it really is active you can cause serious damage.

# zpool import -f tank newtank

If you are missing a log device you can pass the -m option to import it without the log.

# zpool import -m tank newtank

Validate Mountpoint Property

Now depending on how your zfs are setup you could end up not having the correct mountpoints after this change, you will want to review this and ensure that this is what you expect.

# zfs get mountpoint newtank/fs1
newtank/fs1 mountpoint /tank/fs1 default

Now here we can see that the mountpoint is retaining the old property, this will only happen if you have broken inheritance, but if this is not the desired effect you will need to change it manually.

# zfs set mountpoint=/newtank/fs1 newtank/fs1

Also please remember that if you change the mountpoint you will need to update any NFS clients that utilize that mountpoint, so you will want to think about this step before you making changes.