4

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.

1

2 Answers 2

2

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

6
  • 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. Mar 17, 2014 at 21:06
  • 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
    Mar 17, 2014 at 21:08
  • @user250271 Did you ever get this working ?
    – Panther
    Mar 18, 2014 at 15:30
  • Nope, but I think I need to learn a bit more first so I'm backburnering this for a bit. Thanks for the detailed answer. Mar 19, 2014 at 23:40
  • OK, well, as you work through chroot, if you get stuck, ask for help ;)
    – Panther
    Mar 20, 2014 at 0:49
0

Mounting /tmp/.X11-unix inside the chroot filesystem should work:

mkdir /media/lubuntu/os/chroot/.X11-unix
mount --rbind /tmp/.X11-unix /media/lubuntu/os/chroot/.X11-unix
chroot /media/lubuntu/os/chroot
xterm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .