确定要导入的池后,即可通过将该池的名称或者其数字标识符指定为 zpool import 命令的参数来将其导入。例如:
# zpool import tank
如果多个可用池具有相同名称,则必须使用数字标识符指定要导入的池。例如:
# zpool import pool: dozer id: 2704475622193776801 state: ONLINE action: The pool can be imported using its name or numeric identifier. config: dozer ONLINE c1t9d0 ONLINE pool: dozer id: 6223921996155991199 state: ONLINE action: The pool can be imported using its name or numeric identifier. config: dozer ONLINE c1t8d0 ONLINE # zpool import dozer cannot import 'dozer': more than one matching pool import by numeric ID instead # zpool import 6223921996155991199
如果池名称与现有池名称冲突,则可以采用其他名称导入该池。例如:
# zpool import dozer zeepool
此命令使用新名称 zeepool 导入已导出的池 dozer。新的池名称是持久性的。
如果池未正常导出,则 ZFS 需要使用 –f 标志,以防止用户意外导入仍在其他系统中使用的池。例如:
# zpool import dozer cannot import 'dozer': pool may be in use on another system use '-f' to import anyway # zpool import -f dozer
通过使用 –R 选项还可以在备用根下导入池。有关备用根池的更多信息,请参见通过备用根位置使用 ZFS 池。
缺省情况下,无法导入缺少日志设备的池。但是,可以使用 zpool import –m 命令强制导入缺少日志设备的池。例如:
# zpool import dozer pool: dozer id: 16216589278751424645 state: UNAVAIL status: One or more devices are missing from the system. action: The pool cannot be imported. Attach the missing devices and try again. see: http://support.oracle.com/msg/ZFS-8000-6X config: dozer UNAVAIL missing device mirror-0 ONLINE c8t0d0 ONLINE c8t1d0 ONLINE device details: missing-1 UNAVAIL corrupted data status: ZFS detected errors on this device. The device has bad label or disk contents. Additional devices are known to be part of this pool, though their exact configuration cannot be determined.
导入缺少日志设备的池。例如:
# zpool import -m dozer # zpool status dozer pool: dozer state: DEGRADED status: One or more devices are unavailable in response to persistent errors. Sufficient replicas exist for the pool to continue functioning in a degraded state. action: Determine if the device needs to be replaced, and clear the errors using 'zpool clear' or 'fmadm repaired', or replace the device with 'zpool replace'. Run 'zpool status -v' to see device specific details. scan: none requested config: NAME STATE READ WRITE CKSUM dozer DEGRADED 0 0 0 mirror-0 ONLINE 0 0 0 c8t0d0 ONLINE 0 0 0 c8t1d0 ONLINE 0 0 0 logs 2189413556875979854 UNAVAIL 0 0 0 errors: No known data errors
在附加了缺少的日志设备后,运行 zpool clear 命令清除池错误。
缺少镜像日志设备时,也可以尝试进行类似的恢复:例如:
# zpool import dozer The devices below are missing, use '-m' to import the pool anyway: mirror-1 [log] c3t3d0 c3t4d0 cannot import 'dozer': one or more devices is currently unavailable # zpool import -m dozer # zpool status dozer pool: dozer state: DEGRADED status: One or more devices could not be opened. Sufficient replicas exist for the pool to continue functioning in a degraded state. action: Attach the missing device and online it using 'zpool online'. see: https://support.oracle.com/epmos/faces/KmHome?_adf.ctrl-state=10oxbvnj5n_4&_afrLoop=1145647522713 scan: scrub repaired 0 in 0h0m with 0 errors on Fri Oct 15 16:51:39 2010 config: NAME STATE READ WRITE CKSUM dozer DEGRADED 0 0 0 mirror-0 ONLINE 0 0 0 c3t1d0 ONLINE 0 0 0 c3t2d0 ONLINE 0 0 0 logs mirror-1 UNAVAIL 0 0 0 insufficient replicas 13514061426445294202 UNAVAIL 0 0 0 was c3t3d0 16839344638582008929 UNAVAIL 0 0 0 was c3t4d0
在附加了缺少的日志设备后,运行 zpool clear 命令清除池错误。
可以在只读模式下导入池。如果池受损严重而无法访问,此功能也许能使您恢复池中的数据。例如:
# zpool import -o readonly=on tank # zpool scrub tank cannot scrub tank: pool is read-only
在只读模式下导入池时,须符合以下条件:
所有文件系统和卷均以只读模式挂载。
池的事务处理功能被禁用。这也意味着,意图日志 (intent log) 中任何暂停的同步写入操作只有在读写模式下导入池后才启动。
只读导入期间,将忽略对池属性的设置尝试。
通过导出再导入池的方法,可以将只读池设置回读写模式。例如:
# zpool export tank # zpool import tank # zpool scrub tank
在本示例中,以下命令通过标识池 dpool 的其中一个特定设备 /dev/dsk/c2t3d0 来导入该池。
# zpool import -d /dev/dsk/c2t3d0s0 dpool # zpool status dpool pool: dpool state: ONLINE scan: resilvered 952K in 0h0m with 0 errors on Fri Jun 29 16:22:06 2012 config: NAME STATE READ WRITE CKSUM dpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c2t3d0 ONLINE 0 0 0 c2t1d0 ONLINE 0 0 0
即使该池由整个磁盘组成,该命令也必须包括特定设备的分片标识符。