9

when I runchroot /somepath /usr/bin/startxI got something what looks like an evdev problem... (I correctly --bind mounted /dev/ /dev/pts /dev/shm /proc /sys /tmp )

The screen is displayed and programs run normally, except I got no mouse nor keyboard and I can't switch to a local terminal, forcing me to hard reboot.

What is the cause of this?
Are there any solution to go ahead by making the server run?

Possible steps to reproduce (work on all distributions):

  • copy the root directory of a Linux distribution to a folder of you running distribution.

  • correctly bind mount everything (/dev/pts /var/run /dev/shm /sys/kernel/debugfs...)

  • run a shell with thechrootcommand.

  • Make sure not any X11 server is already running then launchxinit /usr/bin/some X11 program

You can now hard-reboot your computer! (if you didn't set up any remote access)

user2284570
  • 1,799
  • 7
  • 35
  • 62
  • @IgnacioVazquez-Abrams : BIND MOUNT! – user2284570 Dec 15 '13 at 18:27
  • @MariusMatutiae : Thanks, I've just tried to copy (cp -r --sparse=always /path_to_root/* /mnt) the rootfs to the root of an empty partition (on an USB flash disk) and I booted it directly.... And it work perfectly! (So it is not because some packages/files are missing :-( ). I need to use chroot for mixing the functionalities of two different distro. – user2284570 Dec 16 '13 at 19:24
  • 1
    At least in my case, the machine isn't completely dead. It just doesn't respond to keyboard/mouse. When I log in remotely, I can kill the offending X server and that's enough to resume normal operation. – Petr Jul 06 '14 at 16:33
  • @PetrPudlák : Yes, That's was I said "*The screen is displayed and programs run normally...*". I don't have another machine which I can use for ssh. So my only option is to hard-reboot. – user2284570 Jul 06 '14 at 19:19
  • Nowadays another machine could be an Android smartphone + ConnectBot. Inconvenient, but works. – Olaf Dietsche May 15 '20 at 07:34
  • @OlafDietsche and slow because of networking… Though now that programs are becoming Wayland only, this question is keeping its spirit. – user2284570 May 15 '20 at 19:16

2 Answers2

7

I realize this question is old, but for reference:

The screen is displayed and programs run normally, except I got no mouse nor keyboard and I can't switch to a local terminal, forcing me to hard reboot.

I correctly --bind mounted /dev/ /dev/pts /dev/shm /proc /sys /tmp

In addition to mounting the above, I also had to bind mount /run/udev to make the mouse and keyboard work in my chroot. I did not use an xorg.conf*, and Xorg was able to correctly detect my settings.

Entry in my /etc/schroot/default/fstab:

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

If you are doing a standard chroot you could obviously put it in your /etc/fstab instead:

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

...or mount --bind it.


*Well-- I tried using an xorg.conf initially, but it didn't work. I also tried adding

Section "ServerFlags" Option "AutoAddDevices" "false" EndSection in xorg.conf, which made my mouse work, but not the keyboard.

transistor1
  • 356
  • 3
  • 6
  • 1
    fstab is not a help. It is the same as specifying commands manually. I don't accept answer which say they didn't solve the error. Also, there are no Xorg.conf on gentoo. *(If you want to use hand written files, you have to it differently)*. Last question : how to start a session if you have no virtual keyboard? – user2284570 Aug 02 '14 at 23:56
  • 1
    I did solve the error. Are you sure you read this answer completely? The soluton was not fstab. The solution for me was **to bind mount /run/udev**... I also stated I did **not** use an xorg.conf. Furthermore -- I did state you could also `mount --bind` it if you wanted to. – transistor1 Aug 03 '14 at 01:05
4

There is an article on Gentoo wiki that details the required procedure :
HOWTO_startx_in_a_chroot.
The article details how to first sett up the chroot, then how to enter the chroot and configure mainsystem.

Another such article comes from Arch Linux :
Running graphical applications from chroot.

More for Ubuntu :
Accessing graphical applications inside the chroot
Creating a chroot jail with sound and X11

For KDE : Kde4schroot. Since that's the one that's demanded, here are some details:

Replace /etc/schroot/schroot.conf with :

# 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

Then replace /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

Switch to kde4 user:

su - kde4

Then schroot and type root passwd:

schroot -u root

Add lenny and experimental repositories to /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

Set up pinning by editing /etc/apt/preferences and adding:

 Package: *
 Pin: release a=experimental
 Pin-Priority: 800
 Package: *
 Pin: release a=unstable
 Pin-Priority: 400
 Package: *
 Pin: release a=lenny
 Pin-Priority: 200

Then run update and install kde4:

aptitude update && aptitude install -t experimental kde4 xorg

Install kdm:

aptitude install -t experimental kdm

Then edit /etc/kde4/kdm/kdmrc and change StaticServers and ReserveServers:

StaticServers=:1
ReserveServers=:2,:3

Or use gdm (gdm will ask to use another display if DISPLAY :0 is already in use.

aptitude install gdm

To run a full kde4 session, go to a text virtual terminal(vt) outside the current X session, for example vt2 (ctrl-alt-F2). To login to a full kde4 session run the following:

su - kde4
schroot
su (use root passwd here)
invoke-rc.d kdm start

And now you should see kdm and should be able to login as kde4 to kde4!
For more details see the above article.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • Shouldn't this have been a comment instead of an answer? In the best case it's a link only answer. – Cristian Ciupitu Jun 28 '14 at 13:13
  • @CristianCiupitu: As I said above, I'm waiting for his feedback in order to flesh it out with the answer for his (unspecified) Linux distribution. – harrymc Jun 28 '14 at 13:42
  • 2
    The problem is all the links are about plain `chroot`, while the problem is happening using `schroot`. Moreover, the second two links talk about how to run a `chroot`ed graphical application on a running X server, while the question is about how to run a standalone X-server inside `schroot`. I tried to get something out of the first link, but so far I've had no success. (My distribution is Debian Wheezy.) – Petr Jun 29 '14 at 09:43
  • Some more promising sources : [Kde4schroot](https://wiki.debian.org/Kde4schroot) and [chroot jail with sound and X11](https://kb8ojh.net/elb/musings/tag/xpra). Also, have you given thoughts to accounts and permissions? – harrymc Jun 29 '14 at 10:02
  • eh, if the original question is in 2013, chances are there's not going to be feedback from the OP. I'd consider having the main points here *essential*. I'd like to roll back the tag edits however - the instructions are likely to be broadly the same, with distro specific changes and the OP's intentions arn't clear.I'd add that as is, this *is* a link only answer, and we all tend to hate that. – Journeyman Geek Jun 29 '14 at 14:44
  • @JourneymanGeek: Now that I know that the distribution is Debian, the nearest article is that of [Kde4schroot](https://wiki.debian.org/Kde4schroot). However, that article contains 7 screens of bare Linux commands and configuration scripts, with little text and no real possibility of summarizing that. Copying the whole thing is plagiarism, so I do have a problem. I can delete this answer, but I think that it can still be useful to readers. – harrymc Jun 29 '14 at 15:25
  • @harrymc: Link only answers are low quality - if your link went down, its useless to the next guy. As the #1 user repwise, you can do better. I'm sure with sufficient understanding paraphrasing is possible. Otherwise, yeah, I'd probably treat it like any other low quality answer. – Journeyman Geek Jun 29 '14 at 23:33
  • @JourneymanGeek: (1) This is not link-only but links-only ;) and not all of them can disappear, (2) The bounty is by a Debian user but the OP's distribution is unknown, (3) I really truly admit that I don't see how to summarize such an article without copying it. – harrymc Jun 30 '14 at 08:41
  • They could. If paraphrasing an answer is too much work, yes, not answering is clearly an option, especially when we're talking about a bounty. A similar post by a first time user would more likely than not get a comment or a deletion. I'm taking the chance to say this is likely to happen. No matter what, answers NEED to be useful on their own merits. – Journeyman Geek Jun 30 '14 at 08:48
  • @JourneymanGeek: Did that, since everyone insists, trying for minimalism. But such wholesale copying leaves a bad taste. And I don't even have any feedback to say if it works for Petr Pudlák. – harrymc Jun 30 '14 at 10:39
  • @harrymc : Petr Pudlák is right.I already perfectly know how to run an X.org application on a different chroot and even on a different computer from which the program is running *(useful if you have a computer with a fast CPU without graphic card)*. You also do things too difficult... I don't want security, so running `export DISPLAY=:0.0`is enough and always worked. I asked the question, because I often rescue systems with a minimal livecd *(no Xorg, no live image, just a big initrd)*.The main advantage of this livecd is that is start very quickly, which save a lot of time with many machines. – user2284570 Jun 30 '14 at 13:04
  • @user2284570: If my answer doesn't help, could you please flesh-out your question with Linux version, what you have tried, error message etc. It's hard to answer having so little data. I also don't understand why chroot or schroot is needed with a live CD. I start having the feeling that you and Petr Pudlák may not have the same problem. – harrymc Jun 30 '14 at 13:49
  • @harrymc : I'm sure it as nothing to do with my version. I've seen the same Fedora; Debian and Slackware both as source and target. I think it's something like the unset $DISPLAY which sometimes X11 prevent programs to launch *(this variable is exported n real Xorg ssesion)*. I'm sure there something similar in my case which is done automatically inside complete chroot *(the one targeted by initrd on all major distributions)*, but I can't see what. It's probably something like dbus or other daemons which use pipe instead of Unix domains. So there's no point to narrow the scope of my question. – user2284570 Jun 30 '14 at 22:22
  • @user2284570: That's not narrowing. I simply have nothing to go on beyond what I have already done. The above links all pertain to working cases, and you provide no information on what you did that's different from any of them. So how do you expect any meaningful answer? – harrymc Jul 01 '14 at 06:00
  • @harrymc : just install an alternative root on your hard disk... run a shell inside it with the `chroot`command... Make sure no Xorg server is already launched... then run `xinit /usr/bin/xterm` and you'll see the result. That's all. – user2284570 Jul 01 '14 at 09:18
  • Unfortunately, the article is outdated, schroot now uses different configuration options. I'd be fine with that, the problem is that it's not clear what's causing the error described in the question. When I tried to adapt it the current version, I still got the error. – Petr Jul 06 '14 at 16:32
  • My only gripe with the distribution-specific files is that they are often so specific to the distribution at hand. It is rare that you see a lot more details such as in LFS. – shevy Jul 22 '17 at 18:26
  • A few years later, the gentoo-wiki URL isn't valid any more; here is an archived version, which I will try to follow now: https://web.archive.org/web/20140825153602/http://www.gentoo-wiki.info/HOWTO_startx_in_a_chroot – Pierre Aug 10 '23 at 10:51