Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

[How-To] Renaming a plugin jail

Western Digital Drives - The Preferred Drives of FreeNAS and TrueNAS CORE

qwertymodo

Member
Joined
Apr 7, 2014
Messages
144
Really, the only reason I can think of for renaming a jail is because the plugin system tends to give its jails really stupid names like customplugin_1, which makes it hard to remember which jail corresponds to which plugin. If you're creating your own jails, you can name them whatever you like, so this shouldn't be necessary.

To be clear, I have done this multiple times, and it has worked every time, but that is no guarantee it will work for you, so back up your data, and proceed at your own peril.

To quote cyberjock:

Not supported dingbat!
There, you've been warned.

Also, I've never attempted this on a jail with snapshots, always on a brand-new jail for a freshly installed plugin. If somebody wants to try finding the snapshots and figuring out how to rename them, please let me know and I'll add it here.

Ok, now on to business. First of all, stop the plugin from the WebGUI by selecting Plugins>Installed and clicking the switch from On to Off.

Next, stop the jail from the WebGUI by selecting Jails, clicking on the jail, and then clicking the stop button below the jails list.

Now, in the shell, you can rename the jail using zfs rename:
Code:
zfs rename <poolname>/jails/<oldjailname> <poolname>/jails/<newjailname>


Note: the poolname does not include /mnt/ e.g. my jail was located at /mnt/vdev0/jails/customplugin_1 so I used
Code:
zfs rename vdev0/jails/customplugin_1 vdev0/jails/newjailname


This assumes you're using the default jails location. If not, you'll have to adjust the path.

Next, rename the jail metadata folder, which is located in the jails root folder.
Code:
mv /mnt/<poolname>/jails/.<oldjailname>.meta /mnt/<poolname>/jails/.<newjailname>.meta

Note the '.' at the beginning of the folder name

Now, change the hostname in following locations
<jailroot>/.<newjailname>.meta/host
<jailroot>/<newjailname>/etc/rc.conf
<jailroot>/<newjailname>/etc/hosts (change both places in this file)

Finally, update the FreeNAS database:
Code:
sqlite3 /data/freenas-v1.db
sqlite>update plugins_plugins set plugin_jail='newjailname' where plugin_jail='oldjailname';
sqlite>.q;

Note: don't forget the semicolons.

Now you can go back and start the jail and the plugin, in that order, and it should all be working.

If you have configured any mount points in your jail via the Jails>Add Storage, you'll need to re-add them.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Biznatch! You stole my quote.

I did confirm that this works. However, there is no guarantee that this will work in the future or that it won't cause some kind of unrecoverable problem. So "use at your own risk(or reward)".

Moving to hacking guides section of the forum.

Edit: One thing you should do is is fix the mountpoints since you renamed the dataset. ;)
 

Sirach Matthews

Junior Member
Joined
Sep 23, 2014
Messages
20
When I attempt to restart my jail, I receive the following error:

warden_exception('ERROR: No such jail!\n',)
 

Breit

Neophyte
Joined
Oct 4, 2016
Messages
8
Thank you very much. Works like a charm. This is what I was looking for! :)
Great guide.

One small thing though:
[...]
Finally, update the FreeNAS database:
Code:
sqlite3 /data/freenas-v1.db
sqlite>update plugins_plugins set plugin_jail='newjailname' where plugin_jail='oldjailname';
sqlite>.q;

Note: don't forget the semicolons.
[...]
I'm pretty confident that you should forget the semicolon in the last line. Exiting the sqlite prompt is done by just typing '.q'.
 

wattaj

Newbie
Joined
Jun 14, 2019
Messages
1
Oh man, I'm so bookmarking this post.
:cool:
 
Top