| ||||||||
4.7 Storage Pool MigrationIt is occasionally necessary to move a storage pool between machines. To do so, the storage devices must be disconnected from the original machine and reconnected to the destination machine. This can be accomplished by physically recabling the devices, or by using multi-ported devices such as those on a SAN. ZFS provides the means to export the pool from one machine and import it on the destination machine, even if the machines are of different endianness. For information on replicating or migrating filesystems between different storage pools (which may be on different machines), see 5.7 Backing Up and Restoring ZFS Data. 4.7.1 Preparing for MigrationStorage pools should be explicitly exported to indicate that they are ready to be migrated. This flushes any unwritten data to disk, write data to the disk indicating that the export was done, and remove all knowledge of the pool from the system. If you do not explicitly export the pool, choosing instead to remove the disks manually, you can still import the resulting pool on another system. However, you may lose the last few seconds of data transactions, and the original machine will think the pool is faulted because the devices are no longer present. The destination machine will also refuse, by default, to import a pool that has not been explicitly exported. This is because the case is indistinguishable from network attached storage that is still in use on another system. 4.7.2 Exporting a PoolTo export a pool, use the zpool export command:
Once this command is executed, the pool tank is no longer visible on the system. The command attempts to unmount any mounted filesystems within the pool before continuing. If any of the filesystems fail to unmount, you can forcefully unmount them by using the -f flag:
If devices are unavailable at the time of export, the disks cannot be specified as cleanly exported. If one of these devices is later attached to a system without any of the working devices, it shows up as "potentially active". If there are emulated volumes in the pool that are in use, it cannot be exported, even with the -f option. To export a pool with an emulated volume, make sure all consumers of the volume are no longer active first. For more information on emulated volumes, see 8.1 Emulated Volumes. 4.7.3 Determining Available Pools to ImportOnce the pool has been removed from the system (either though export or forcefully removing the devices), attach the devices to the target system. Although ZFS can cope with some situations where only a portion of the devices are available, in general all devices within the pool must be moved between the systems. The devices do not necessarily have to be attached under the same device name; ZFS detects any moved or renamed devices and adjusts the configuration appropriately. To discover available pools, run the zpool import command with no options:
In the above example, the pool tank is available to be imported on the target system. Each pool is identified by a name as well as a unique numeric identifier. In the event that there are multiple available pools to import with the same name, the numeric identifier can be used to distinguish between them. The command attempts to display as much information as possible about the state of the devices in the pool. For example, if a pool appears to be in use on another system, or was not cleanly exported, a message similar to the following is displayed:
Similar to zpool status, the zpool import command refers to a knowledge article available on the web with the most up-to-date information regarding repair procedures for this problem. In this case, the user can force the pool to be imported. Be warned: importing a pool that is currently in use by another system over a storage network can result in data corruption and panics as both systems attempt to write to the same storage. If some of the devices in the pool are not available but there is enough redundancy to have a usable pool, the pool appears in the DEGRADED state:
In the above case, the second disk is damaged or missing, though you can still import the pool because the mirrored data is still accessible. If there are too many faulted or missing devices, the pool cannot be imported:
In this case, there are two disks missing from a RAID-Z virtual device, which means that there isn't sufficient replicated data available to reconstruct the pool. There are even some cases, where not enough devices are present to determine the complete configuration. In this case, ZFS doesn't know what other devices were part of the pool, though it does report as much information as possible about the situation:
4.7.4 Finding Pools From Alternate DirectoriesBy default, zpool import only searches devices within the /dev/dsk directory. If you have devices in another directory, or are using pools backed by files, you will need to use the -d option to search different directories:
If you have devices in multiple directories, multiple -d options can be specified. | ||||||||
| ||||||||