
Version | Effective: 30/11/2009 |
5.3.8. Duplicating zones with zoneadm detach/attach and zfs clone
[ug] First, the zone "test" is moved to its own ZFS file system. The file system must only be available from root otherwise an error message will appear.
global# zfs create container/ztest |
|
|
| |||
global# ls | /container/ztest |
|
|
| ||
2 | root | root | 2 | Feb 19 | 16:00 /container/ztest | |
global# chmod |
|
|
| |||
global# ls | /container/ztest |
|
|
| ||
2 | root | root | 2 | Feb 19 | 16:00 /container/ztest | |
|
|
|
|
|
|
|
Next, the zone is moved to the separate ZFS file system. The configuration is adjusted automatically; to do so, it must of course be shut down.
global# zoneadm
Moving across
Cleaning up zonepath /container/test...
The zone is detached, and the current status of the file system is recorded with zfs snapshot as a
global# zoneadm
global# zfs snapshot container/ztest@gold global# zoneadm
global# zoneadm
A copy of the zone is created by generating a writable version of the zone file system with zfs
clone.
global# zfs clone container/ztest@gold container/ztest2
global# zfs list |
|
|
|
|
NAME | USED | AVAIL | REFER | MOUNTPOINT |
container | 181M | 803M | 88.7M | /container |
container/ztest | 91.8M | 803M | 88.7M | /container/ztest |
container/ztest@gold | 3.07M | - | 90.4M | - |
container/ztest2 | 0 | 803M | 90.4M | /container/ztest2 |
In order to activate the zone copy, it must be configured, and the zone path must be adjusted. Subsequently, it is sufficient to use zoneadm attach and the zone can be started up.
global# zonecfg | |
test2: No such zone configured | |
Use 'create' to | begin configuring a new zone. |
global# zonecfg | |
global# zoneadm | |
global# zoneadm | |
|
|
In the zone, the name of the OS instance is still the same of course since the file /etc/nodename has not yet been changed. Furthermore, it makes sense to adapt the network addresses as well, just like the zonepath adaptation performed here.
Additional zones with the same OS content can now be created very quick by repeating the steps zfs clone / zonecfg / zoneadm attach.
In the same way, zones can also be moved to other systems with zoneadm detach / attach. A prerequisite is that the same package and patch status is present on the target system. By using the option zoneadm attach
Since Solaris 10 5/09, zfs clone is used automatically with the command zoneadm