为什么在取消压缩 squashfs 文件系统后,我从任何命令都会收到“警告:无法打开目录”?

为什么在取消压缩 squashfs 文件系统后,我从任何命令都会收到“警告:无法打开目录”?

我一直在尝试创建自定义 ISO 映像,并且取得了成功。然而,在此过程中我遇到了一种我无法理解的情况。

我的系统是 Ubuntu 20.04.6 LTS 桌面。

基本上,当我运行sudo unsquashfs ubuntu-server-minimal.squashfs到一个目录,然后列出父目录的内容时,结果squashfs-根目录目录下,我收到以下信息以及一些警告:

$ ls -l
total 2231416
dr-xr-xr-x  9 mike mike       4096 Aug  9 22:06 extracted-iso
drwxr-xr-x 18 root root       4096 Aug  9 17:20 squashfs-root
-rw-rw-r--  1 mike mike 2133391360 Sep 18 18:13 ubuntu-22.04.3-live-server-amd64.iso
-r--r--r--  1 mike mike  151560192 Sep 18 18:15 ubuntu-server-minimal.squashfs
warning: could not open directory 'iso/squashfs-root/var/lib/polkit-1/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/lib/private/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/lib/apt/lists/partial/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/lib/snapd/void/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/log/private/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/cache/private/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/cache/pollinate/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/cache/ldconfig/': Permission denied
warning: could not open directory 'iso/squashfs-root/root/': Permission denied
warning: could not open directory 'iso/squashfs-root/run/lock/lvm/': Permission denied
warning: could not open directory 'iso/squashfs-root/run/lvm/': Permission denied
warning: could not open directory 'iso/squashfs-root/etc/polkit-1/localauthority/': Permission denied
warning: could not open directory 'iso/squashfs-root/etc/ssl/private/': Permission denied

这就是我感到困惑的地方。我知道squashfs-根目录归 root 所有,但每个人都有读取权限。其次,在创建chroot进入所需的各种挂载后,警告数量会增加squashfs-根目录例如以下内容:

mount --bind /etc/resolv.conf squashfs-root/etc/resolv.conf
mount -t proc none squashfs-root/proc
mount -t sysfs none squashfs-root/sys
mount -t devpts none squashfs-root/dev/pts

此外,这些警告现在会出现在任何命令中,例如lsb_release -apwd

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:    20.04
Codename:   focal
warning: could not open directory 'iso/squashfs-root/var/lib/polkit-1/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/lib/private/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/lib/apt/lists/partial/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/lib/snapd/void/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/log/private/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/cache/private/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/cache/pollinate/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/cache/ldconfig/': Permission denied
warning: could not open directory 'iso/squashfs-root/root/': Permission denied
warning: could not open directory 'iso/squashfs-root/run/lock/lvm/': Permission denied
warning: could not open directory 'iso/squashfs-root/run/lvm/': Permission denied
warning: could not open directory 'iso/squashfs-root/etc/polkit-1/localauthority/': Permission denied
warning: could not open directory 'iso/squashfs-root/etc/ssl/private/': Permission denied

$ pwd
/home/mike/custom-iso/iso
warning: could not open directory 'iso/squashfs-root/var/lib/polkit-1/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/lib/private/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/lib/apt/lists/partial/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/lib/snapd/void/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/log/private/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/cache/private/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/cache/pollinate/': Permission denied
warning: could not open directory 'iso/squashfs-root/var/cache/ldconfig/': Permission denied
warning: could not open directory 'iso/squashfs-root/root/': Permission denied
warning: could not open directory 'iso/squashfs-root/run/lock/lvm/': Permission denied
warning: could not open directory 'iso/squashfs-root/run/lvm/': Permission denied
warning: could not open directory 'iso/squashfs-root/etc/polkit-1/localauthority/': Permission denied
warning: could not open directory 'iso/squashfs-root/etc/ssl/private/': Permission denied
  • 如果我sudo su,所有警告都会消失。
  • 删除后squashfs-根目录使用 后sudo rm -fr squashfs-root,所有警告都会消失。

那么这是怎么回事?为什么我会收到这些警告?如何才能抑制这些警告?我是不是做错了什么unsquashfs

更新:

作为测试,我在 VirtualBox 中创建了两个虚拟机,一个装有 Ubuntu 20.04.6 LTS 桌面,另一个装有 22.04.3 LTS 桌面。我下载了相同的 ISO,提取并像之前一样将 squashfs 解压到两个系统中。我在两个虚拟机中都没有收到任何警告。

因此,看来我当前的系统出了问题,我需要帮助进行故障排除。有什么想法可以开始吗?

答案1

我解决了这个问题。

我意识到的父目录iso/squashfs-root中有一个 Git 存储库,但iso/squashfs-root尚未添加到.gitignore文件。结果,警告实际上来自 Git,而不是操作系统。所以我只是将此目录添加到.gitignore警告就消失了。

相关内容