CrazySurfaNZ
Cadet
- Joined
- Apr 7, 2014
- Messages
- 4
Actually, nothing nasty happens. The jails won't start of course, but FreeNAS will continue running without problems.
In reality, the config DB contains only single reference to the jails location and you can change it via GUI. The reason why you can't just cp it over is that the jails (warden) uses ZFS features to use disk space effectively (that's the reason you can't use UFS with FreeNAS jails). One plugin jail consumes about 700MB of disk space. With 5 plugins/jails you would waste 4*700MB=2.8GB of disk space by basically identical files. Instead of creating copies, warden does a snapshot of the plugin template dataset and then creates individual plugin jails as ZFS clones of the template snapshot. If you cp this to a new location you will lose the snapshot/clone links. Therefore you need to use ZFS replication to relocate the jails. Another small complication is that warden explicitly sets the template dataset mountpoint.
Enough theory, this is the "Relocate jails how-to" :) :
Assumptions:
Steps:
- The pool you are transferring the jails from is main_pool
- The destination pool is ssd_pool
- The jail root (Jails->Configuration) is /mnt/main_pool/jails
- The new jail root will be /mnt/ssd_pool/jails
- Turn off all plugins (Plugins->Installed)
- Stop all jails (Jails->View Jails)
- Run these commands via CLI:[PANEL]zfs snapshot -r main_pool/jails@relocate
zfs send -R main_pool/jails@relocate | zfs receive -v ssd_pool/jails
zfs get -rH -o name -s received mountpoint ssd_pool/jails | xargs -I {} sh -c "zfs set mountpoint=/{} {}; zfs mount {};"[/PANEL]- Change the Jail Root to /mnt/ssd_pool/jails (Jails->Configuration)
- Start jails/plugins
- Check that everything works and destroy the original jails dataset (main_pool/jails)
I just did this myself on my freenas box.
A couple of things I found out:
1) Change to /mnt before you run the commands. You could probably include /mnt in the command itself, but I wanted to use the command exactly as Dusan posted it for maximum chances of success.
2) Don't try to be smart and create the 'jails' dataset on the new pool yourself before you run the commands, the commands will complain like follows:
[root@freenas /mnt]# zfs snapshot -r megaPool/jails@relocate
[root@freenas /mnt]# zfs send -R megaPool/jails@relocate | zfs receive -v dotsystem/jails
cannot receive new filesystem stream: destination 'dotsystem/jails' exists
must specify -F to overwrite it
warning: cannot send 'megaPool/jails@relocate': Broken pipe
cannot send 'megaPool/jails': I/O error
[root@freenas /mnt]# zfs send -R megaPool/jails@relocate | zfs receive -v dotsystem/jails
cannot receive new filesystem stream: destination 'dotsystem/jails' exists
must specify -F to overwrite it
warning: cannot send 'megaPool/jails@relocate': Broken pipe
cannot send 'megaPool/jails': I/O error
After I deleted my 'dotsystem/jails' dataset it worked as expected, though I got an error when I tried to create the snapshot again:
[root@freenas ~]# cd /mnt/
[root@freenas /mnt]# zfs snapshot -r megaPool/jails@relocate
cannot create snapshot 'megaPool/jails@relocate': dataset already exists
cannot create snapshot 'megaPool/jails/sabnzbd_1@relocate': dataset already exists
cannot create snapshot 'megaPool/jails/plexmediaserver_1@relocate': dataset already exists
cannot create snapshot 'megaPool/jails/sonarr_1@relocate': dataset already exists
cannot create snapshot 'megaPool/jails/.warden-template-pluginjail@relocate': dataset already exists
no snapshots were created
[root@freenas /mnt]# zfs send -R megaPool/jails@relocate | zfs receive -v dotsystem/jails
receiving full stream of megaPool/jails@relocate into dotsystem/jails@relocate
received 111KB stream in 1 seconds (111KB/sec)
receiving full stream of megaPool/jails/.warden-template-pluginjail@clean into dotsystem/jails/.warden-template-pluginjail@clean
received 1.19GB stream in 13 seconds (93.7MB/sec)
receiving incremental stream of megaPool/jails/.warden-template-pluginjail@relocate into dotsystem/jails/.warden-template-pluginjail
@relocate
received 48.6KB stream in 1 seconds (48.6KB/sec)
found clone origin dotsystem/jails/.warden-template-pluginjail@clean
receiving incremental stream of megaPool/jails/sabnzbd_1@relocate into dotsystem/jails/sabnzbd_1@relocate
received 234MB stream in 4 seconds (58.5MB/sec)
found clone origin dotsystem/jails/.warden-template-pluginjail@clean
receiving incremental stream of megaPool/jails/plexmediaserver_1@relocate into dotsystem/jails/plexmediaserver_1@relocate
received 2.84GB stream in 54 seconds (53.9MB/sec)
found clone origin dotsystem/jails/.warden-template-pluginjail@clean
receiving incremental stream of megaPool/jails/sonarr_1@relocate into dotsystem/jails/sonarr_1@relocate
received 545MB stream in 7 seconds (77.9MB/sec)
[root@freenas /mnt]# zfs get -rH -o name -s received mountpoint dotsystem/jails | xargs -I {} sh -c "zfs set mountpoint=/{} {}; zfs
mount {};"
[root@freenas /mnt]# zfs snapshot -r megaPool/jails@relocate
cannot create snapshot 'megaPool/jails@relocate': dataset already exists
cannot create snapshot 'megaPool/jails/sabnzbd_1@relocate': dataset already exists
cannot create snapshot 'megaPool/jails/plexmediaserver_1@relocate': dataset already exists
cannot create snapshot 'megaPool/jails/sonarr_1@relocate': dataset already exists
cannot create snapshot 'megaPool/jails/.warden-template-pluginjail@relocate': dataset already exists
no snapshots were created
[root@freenas /mnt]# zfs send -R megaPool/jails@relocate | zfs receive -v dotsystem/jails
receiving full stream of megaPool/jails@relocate into dotsystem/jails@relocate
received 111KB stream in 1 seconds (111KB/sec)
receiving full stream of megaPool/jails/.warden-template-pluginjail@clean into dotsystem/jails/.warden-template-pluginjail@clean
received 1.19GB stream in 13 seconds (93.7MB/sec)
receiving incremental stream of megaPool/jails/.warden-template-pluginjail@relocate into dotsystem/jails/.warden-template-pluginjail
@relocate
received 48.6KB stream in 1 seconds (48.6KB/sec)
found clone origin dotsystem/jails/.warden-template-pluginjail@clean
receiving incremental stream of megaPool/jails/sabnzbd_1@relocate into dotsystem/jails/sabnzbd_1@relocate
received 234MB stream in 4 seconds (58.5MB/sec)
found clone origin dotsystem/jails/.warden-template-pluginjail@clean
receiving incremental stream of megaPool/jails/plexmediaserver_1@relocate into dotsystem/jails/plexmediaserver_1@relocate
received 2.84GB stream in 54 seconds (53.9MB/sec)
found clone origin dotsystem/jails/.warden-template-pluginjail@clean
receiving incremental stream of megaPool/jails/sonarr_1@relocate into dotsystem/jails/sonarr_1@relocate
received 545MB stream in 7 seconds (77.9MB/sec)
[root@freenas /mnt]# zfs get -rH -o name -s received mountpoint dotsystem/jails | xargs -I {} sh -c "zfs set mountpoint=/{} {}; zfs
mount {};"