LINUX.ORG.RU

История изменений

Исправление Harliff, (текущая версия) :

Я воспроизвёл ситуацию с Вашим ZFS на временных файлах. Взгляните:

Создаём пул из временных файлов и экспортируем его:

# truncate -s 1G /tmp/1.img
# truncate -s 1G /tmp/2.img
# zpool create testpool mirror /tmp/1.img /tmp/2.img
# zpool export testpool

Портим один файл и пробуем импортировать пул.

# rm /tmp/1.img
# zpool import -d /tmp/

Получаем сообщение об ошибке:

   pool: testpool
     id: 4938152510598567359
  state: DEGRADED
status: One or more devices are missing from the system.
 action: The pool can be imported despite missing or damaged devices.  The
        fault tolerance of the pool may be compromised if imported.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-2Q
 config:

        testpool        DEGRADED
          mirror-0      DEGRADED
            /tmp/1.img  UNAVAIL  cannot open
            /tmp/2.img  ONLINE

Импортируем пул принудительно и проверяем его статус:

# zpool import -f testpool -d /tmp/
# zpool status
  pool: testpool
 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://openzfs.github.io/openzfs-docs/msg/ZFS-8000-2Q
  scan: scrub repaired 0B in 00:00:00 with 0 errors on Thu Jul  6 18:47:59 2023
config:

        NAME                      STATE     READ WRITE CKSUM
        testpool                  DEGRADED     0     0     0
          mirror-0                DEGRADED     0     0     0
            16783994244145232001  UNAVAIL      0     0     0  was /tmp/1.img
            /tmp/2.img            ONLINE       0     0     0

errors: No known data errors

Создаём ещё временный файл и заменяем им отсутствующее устройство:

# truncate -s 1G /tmp/3.img
# zpool replace testpool 16783994244145232001 /tmp/3.img

Проверяем результат:

# zpool status
  pool: testpool
 state: ONLINE
  scan: resilvered 242K in 00:00:00 with 0 errors on Thu Jul  6 18:49:50 2023
config:

        NAME            STATE     READ WRITE CKSUM
        testpool        ONLINE       0     0     0
          mirror-0      ONLINE       0     0     0
            /tmp/3.img  ONLINE       0     0     0
            /tmp/2.img  ONLINE       0     0     0

errors: No known data errors

Примечание: я указывал -d /tmp/, потому что мои файлы, изображающие из себя дисковые устройства, находились в нестандартном месте. Вам этого делать будет не нужно.

Исходная версия Harliff, :

Я воспроизвёл ситуацию с Вашим ZFS на временных файлах. Взгляните:

Создаём пул из временных файлов и экспортируем его:

# truncate -s 1G /tmp/1.img
# truncate -s 1G /tmp/2.img
# zpool create testpool mirror /tmp/1.img /tmp/2.img
# zpool export testpool

Портим один файл и пробуем импортировать пул.

# rm /tmp/1.img
# zpool import -d /tmp/

Получаем сообщение об ошибке:

   pool: testpool
     id: 4938152510598567359
  state: DEGRADED
status: One or more devices are missing from the system.
 action: The pool can be imported despite missing or damaged devices.  The
        fault tolerance of the pool may be compromised if imported.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-2Q
 config:

        testpool        DEGRADED
          mirror-0      DEGRADED
            /tmp/1.img  UNAVAIL  cannot open
            /tmp/2.img  ONLINE

Импортируем пул принудительно и проверяем его статус:

# zpool import -f testpool -d /tmp/
# zpool status
  pool: testpool
 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://openzfs.github.io/openzfs-docs/msg/ZFS-8000-2Q
  scan: scrub repaired 0B in 00:00:00 with 0 errors on Thu Jul  6 18:47:59 2023
config:

        NAME                      STATE     READ WRITE CKSUM
        testpool                  DEGRADED     0     0     0
          mirror-0                DEGRADED     0     0     0
            16783994244145232001  UNAVAIL      0     0     0  was /tmp/1.img
            /tmp/2.img            ONLINE       0     0     0

errors: No known data errors

Создаём ещё временный файл и заменяем им отсутствующее устройство:

# truncate -s 1G /tmp/3.img
# zpool replace testpool 16783994244145232001 /tmp/3.img

Проверяем результат:

# zpool status
  pool: testpool
 state: ONLINE
  scan: resilvered 242K in 00:00:00 with 0 errors on Thu Jul  6 18:49:50 2023
config:

        NAME            STATE     READ WRITE CKSUM
        testpool        ONLINE       0     0     0
          mirror-0      ONLINE       0     0     0
            /tmp/3.img  ONLINE       0     0     0
            /tmp/2.img  ONLINE       0     0     0

errors: No known data errors

Примечание: я указывал -d /tmp/, потому что мои файлы, изображающие из себя дисковые устройства находились в нестандартном месте. Вам этого делать будет не нужно.