zfs 强制导入多个 VMS(ID),现在找不到 VM,但根据 zfs 的说法,它并没有丢失?

zfs 强制导入多个 VMS(ID),现在找不到 VM,但根据 zfs 的说法,它并没有丢失?

我对 ZFS 完全陌生。今天,我做了一件蠢事,导致需要恢复整个操作系统。在我用来恢复机器的实时操作系统上,我需要安装 ZFS 卷进行数据传输。我做了以下操作:

root@kubuntu:/media/kubuntu/backup3-1tb/recovery# zpool import
   pool: nas-2-mirror
     id: 11643301469609613604
  state: ONLINE
status: The pool was last accessed by another system.
 action: The pool can be imported using its name or numeric identifier and
        the '-f' flag.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-EY
 config:

        nas-2-mirror                                               ONLINE
          mirror-0                                                 ONLINE
            usb-SanDisk_Extreme_55AE_32333135314D343031353938-0:0  ONLINE
            usb-SanDisk_Extreme_55AE_32333135325A343030313338-0:0  ONLINE

   pool: nas-1-mirror
     id: 10379406262813511849
  state: ONLINE
status: The pool was last accessed by another system.
 action: The pool can be imported using its name or numeric identifier and
        the '-f' flag.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-EY
 config:

        nas-1-mirror                                               ONLINE
          mirror-0                                                 ONLINE
            usb-SanDisk_Extreme_55AE_32333135314D343031323130-0:0  ONLINE
            usb-SanDisk_Extreme_55AE_323331363748343030333133-0:0  ONLINE
root@kubuntu:/media/kubuntu/backup3-1tb/recovery# zpool import -f 
   pool: nas-2-mirror
     id: 11643301469609613604
  state: ONLINE
status: The pool was last accessed by another system.
 action: The pool can be imported using its name or numeric identifier and
        the '-f' flag.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-EY
 config:

        nas-2-mirror                                               ONLINE
          mirror-0                                                 ONLINE
            usb-SanDisk_Extreme_55AE_32333135314D343031353938-0:0  ONLINE
            usb-SanDisk_Extreme_55AE_32333135325A343030313338-0:0  ONLINE

   pool: nas-1-mirror
     id: 10379406262813511849
  state: ONLINE
status: The pool was last accessed by another system.
 action: The pool can be imported using its name or numeric identifier and
        the '-f' flag.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-EY
 config:

        nas-1-mirror                                               ONLINE
          mirror-0                                                 ONLINE
            usb-SanDisk_Extreme_55AE_32333135314D343031323130-0:0  ONLINE
            usb-SanDisk_Extreme_55AE_323331363748343030333133-0:0  ONLINE
root@kubuntu:/media/kubuntu/backup3-1tb/recovery# zpool import -f 11643301469609613604 10379406262813511849
cannot import '10379406262813511849': name must begin with a letter
root@kubuntu:/media/kubuntu/backup3-1tb/recovery# zpool import -f nas-1-mirror nas-2-mirror  <<<==== THIS

现在nas-2-mirror好了!

root@kubuntu:~# zpool status
  pool: nas-2-mirror
 state: ONLINE
config:

        NAME                                                       STATE     READ WRITE CKSUM
        nas-2-mirror                                               ONLINE       0     0     0
          mirror-0                                                 ONLINE       0     0     0
            usb-SanDisk_Extreme_55AE_32333135314D343031323130-0:0  ONLINE       0     0     0
            usb-SanDisk_Extreme_55AE_323331363748343030333133-0:0  ONLINE       0     0     0

errors: No known data errors

但是,nas-1-mirror找不到。我尝试使用它的 ID 重新导入它:

root@kubuntu:~# zpool import -f 10379406262813511849
cannot import '10379406262813511849': a pool with that name already exists
use the form 'zpool import <pool | id> <newpool>' to give it a new name

root@kubuntu:~# zpool list
NAME           SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
nas-2-mirror  1.81T  40.1G  1.77T        -         -     0%     2%  1.00x    ONLINE  -

我想也许我通过同时导入两个卷弄乱了卷的名称,所以我采纳了上面导入的帮助建议,并尝试重命名该卷

root@kubuntu:~# zpool import -f 10379406262813511849 nas-1-mirror
cannot import '10379406262813511849': no such pool available

我想也许我可以尝试安装它?

root@kubuntu:~# zfs mount nas-1-mirror
cannot open 'nas-1-mirror': dataset does not exist

root@kubuntu:~# zfs list -o name,canmount,mountpoint
NAME          CANMOUNT  MOUNTPOINT
nas-2-mirror  on        /nas/nas-media

我有点担心。有人有其他方法可以让我试试吗?

编辑

啊哈!我明白我做了什么。我的导入将 ID 重命名为参数中第二个参数使用的 ID。

root@kubuntu:~# zpool list -o guid nas-2-mirror
 GUID
10379406262813511849

所以我需要弄清楚如何撤消此操作。

https://forums.freebsd.org/threads/renaming-zfs-pool-via-zpool-import-mypool-newpoolname.46300/是相关的(第二个问题),但没有关于如何解决该问题的明确答案。我尝试使用,zpool import -fa但得到:

root@kubuntu:~# zpool import -fa
cannot import 'nas-2-mirror': pool already exists

可能的解决方案

我暂时还不能尝试,但也许可以:https://illumos.org/books/zfs-admin/gavwn.html

部分:4.1.1. Using Disks in a ZFS Storage Pool

如果您不小心更改了设备的路径和 ID,请导出并重新导入池才能使用它。

当我可以时,我会尝试这个建议,看看它能给我带来什么。我会相应地发布。

我还看到zfs公开了一个rename命令,所以我也会尝试这个:

zfs rename 10379406262813511849 nas-1-mirror

手术做完之后我就开始工作了。我不想无意中弄乱任何东西。

答案1

首先请注意,对于任何使用此功能的人来说,都需要确保他们正在安全地使用他们的卷。 就我而言,我正在运行“实时”Ubuntu 会话。

好的!我能够很轻松地修复此问题。我必须采取的步骤如下:

  1. 导出已挂载的池

root@kubuntu:/# zpool export nas-2-mirror

  1. 将错误导入的 UID 导入到旧池名称(有效地将其重命名为我搞砸之前的名称......)

root@kubuntu:/# zpool import 10379406262813511849 nas-1-mirror

  1. 导入原始的 nas-2-mirror(强制导入并按 ID 导入,因为它在我的操作系统混乱中无意中丢失了(前面提到过)并且...
root@kubuntu:/# zpool import 11643301469609613604 nas-2-mirror
cannot import 'nas-2-mirror': pool was previously in use from another system.
Last accessed by your-linux-host (hostid=44ddb8ce) at Fri Oct  6 13:52:02 2023
The pool can be imported, use 'zpool import -f' to import the pool.
root@kubuntu:/# zpool import -f 11643301469609613604 nas-2-mirror

最后,检查一切是否正常:

root@kubuntu:/# zpool list
NAME           SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
nas-1-mirror  1.81T   234G  1.58T        -         -     0%    12%  1.00x    ONLINE  -
nas-2-mirror  1.81T  35.7G  1.78T        -         -     0%     1%  1.00x    ONLINE  -

相关内容