如何使用 uuid 或真正唯一的标识符创建 zpool?

如何使用 uuid 或真正唯一的标识符创建 zpool?

前几天我创建了我的第一个 zpool,通过驱动器盘符分配,发现当我重新启动时它已经降级了。经过仔细检查,我意识到我的驱动器号在重新启动后发生了变化,所以我认为我应该使用 UUID 来完成此操作。

我查看了 blkid,发现两个驱动器都有相同的 uuid,大概是因为它们是镜像的。所以我销毁了池并在磁盘上创建了新的分区表。当我再次运行 blkid 时,我看到驱动器不再有 UUID,只有 PTID。这让我意识到 UUID 是文件系统的属性,而不是驱动器本身。

因此,我尝试将 /dev/disk/by-id/ 与格式化驱动器的 UUID 和未格式化驱动器的 PTID 一起使用。两者都不起作用。

user@ubuntu:~$ sudo zpool create nvme-tank mirror /dev/disk/by-id/493fa01d /dev/disk/by-id/9398aa9e
cannot resolve path '/dev/disk/by-id/493fa01d'

user@ubuntu:~$ sudo zpool create nvme-tank mirror /dev/disk/by-id/713e95ab-f307-466c-bc6c-f9ec97914a6a /dev/disk/by-id/44042f83-1654-45b4-9803-42107393af6c
cannot resolve path '/dev/disk/by-id/713e95ab-f307-466c-bc6c-f9ec97914a6a'

这是 blkid 的输出:

/dev/sdb1: UUID="1977-5195" TYPE="vfat" PARTUUID="117c616a-01"
/dev/sdd1: UUID="3d09d690-6110-3c87-abb6-c286e58cf8ae" UUID_SUB="481418c7-ff1c-3ee6-21e1-48be73d0a083" LABEL="ubuntu:0" TYPE="linux_raid_member" PARTUUID="edbfb533-01"
/dev/sdd2: UUID="bb4a8e51-48de-3c04-435f-d48ba763b176" UUID_SUB="3cd3b591-6c08-23df-c885-812b8a4dae09" LABEL="ubuntu:1" TYPE="linux_raid_member" PARTUUID="edbfb533-02"
/dev/sde1: UUID="3d09d690-6110-3c87-abb6-c286e58cf8ae" UUID_SUB="294836fe-a958-5aa8-f9e7-fcb0d5b3ad68" LABEL="ubuntu:0" TYPE="linux_raid_member" PARTUUID="870c34a5-01"
/dev/sde2: UUID="bb4a8e51-48de-3c04-435f-d48ba763b176" UUID_SUB="4f2b1400-7d20-79f5-106f-33fdb0dafc36" LABEL="ubuntu:1" TYPE="linux_raid_member" PARTUUID="870c34a5-02"
/dev/md1: UUID="be1c70fd-3000-4a69-9106-efc73309693d" TYPE="ext4"
/dev/md0: UUID="4c0b7a2c-1b40-4979-868a-0e363bcbe771" TYPE="swap"
/dev/nvme1n1p1: UUID="713e95ab-f307-466c-bc6c-f9ec97914a6a" TYPE="ext4" PARTUUID="9398aa9e-01"
/dev/nvme2n1p1: UUID="24d22c02-be8f-41ba-9907-9494b03c16bb" TYPE="ext4" PARTUUID="edc5ee37-01"
/dev/nvme0n1p1: UUID="44042f83-1654-45b4-9803-42107393af6c" TYPE="ext4" PARTUUID="493fa01d-01"
/dev/nvme0n1: PTUUID="493fa01d" PTTYPE="dos"
/dev/nvme2n1: PTUUID="edc5ee37" PTTYPE="dos"
/dev/nvme1n1: PTUUID="9398aa9e" PTTYPE="dos"
/dev/sda: PTUUID="d5f5a456" PTTYPE="dos"
/dev/sdc: PTUUID="b462c818" PTTYPE="dos"

我查看的一些线程引导我查看 /etc/default/zfs 我发现相关行已被注释掉,但我不确定如何处理上面的注释,这些注释的措辞方式是让我困惑:

# Specify specific path(s) to look for device nodes and/or links for the
# pool import(s). See zpool(8) for more information about this variable.
# It supersedes the old USE_DISK_BY_ID which indicated that it would only
# try '/dev/disk/by-id'.
# The old variable will still work in the code, but is deprecated.
#ZPOOL_IMPORT_PATH="/dev/disk/by-vdev:/dev/disk/by-id"

所以,我的问题是,我可以使用唯一且永久的标识符(例如序列号)直接创建 zpool 吗?或者是否有另一种通过 UUID 创建它们的实际有效的方法?

我在 Ubuntu Server 18.04 上使用 ZFS

编辑:进一步的尝试我也尝试了这里的建议:https://ubuntuforums.org/showthread.php?t=2087726

user@ubuntu:~$ sudo zpool create nvme-tank mirror nvme0n1 nvme1n1
user@ubuntu:~$ sudo zpool export nvme-tank
user@ubuntu:~$ sudo zpool import -d /dev/disk/by-id nvme-tank

但现在我在 blkid 中根本看不到它们:

/dev/sdb1: UUID="1977-5195" TYPE="vfat" PARTUUID="117c616a-01"
/dev/sdd1: UUID="3d09d690-6110-3c87-abb6-c286e58cf8ae" UUID_SUB="481418c7-ff1c-3ee6-21e1-48be73d0a083" LABEL="ubuntu:0" TYPE="linux_raid_member" PARTUUID="edbfb533-01"
/dev/sdd2: UUID="bb4a8e51-48de-3c04-435f-d48ba763b176" UUID_SUB="3cd3b591-6c08-23df-c885-812b8a4dae09" LABEL="ubuntu:1" TYPE="linux_raid_member" PARTUUID="edbfb533-02"
/dev/sde1: UUID="3d09d690-6110-3c87-abb6-c286e58cf8ae" UUID_SUB="294836fe-a958-5aa8-f9e7-fcb0d5b3ad68" LABEL="ubuntu:0" TYPE="linux_raid_member" PARTUUID="870c34a5-01"
/dev/sde2: UUID="bb4a8e51-48de-3c04-435f-d48ba763b176" UUID_SUB="4f2b1400-7d20-79f5-106f-33fdb0dafc36" LABEL="ubuntu:1" TYPE="linux_raid_member" PARTUUID="870c34a5-02"
/dev/md1: UUID="be1c70fd-3000-4a69-9106-efc73309693d" TYPE="ext4"
/dev/md0: UUID="4c0b7a2c-1b40-4979-868a-0e363bcbe771" TYPE="swap"
/dev/nvme2n1p1: UUID="24d22c02-be8f-41ba-9907-9494b03c16bb" TYPE="ext4" PARTUUID="edc5ee37-01"

答案1

UUID并不总是可见的,(特别是在VM环境中)我建议创建一个分区表并使用帕图UID

当您能够列出所需的分区后

lsblk --ascii -o NAME,PARTUUID,LABEL,PATH,FSTYPE
zpool create pool02 /dev/disk/by-partuuid/c8e0c300-5ec9-714c-aef9-fa0dc3f0cab6

当对整个原始磁盘进行分区表时,不会产生性能损失,并且检查分区表可以在灾难恢复时节省您的工作

答案2

我使用 ZFS 的 Arch 文档解决了这个问题:创建存储池

毁了我的旧泳池

user@ubuntu:~$ sudo zpool destroy nvme-tank
user@ubuntu:~$ zpool list
no pools available

获取基于磁盘序列号的 ID(不是 uuid)持久块设备命名;按 ID 和按路径

'by-id 根据硬件序列号创建唯一的名称,by-id 还创建支持它的存储设备的全球通用名称链接。与其他 by-id 链接不同,WWN 是完全持久的,不会根据所使用的子系统而改变。 '

user@ubuntu:~$ ls -lh /dev/disk/by-id/
total 0
lrwxrwxrwx 1 root root  9 Oct  9 17:04 ata-HGST_HUH728080ALN600_VJH620YX -> ../../sda
lrwxrwxrwx 1 root root  9 Oct  9 17:04 ata-HGST_HUH728080ALN600_VJH624KX -> ../../sdc
lrwxrwxrwx 1 root root  9 Oct  9 17:04 ata-Samsung_SSD_850_EVO_120GB_S21SNX0H915160K -> ../../sdd
lrwxrwxrwx 1 root root 10 Oct  9 17:04 ata-Samsung_SSD_850_EVO_120GB_S21SNX0H915160K-part1 -> ../../sdd1
lrwxrwxrwx 1 root root 10 Oct  9 17:04 ata-Samsung_SSD_850_EVO_120GB_S21SNX0H915160K-part2 -> ../../sdd2
lrwxrwxrwx 1 root root  9 Oct  9 17:04 ata-Samsung_SSD_850_EVO_120GB_S21SNX0H915161E -> ../../sde
lrwxrwxrwx 1 root root 10 Oct  9 17:04 ata-Samsung_SSD_850_EVO_120GB_S21SNX0H915161E-part1 -> ../../sde1
lrwxrwxrwx 1 root root 10 Oct  9 17:04 ata-Samsung_SSD_850_EVO_120GB_S21SNX0H915161E-part2 -> ../../sde2
lrwxrwxrwx 1 root root  9 Oct  9 17:04 md-name-ubuntu:0 -> ../../md0
lrwxrwxrwx 1 root root  9 Oct  9 17:04 md-name-ubuntu:1 -> ../../md1
lrwxrwxrwx 1 root root  9 Oct  9 17:04 md-uuid-3d09d690:61103c87:abb6c286:e58cf8ae -> ../../md0
lrwxrwxrwx 1 root root  9 Oct  9 17:04 md-uuid-bb4a8e51:48de3c04:435fd48b:a763b176 -> ../../md1
lrwxrwxrwx 1 root root 13 Oct  9 17:04 nvme-eui.0025385481b1ea19 -> ../../nvme2n1
lrwxrwxrwx 1 root root 15 Oct  9 17:04 nvme-eui.0025385481b1ea19-part1 -> ../../nvme2n1p1
lrwxrwxrwx 1 root root 13 Oct  9 19:11 nvme-eui.0025385581b40c9c -> ../../nvme0n1
lrwxrwxrwx 1 root root 13 Oct  9 19:11 nvme-eui.0025385581b40e03 -> ../../nvme1n1
lrwxrwxrwx 1 root root 13 Oct  9 17:04 nvme-Samsung_SSD_960_EVO_1TB_S3X3NF0K400271N -> ../../nvme2n1
lrwxrwxrwx 1 root root 15 Oct  9 17:04 nvme-Samsung_SSD_960_EVO_1TB_S3X3NF0K400271N-part1 -> ../../nvme2n1p1
lrwxrwxrwx 1 root root 13 Oct  9 19:11 nvme-Samsung_SSD_970_EVO_1TB_S467NF0K510805L -> ../../nvme0n1
lrwxrwxrwx 1 root root 13 Oct  9 19:11 nvme-Samsung_SSD_970_EVO_1TB_S467NF0K511164Z -> ../../nvme1n1
lrwxrwxrwx 1 root root  9 Oct  9 17:04 usb-Samsung_Flash_Drive_0373617100005284-0:0 -> ../../sdb
lrwxrwxrwx 1 root root 10 Oct  9 17:04 usb-Samsung_Flash_Drive_0373617100005284-0:0-part1 -> ../../sdb1
lrwxrwxrwx 1 root root  9 Oct  9 17:04 wwn-0x5000cca261d0d95a -> ../../sda
lrwxrwxrwx 1 root root  9 Oct  9 17:04 wwn-0x5000cca261d0d9ca -> ../../sdc
lrwxrwxrwx 1 root root  9 Oct  9 17:04 wwn-0x5002538d413f3b81 -> ../../sdd
lrwxrwxrwx 1 root root 10 Oct  9 17:04 wwn-0x5002538d413f3b81-part1 -> ../../sdd1
lrwxrwxrwx 1 root root 10 Oct  9 17:04 wwn-0x5002538d413f3b81-part2 -> ../../sdd2
lrwxrwxrwx 1 root root  9 Oct  9 17:04 wwn-0x5002538d413f3b87 -> ../../sde
lrwxrwxrwx 1 root root 10 Oct  9 17:04 wwn-0x5002538d413f3b87-part1 -> ../../sde1
lrwxrwxrwx 1 root root 10 Oct  9 17:04 wwn-0x5002538d413f3b87-part2 -> ../../sde2

做了新的游泳池,似乎有效。我猜想池中的第一个设备不会在 lsblk 中显示?

user@ubuntu:~$ sudo zpool create nvme-tank mirror nvme-Samsung_SSD_970_EVO_1TB_S467NF0K510805L nvme-Samsung_SSD_970_EVO_1TB_S467NF0K511164Z
user@ubuntu:~$ blkid
/dev/sdb1: UUID="1977-5195" TYPE="vfat" PARTUUID="117c616a-01"
/dev/sdd1: UUID="3d09d690-6110-3c87-abb6-c286e58cf8ae" UUID_SUB="481418c7-ff1c-3ee6-21e1-48be73d0a083" LABEL="ubuntu:0" TYPE="linux_raid_member" PARTUUID="edbfb533-01"
/dev/sdd2: UUID="bb4a8e51-48de-3c04-435f-d48ba763b176" UUID_SUB="3cd3b591-6c08-23df-c885-812b8a4dae09" LABEL="ubuntu:1" TYPE="linux_raid_member" PARTUUID="edbfb533-02"
/dev/sde1: UUID="3d09d690-6110-3c87-abb6-c286e58cf8ae" UUID_SUB="294836fe-a958-5aa8-f9e7-fcb0d5b3ad68" LABEL="ubuntu:0" TYPE="linux_raid_member" PARTUUID="870c34a5-01"
/dev/sde2: UUID="bb4a8e51-48de-3c04-435f-d48ba763b176" UUID_SUB="4f2b1400-7d20-79f5-106f-33fdb0dafc36" LABEL="ubuntu:1" TYPE="linux_raid_member" PARTUUID="870c34a5-02"
/dev/md1: UUID="be1c70fd-3000-4a69-9106-efc73309693d" TYPE="ext4"
/dev/md0: UUID="4c0b7a2c-1b40-4979-868a-0e363bcbe771" TYPE="swap"
/dev/nvme2n1p1: UUID="24d22c02-be8f-41ba-9907-9494b03c16bb" TYPE="ext4" PARTUUID="edc5ee37-01"
/dev/nvme1n1: LABEL="nvme-tank" UUID="12820183881567404585" UUID_SUB="7696346709622828030" TYPE="zfs_member"

相关内容