如何在普通 chroot 中启动 Xorg-server?

use*_*570 9 x-server chroot

当我运行时,chroot /somepath /usr/bin/startx我得到了一些看起来像 evdev 问题的东西...... (我正确地 --bind 安装了 /dev/ /dev/pts /dev/shm /proc /sys /tmp )

屏幕显示和程序正常运行,除了我没有鼠标和键盘,我无法切换到本地终端,迫使我硬重启。

这是什么原因?
是否有任何解决方案可以让服务器运行?

重现的可能步骤(适用于所有发行版)

  • 将 Linux 发行版的根目录复制到您运行发行版的文件夹中。

  • 正确绑定挂载所有内容(/dev/pts /var/run /dev/shm /sys/kernel/debugfs...)

  • 使用chroot命令运行 shell 。

  • 确保没有任何 X11 服务器已经在运行,然后启动xinit /usr/bin/some X11 program

您现在可以硬重启您的计算机!(如果您没有设置任何远程访问)

tra*_*or1 7

我意识到这个问题很旧,但仅供参考:

屏幕显示和程序正常运行,除了我没有鼠标和键盘,我无法切换到本地终端,迫使我硬重启。

我正确 --bind 挂载 /dev/ /dev/pts /dev/shm /proc /sys /tmp

除了挂载上面的,我还必须绑定 mount /run/udev才能让鼠标和键盘在我的 chroot 中工作。我并没有使用xorg.conf*,和Xorg能够正确地检测我的设置。

进入我的/etc/schroot/default/fstab

/run/udev /run/udev none rw,bind 0 0

如果你正在做一个标准的 chroot 你显然可以把它放在你的/etc/fstab

/run/udev /path/to/chroot/run/udev none rw,bind 0 0

...或者mount --bind它。


*嗯——我xorg.conf最初尝试使用,但没有用。我也尝试添加

Section "ServerFlags" Option "AutoAddDevices" "false" EndSection 在 xorg.conf 中,它使我的鼠标可以工作,但不能使键盘工作。


har*_*ymc 5

Gentoo wiki 上有一篇文章详细介绍了所需的过程:
HOWTO_startx_in_a_chroot
本文详细介绍了如何首先设置 chroot,然后如何进入 chroot 并配置主系统。

另一篇此类文章来自 Arch Linux:
从 chroot 运行图形应用程序

Ubuntu 的更多内容:
访问 chroot 内的图形应用程序
创建带有声音和 X11 的 chroot 监狱

对于 KDE:Kde4schroot。由于这是所要求的,因此以下是一些细节:

用。。。来代替/etc/schroot/schroot.conf

# schroot chroot definitions.
# See schroot.conf(5) for complete documentation of the file format.
#
# Please take note that you should not add untrusted users to
# root-groups, because they will essentially have full root access
# to your system.  They will only have root access inside the chroot,
# but that's enough to cause malicious damage.
#
[experimental]
type=directory
description=Debian experimental (unstable)
priority=4
groups=sbuild,root
users=kde4
#root-groups=root,sbuild
aliases=unstable,default
#device=/dev/hda_vg/experimental_chroot
mount-options=-o atime,sync,user_xattr
location=/home/chroot
run-setup-scripts=true
run-exec-scripts=true
Run Code Online (Sandbox Code Playgroud)

然后替换/etc/schroot/mount-defaults

# mount.defaults: static file system information for chroots.
# Note that the mount point will be prefixed by the chroot path
# (CHROOT_PATH)
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev            /dev            none    rw,bind         0       0
/dev/pts        /dev/pts        none    rw,bind         0       0
tmpfs           /dev/shm        tmpfs   defaults        0       0
/home           /home           none    rw,bind         0       0
/tmp            /tmp            none    rw,bind         0       0
Run Code Online (Sandbox Code Playgroud)

切换到kde4用户:

su - kde4
Run Code Online (Sandbox Code Playgroud)

然后 schroot 并输入 root passwd:

schroot -u root
Run Code Online (Sandbox Code Playgroud)

将 lenny 和实验存储库添加到 /etc/apt/sources.list:

echo "deb http://ftp.us.debian.org/debian experimental main non-free contrib" >> /etc/apt/sources.list
echo "deb http://ftp.us.debian.org/debian lenny main" >> /etc/apt/sources.list
Run Code Online (Sandbox Code Playgroud)

通过编辑和添加设置固定/etc/apt/preferences

 Package: *
 Pin: release a=experimental
 Pin-Priority: 800
 Package: *
 Pin: release a=unstable
 Pin-Priority: 400
 Package: *
 Pin: release a=lenny
 Pin-Priority: 200
Run Code Online (Sandbox Code Playgroud)

然后运行更新并安装 kde4:

aptitude update && aptitude install -t experimental kde4 xorg
Run Code Online (Sandbox Code Playgroud)

安装kdm:

aptitude install -t experimental kdm
Run Code Online (Sandbox Code Playgroud)

然后编辑 /etc/kde4/kdm/kdmrc 并更改 StaticServers 和 ReserveServers:

StaticServers=:1
ReserveServers=:2,:3
Run Code Online (Sandbox Code Playgroud)

或者使用 gdm(如果 DISPLAY :0 已在使用,则 gdm 会要求使用另一个显示器。

aptitude install gdm
Run Code Online (Sandbox Code Playgroud)

要运行完整的 kde4 会话,请转到当前 X 会话之外的文本虚拟终端 (vt),例如 vt2 (ctrl-alt-F2)。要登录完整的 kde4 会话,请运行以下命令:

su - kde4
schroot
su (use root passwd here)
invoke-rc.d kdm start
Run Code Online (Sandbox Code Playgroud)

现在您应该看到 kdm 并且应该能够以 kde4 身份登录到 kde4!
更多详情请参阅上面的文章。

  • 问题是所有链接都是关于普通的“chroot”,而问题是使用“schroot”发生的。此外,后两个链接讨论如何在正在运行的 X 服务器上运行“chroot”图形应用程序,而问题是如何在“schroot”内运行独立的 X 服务器。我试图从第一个链接中获取一些内容,但到目前为止我还没有成功。 (我的发行版是 Debian Wheezy。) (2认同)