Sun Microsystems
Products & Services
 
Support & Training
 
 

Previous Previous     Contents     Next Next

4.7 Storage Pool Migration

It 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 Migration

Storage 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 Pool

To export a pool, use the zpool export command:

# zpool export tank

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:

# zpool export tank
cannot unmount '/export/home/eschrock': Device busy
# zpool export -f tank

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 Import

Once 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:

# zpool import
  pool:  tank
    id:  3824973938571987430916523081746329
 state:  ONLINE
 action: The pool can be imported using its name or numeric identifier.  The
         pool may be active on on another system, but can be imported using
         the '-f' flag.
config:

        mirror              ONLINE
          c0t0d0            ONLINE
          c0t0d1            ONLINE

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:

# zpool import
  pool: tank
    id: 3824973938571987430916523081746329
 state: DEGRADED
action: This pool appears to be in use or may not have been
        cleanly exported.  Use the '-f' flag to import this
        pool.
   see: http://www.sun.com/msg/ZFS-XXXX-13
config:

        mirror              ONLINE
          c0t0d0            ONLINE
          c0t0d1            ONLINE

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:

# zpool import
  pool: tank
    id: 3824973938571987430916523081746329
action: DEGRADED
  desc: This pool can be imported despite missing some
        devices.  The fault tolerance of the pool may
        be compromised.
   see: http://www.sun.com/msg/ZFS-XXXX-12
config:

        mirror              DEGRADED
          c0t0d0            ONLINE
          c0t0d1            FAULTED

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:

# zpool import
  pool: dozer
    id: 129384759861034862594739890875563
 state: FAULTED
action: This pool cannot be imported because the necessary
        devices are missing or damaged.  Attach the
        unavailable devices and try again.
   see: http://www.sun.com/msg/ZFS-XXXX-11
config:

        raidz               FAULTED
          c0t0d0            ONLINE
          c0t0d1            FAULTED
          c0t0d2            ONLINE
          c0t0d3            FAULTED

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:

# zpool import
  pool: tank
    id: 3824973938571987430916523081746329
 state: FAULTED
action: This pool cannot be imported because some
        devices are missing.  The following is a partial
        configuration.  Attach the additional unknown devices
        and try again.
   see: http://www.sun.com/msg/ZFS-XXXX-12
config:

        mirror              ONLINE
          c0t0d0            ONLINE
          c0t0d1            ONLINE

        Additional devices are known to be part of this pool,
        though their exact configuration cannot be determined.

4.7.4 Finding Pools From Alternate Directories

By 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:

# zpool create dozer /file/a /file/b
# zpool export dozer
# zpool import
no pools available
# zpool import -d /file
  pool: dozer
    id: 672153753596386982
 state: ONLINE
action: The pool can be imported using its name or numeric identifier.
config:

        dozer       ONLINE
          /file/a   ONLINE
          /file/b   ONLINE
# zpool import -d /file dozer

If you have devices in multiple directories, multiple -d options can be specified.

Previous Previous     Contents     Next Next