用户工具

站点工具


start

Hshh's Cosmos

记录一次 ZFS 由于设备名称变更导致故障的修复

发现一台 ubuntu 23.10 的 ZFS 卷降级了

# zpool status stor
  pool: stor
 state: DEGRADED
status: One or more devices could not be used because the label is missing or
        invalid.  Sufficient replicas exist for the pool to continue
        functioning in a degraded state.
action: Replace the device using 'zpool replace'.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-4J
  scan: scrub repaired 0B in 19:13:23 with 0 errors on Sun Jun  9 19:37:31 2024
config:

        NAME                        STATE     READ WRITE CKSUM
        stor                        DEGRADED     0     0     0
          raidz2-0                  DEGRADED     0     0     0
            scsi-35000cca260cd1f18  ONLINE       0     0     0
            scsi-35000cca260cc3084  ONLINE       0     0     0
            scsi-35000cca260cc6be0  ONLINE       0     0     0
            13184766210832087855    FAULTED      0     0     0  was /dev/sdf1
            8984617841033776882     FAULTED      0     0     0  was /dev/sdg1
            wwn-0x5000cca2604ac3e0  ONLINE       0     0     0

errors: No known data errors

# zpool status -L stor
  pool: stor
 state: DEGRADED
status: One or more devices could not be used because the label is missing or
        invalid.  Sufficient replicas exist for the pool to continue
        functioning in a degraded state.
action: Replace the device using 'zpool replace'.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-4J
  scan: scrub repaired 0B in 19:13:23 with 0 errors on Sun Jun  9 19:37:31 2024
config:

        NAME                      STATE     READ WRITE CKSUM
        stor                      DEGRADED     0     0     0
          raidz2-0                DEGRADED     0     0     0
            sdc                   ONLINE       0     0     0
            sdd                   ONLINE       0     0     0
            sde                   ONLINE       0     0     0
            13184766210832087855  FAULTED      0     0     0  was /dev/sdf1
            8984617841033776882   FAULTED      0     0     0  was /dev/sdg1
            sdg                   ONLINE       0     0     0

errors: No known data errors

我的天, raidz2 掉了2个盘!

经检查, 硬盘并没有问题, 只是重启后设备名变了(从上面 sdg 在列里, 但是却说曾经的 sdg1 出错了可以看出), 这样 ZFS 就出问题了??!! 我在 FreeBSD 下重来没碰到过.

试着用 zpool replace, 报错

# zpool replace stor 13184766210832087855 /dev/sdf
invalid vdev specification
use '-f' to override the following errors:
/dev/sdf1 is part of active pool 'stor'

# zpool replace -f stor 13184766210832087855 /dev/sdf
invalid vdev specification
the following errors must be manually repaired:
/dev/sdf1 is part of active pool 'stor'

尝试zpool labelclear, 报错. wipefs 掉再 replace, 还是报错

# zpool labelclear /dev/sdf                       
failed to clear label for /dev/sdf

# wipefs -a /dev/sdf
/dev/sdf: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
/dev/sdf: 8 bytes were erased at offset 0x74702555e00 (gpt): 45 46 49 20 50 41 52 54
/dev/sdf: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa
/dev/sdf: calling ioctl to re-read partition table: Success

# zpool replace stor 13184766210832087855 /dev/sdf
cannot replace 13184766210832087855 with /dev/sdf: /dev/sdf is busy, or device removal is in progress

艹! 已经不能描述我当前的心情了.

最后查了下网上的一些案例, 先 export, 然后用 import -d 的方式. 但是如果只用 -d /dev/disk/by-id/ 是不行的, 直接用多次 -d 来解决.

将有问题的设备离线, 导出池后, 用 -d /dev/disk/by-id/ 加上多个 -d 设备名导入池. 然后将有问题的设备重新上线.

# zpool offline stor 13184766210832087855
# zpool offline stor 8984617841033776882 
# zpool export stor
# zpool import -d /dev/disk/by-id/ -d /dev/sdc -d /dev/sdd -d /dev/sde -d /dev/sdg -d /dev/sdf -d /dev/sdi stor
# zpool online stor 13184766210832087855
# zpool online stor 8984617841033776882 

最后终于池在线了, 并且对2个有问题的设备重建.

# zpool status stor
  pool: stor
 state: ONLINE
status: One or more devices is currently being resilvered.  The pool will
        continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
  scan: resilver in progress since Sun Jul  7 01:17:01 2024
        44.7G / 32.3T scanned at 1.09G/s, 0B / 32.3T issued
        0B resilvered, 0.00% done, no estimated completion time
config:

        NAME                        STATE     READ WRITE CKSUM
        stor                        ONLINE       0     0     0
          raidz2-0                  ONLINE       0     0     0
            scsi-35000cca260cd1f18  ONLINE       0     0     0
            scsi-35000cca260cc3084  ONLINE       0     0     0
            scsi-35000cca260cc6be0  ONLINE       0     0     0
            wwn-0x5000cca260cc504c  ONLINE       0     0     0
            wwn-0x5000cca260cc32d0  ONLINE       0     0     0  (awaiting resilver)
            wwn-0x5000cca2604ac3e0  ONLINE       0     0     0

errors: No known data errors

实际重建速度在后面是很快的, 前面做扫描用了一段很长的时间.

2024/07/07 05:20

又是鸡飞蛋打的时间

一堆 Linux 需要更新 OpenSSH: CVE-2024-6387.

2024/07/02 03:13

rustdesk

现在 TeamViewer 越来越恶心, 国内用还会提示绑手机号. AnyDesk 连接服务器慢, 中继服务器国内连接不快, 直接端口连接对于同一个ip地址不同端口支持不好.

改用 RustDesk, 自己搭了个服务端, 连接速度真够快的.

2024/06/25 15:39

btrfs

由于 btrfs 缺少 ext4 的 e2image 工具, 所以如果要把分区前部空出一段空间, 而且使用空间超过一半, 就要操作很多步才能达到目的.

把当前的文件系统缩小, 修改分区缩小后段, 新建分区, 加到 btrfs 的相同挂载点.

重复上面步骤. 最后就是新建了一堆临时分区, 最后腾出前段的空间, 再反向操作.

2024/06/25 14:32

如果给 windows 设置测试用的 IPv6

根据命令 netsh interface ipv6 show prefixpolicies

Precedence  Label  Prefix
----------  -----  --------------------------------
        50      0  ::1/128
        40      1  ::/0
        35      4  ::ffff:0:0/96
        30      2  2002::/16
         5      5  2001::/32
         3     13  fc00::/7
         1     11  fec0::/10
         1     12  3ffe::/16
         1      3  ::/96

如果只是测试, 不要给 windows 使用大于 label 1 的 IPv6 地址段, 避免以后碰到的坑.

2024/06/22 16:45

碰到 bhyve 的 efi boot var 坏了

bhyve 里的 arch linux 更新重启后, bhyve core dump, 启动不了了.

把 ini 的 lpc.bootvars 注释掉, 正常启动, 看来不知道什么原因把 efi 的 启动变量弄坏了.

重新把 /usr/local/share/edk2-bhyve/BHYVE_UEFI_VARS.fd 复制过来覆盖掉, 启动正常.

重新进到虚拟机后, 用 efibootmgr 添加启动项, 修改启动顺序. 再次重启, 没问题.

非常奇怪, 坏之前明明没有碰过 efi boot var 啊.

2024/06/22 04:00

有点想把 locale 设为 C.UTF-8

一直以来都在用 en_US.UTF-8, 但是用 sort, comm 总是怪怪的.

Linux

用 en_US, 排序会忽略符号

$ printf "a.d\na_c\nab" | sort
ab
a_c
a.d

用 C

$ printf "a.d\na_c\nab" | sort
a.d
a_c
ab

用 awk 排序, 不依赖 locale

$ printf "a.d\na_c\nab" | awk '{if ($0!="") {a[$0]}} END {asorti(a); for (k in a) {print a[k]}}'
a.d
a_c
ab

FreeBSD

用 en_US

$ printf "a.d\na_c\nab" | sort
a_c
a.d
ab

用 C

$ printf "a.d\na_c\nab" | sort      
a.d
a_c
ab

用 gawk 排序和 Linux 一样 (FreeBSD 自身的 awk 不支持 asorti)

2024/06/22 01:51

DNSSEC & EDNS

DNS 总是 DNSSEC 失败, 查了几天, 终于想起来, DNSSEC 需要用 EDNS, 而我对某些 IP 段关闭了 EDNS. 原来傻逼是自己.

2024/06/13 01:22

用 gost 替换 3proxy

自从 FreeBSD 14.1 开始, 3proxy 的 tcppm (TCP端口映射), 如果配置不指定 log 是不会继承主配置, 启动会报错. 虽然可以在参数指定 log, 但是还是觉得不爽. 看了半天源代码, 没找出问题.

我需要用到通过 socks5 做 TCP 端口映射. 可选的方案不多, gost 可以, 反正 go 的程序部署简单.

不过, gost 的 cpu/ram 占用还是要比 3proxy 高.

2024/06/12 17:34

其他变动

start.txt · 最后更改: 2024/06/22 02:21 由 Hshh