snap
将其所有软件包(包括核心依赖项,例如bare
和core
以及每个软件包)存储为单个 SquashFS.snap
文件,然后挂载这些文件(通常在/snap/
目录中)以访问内容。它的实际运行方式如下( 的输出mount | grep snap
):
/var/lib/snapd/snaps/snapd_17029.snap on /snap/snapd/17029 type squashfs (ro,nodev,relatime,x-gdu.hide)
/var/lib/snapd/snaps/bare_5.snap on /snap/bare/5 type squashfs (ro,nodev,relatime,x-gdu.hide)
/var/lib/snapd/snaps/prusa-slicer_60.snap on /snap/prusa-slicer/60 type squashfs (ro,nodev,relatime,x-gdu.hide)
/var/lib/snapd/snaps/gtk-common-themes_1535.snap on /snap/gtk-common-themes/1535 type squashfs (ro,nodev,relatime,x-gdu.hide)
snap
也没有用于重新安装软件包的命令,例如apt reinstall
。为了重新安装,需要删除软件包并再次安装。
snap
鉴于这两个特性,只需破坏包含一些核心依赖项的 SquashFS 文件,就可能破坏通过安装的所有软件。
这正是我昨天遇到的情况 - 我无法运行使用 安装的任何软件snap
。每次尝试都以完全相同的堆栈跟踪结束:
unexpected fault address 0x6208c0
fatal error: fault
[signal SIGBUS: bus error code=0x2 addr=0x6208c0 pc=0x6208c0]
goroutine 1 [running, locked to thread]:
runtime.throw(0x85ef48, 0x5)
/usr/lib/go-1.13/src/runtime/panic.go:774 +0x72 fp=0xc0000dde38 sp=0xc0000dde08 pc=0x42e582
runtime.sigpanic()
/usr/lib/go-1.13/src/runtime/signal_unix.go:391 +0x455 fp=0xc0000dde68 sp=0xc0000dde38 pc=0x4426c5
compress/bzip2.init.0()
/usr/lib/go-1.13/src/compress/bzip2/bzip2.go:479 fp=0xc0000dde70 sp=0xc0000dde68 pc=0x6208c0
runtime.doInit(0xd0c400)
/usr/lib/go-1.13/src/runtime/proc.go:5222 +0x8a fp=0xc0000ddea0 sp=0xc0000dde70 pc=0x43bf1a
runtime.doInit(0xd11da0)
/usr/lib/go-1.13/src/runtime/proc.go:5217 +0x57 fp=0xc0000dded0 sp=0xc0000ddea0 pc=0x43bee7
runtime.doInit(0xd12160)
/usr/lib/go-1.13/src/runtime/proc.go:5217 +0x57 fp=0xc0000ddf00 sp=0xc0000dded0 pc=0x43bee7
runtime.doInit(0xd117e0)
/usr/lib/go-1.13/src/runtime/proc.go:5217 +0x57 fp=0xc0000ddf30 sp=0xc0000ddf00 pc=0x43bee7
runtime.doInit(0xd0fdc0)
/usr/lib/go-1.13/src/runtime/proc.go:5217 +0x57 fp=0xc0000ddf60 sp=0xc0000ddf30 pc=0x43bee7
runtime.main()
/usr/lib/go-1.13/src/runtime/proc.go:190 +0x1da fp=0xc0000ddfe0 sp=0xc0000ddf60 pc=0x42feda
runtime.goexit()
/usr/lib/go-1.13/src/runtime/asm_amd64.s:1357 +0x1 fp=0xc0000ddfe8 sp=0xc0000ddfe0 pc=0x45a541
snap-update-ns failed with code 2
内核日志包含更多提示:
[19136.436337] SQUASHFS error: xz decompression failed, data probably corrupt
[19136.436339] SQUASHFS error: squashfs_read_data failed to read block 0xfbf09
[19136.436361] SQUASHFS error: xz decompression failed, data probably corrupt
[19136.436362] SQUASHFS error: squashfs_read_data failed to read block 0xfbf09
我或多或少可以清楚,其中一个核心按扣一定以某种方式损坏了。
问题是,如何以优雅的方式解决此类问题?没有简单的方法来查找哪个文件已损坏,即使我找到了 - snap 也没有提供重新安装软件包的选项,只能删除并再次安装它。
因此,我看到的唯一解决方案是删除所有软件包并重新安装它们 - 而这就是我最终所做的。难道没有其他侵入性较小的选择吗?
为了复制此问题,只需将随机数据放入核心快照之一中 - 使其不可读(首先备份文件):
head -c 50M </dev/urandom > /var/lib/snapd/snaps/core20_1623.snap