Provide an Xserver To Chroot

9,365

Use Xephyr

sudo apt-get install xserver-xephyr

Start Xephyr

Xephyr -ac -screen 1280x1024 -br -reset -terminate 2> /dev/null :1 &

The ":1" = your display (displays are numbered starting with 0)

-ac = disable access control restrictions= allow you to forward X

-screen 1280x1024 = screen size

-br = black background

-reset -terminate= Xephyr should automatically close when the last X client is killed, does not always work.

2> /dev/null redirects error messages.

Set your display (for X)

DISPLAY=:1.0

ssh into your chroot (you may need to install ssh server, you may also wish to look at LXC )

ssh -XfC -c blowfish user@server xterm

or use any other graphical tool you wish.

See also

http://ubuntuforums.org/showthread.php?t=620003

https://help.ubuntu.com/lts/serverguide/lxc.html

Share:
9,365

Related videos on Youtube

please delete me
Author by

please delete me

please delete me

Updated on September 18, 2022

Comments

  • please delete me
    please delete me over 1 year

    Description:

    I'm using a Lubuntu 13.10 X86-64 livecd to chroot into another Lubuntu 13.10 X86-64 located on my hard drive in a folder called chroot. I've had no trouble using the terminal to chroot in, and I can launch gui applications on my current xserver from the chroot after using "xhost +" on the livecd, but I need provide the chroot it's own X output. I've googled, searched askubuntu, and typed every command under the sun and moon all to no avail. I would love a solution, but would even be happy for a guess if you've got one. I've backed up the chroot so I can restore if it gets messed up. I've also tried using Xnest but it doesn't want to work either. I would like to run the lxde desktop environment in the chroot, if possible logging in as a specific user.

    Details:

    Below are the commands I used to commence the chroot.

    sudo mount --bind /dev /media/lubuntu/os/chroot/dev
    
    sudo mount --bind /proc /media/lubuntu/os/chroot/proc
    
    sudo mount --bind /sys /media/lubuntu/os/chroot/sys
    
    sudo cp /etc/resolv.conf /media/lubuntu/os/chroot/etc/resolv.conf
    
    xhost +
    
    sudo chroot /media/lubuntu/os/chroot
    

    I would also have typed "export DISPLAY=:0.0" in the chroot, but it worked without it.

    Test Results:

    Test #1:

    Description:

    I get a black screen on all outputs (control+alt+Fkeys), and I cannot type anything. I'm forced to kill the computer by hand.

    Details:

    In chroot terminal type

    export DISPLAY=localhost:1
    

    In chroot terminal type

    startx -- :1
    

    Test #2:

    Description:

    I get a black screen for F1, pressing "control + alt + F7" gets me back to my normal desktop. I cannot type anything on the black screen. When I enter "gksu leafpad" in the chroot terminal on F7 I get an error that it "cannot open display localhost:1". When I switch to F1 it now shows a terminal prompt for the livecd not the chroot.

    Details:

    In chroot terminal type

    export DISPLAY=localhost:1
    

    In livecd terminal type

    sudo startx -- :1
    

    Test #3: [Edited In]

    Description:

    I get a blank black window, just as I would for Xnest. When I try to launch xterm I get an error stating "could not resolve hostname lubuntu: Name or service not known". I've also tried installing "openssh-server" in the chroot, and on the livecd. When I use the same commands on the livecd only and attempt to launch xterm from the livecd I do not get the same error. Instead I get a password prompt. The livecd user "lubuntu" has no password. If I leave the password blank I get error "permission denied. If I create a user account a retry it I get error "permission denied, please try again" when entering the correct user password. The "could not resolve hostname lubuntu" error experienced with the chroot also occurs when using apt-get in the chroot, though I can and have installed things from apt.

    Details:

    In livecd terminal type

    Xephyr -ac -screen 1024x768 -br -reset -terminate 2> /dev/null :1 &
    

    In chroot terminal type

    DISPLAY=:1.0
    

    I also tried "DISPLAY=:1.0" in the livecd terminal.

    In chroot terminal type

    ssh -XfC -c blowfish root@lubuntu xterm
    

    I also tried "user@server" and "root@localhost" in the chroot terminal.

    Additional Information

    Anything else you want to know? I'll try to add it here.

  • please delete me
    please delete me about 10 years
    Ran into some errors. Added results to my posting as "Test 3". I get error unable to resolve the host. I've also tried without the chroot and am unable to get to work that way either because it doesn't like my password.
  • Panther
    Panther about 10 years
    You have to give your chroot an ip address and then use the ip address in your command. [email protected] or whatever. If you do not know how to do that, I again suggest you use lxc ;)
  • Panther
    Panther about 10 years
    @user250271 Did you ever get this working ?
  • Panther
    Panther about 10 years
    OK, well, as you work through chroot, if you get stuck, ask for help ;)
  • David West
    David West about 6 years
    two thumbs up. So useful