为什么在启动过程中,chroot 中的挂载 proc 会失败?

为什么在启动过程中,chroot 中的挂载 proc 会失败?

在全新安装的 Ubuntu Raring 机器上,我尝试执行debootstrap另一个系统的操作。以下是确切的命令:

http_proxy=http://192.168.122.1:8000/ debootstrap --arch=amd64 raring /mnt/virtfs-test/

它运行良好,但几乎最后却失败了:

[...]
I: Extracting zlib1g...
W: Failure trying to run: chroot /mnt/virtfs-test mount -t proc proc /proc
W: See /mnt/virtfs-test/debootstrap/debootstrap.log for details

日志文件仅显示以下内容:

gpgv: Signature made Thu Apr 25 13:54:39 2013 CEST using DSA key ID 437D05B5
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key <[email protected]>"
gpgv: Signature made Thu Apr 25 13:54:39 2013 CEST using RSA key ID C0B21F32
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2012) <[email protected]>"
chroot: failed to run command 'mount': Permission denied

这让我很好奇为什么会失败。我注意到我甚至无法 chroot 到那里:

chroot /mnt/virtfs-test 
chroot: failed to run command ‘/bin/bash’: Permission denied

这让我此 ServerFault 问答我发现了一个有趣的现象:

# ls -al /mnt/virtfs-test/lib64/
total 8
drwxr-xr-x  2 root root 4096 Aug 21 20:02 .
drwxr-xr-x 20 root root 4096 Feb  7  2013 ..
----------  1 root  123    0 Aug 21 20:02 ld-linux-x86-64.so.2

什么?文件不是链接,它是空的,没有设置任何权限?这毫无道理。所以我按照 SF 问答中的方式链接了文件:

ln -s /lib/x86_64-linux-gnu/ld-2.17.so /mnt/virtfs-test/lib64/ld-linux-x86-64.so.2

现在我可以 chroot 了:

# chroot /mnt/virtfs-test 
groups: cannot find name for group ID 0
I have no name!@mymachine:/#

但是,我仍然很好奇为什么 debootstrap 会失败。我使用的是 debootstrap 版本,1.0.46ubuntu1它是 Ubuntu Raring 中完全更新的版本。我找不到与此相关的任何错误报告。

有人知道吗?

笔记:

  • 我以完全 root 身份执行了所有命令 ( sudo -i)。
  • 我尝试启动到的文件系统类型为9p(VirtFS,位于 Ubuntu KVM 虚拟机内)。在 apparmor 配置文件中启用此功能后,我没有在主机上看到任何消息(/etc/apparmor.d/abstractions/libvirt-qemu在主机上):

    /mnt/vms/virtfs-test/ rwl,
    /mnt/vms/virtfs-test/** rwl,
    

相关内容