9

Now that our server is set up, I would like to rename our zpools.

I read somewhere that the way to do this is export & re-import under the new name. But will all my mount points and shares remain intact? Or will I have to set those up again?

3 Answers 3

4

Actually, you can rename a zpool. Just not live. It is done exactly as you suggested. You can only export & re-import it using the new name. 'man zpool import' explains it:

 zpool import [-o mntopts] [ -o property=value] ... [-d dir | -c cachefile] [-D] [-f] [-R root] pool | id [newpool] Imports a specific pool. A pool can be identified by its name or the numeric identifier. If newpool is specified, the pool is imported using the name newpool. Otherwise, it is imported with the same name as its exported name. 

It is worth noting that while your mounts will likely survive, they won't be where they used to be, most likely. If you were, for example, importing NFS mounts on a client using 192.168.1.5:/<pool>/<dataset> then the mount would change to 192.168.1.5:/<new-pool-name>/<dataset>. Since you have to export the pool to rename it anyway, this task of renaming a pool IS a downtime event -- so if on re-import you have to reset some mounts or change some mountpoints on the server, I don't see that it's that huge a deal.

2

Nope, you can’t just zpool rename and call it a day. ZFS doesn’t work like that, because the pool name lives in the on-disk labels, and Oracle/Sun/illumos/FreeBSD/Linux devs never gave us a command to flip it.

The official way, and the only “sane” one.

Take the pool offline and do:

zpool export oldpool zpool import oldpool newpool 

Boom, renamed! Then go clean up all the places that still think it’s called oldpool, /etc/fstab, zpool.cache, any systemd mount units, backup scripts, cron jobs, whatever cruft you’ve accumulated over the years.

If downtime makes your boss scream…

Spin up a new pool with the shiny name, and sling the data over with zfs send | zfs recv, do:

zfs snapshot -r oldpool@snap zfs send -R oldpool@snap | zfs recv newpool 

Yeah, it’s slow and needs extra disks, but that’s life if you want zero downtime.

What NOT to do?

Don’t get cute with zdb or a hex editor. Sure, you might manage to hack the labels, but odds are you end up with a pool that refuses to import and a very bad day.

TL;DR: There’s no black magic zpool rename. Export/import if you can stomach the outage. If not, build a new pool and replicate. Anything else is asking for pain.

-2
#!/bin/sh function zpool_rename() { local oldname="$1" local newname="$2" zpool list && zpool export "$oldname" && zpool import "$oldname" "$newname" && zpool list } 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.