You are not logged in.

#1 2019-03-16 21:06:52

thomasqueirozb
Member
Registered: 2019-03-16
Posts: 6

Problems running GUI in chroot environment

I am trying to mount an external drive and run a graphical application under chroot.

I started off doing the basic

$ xhost +
# mount /dev/sdXY /mnt
# arch-chroot /mnt

However I needed to be logged in as my user to run some specific programs so I created a monster .sh file

#!/bin/bash
export HOME=/home/user
export USER=user
source /home/user/.bashrc
export DISPLAY=:0.0

Every time I chrooted I had to "source /home/user/file.sh", which got the job done but was really nasty as you can see.

I found out that "arch-chroot /mnt su -l user" kinda resolved my problem. I was running everything as my user but I still had to set DISPLAY=:0.0 . This also exited the environment automatically when I tried to run firefox and other graphical programs.

I also got this problem when trying to run something as sudo:

 sudo: no tty present and no askpass program specified 

Note that the external drive is a ubuntu system (I really hate using it but there is no other way unfortunately sad )

I would like to:
- chroot as my user and fix the sudo error (if possible otherwise I'll just run everything as root and use my horrible .sh file)
- automatically change the DISPLAY environment variable


Running arch-chroot with the -c tag didn't really help me in doing this since it just exited.
I read the wiki for chroot but couldn't find anything that would help me (couldn't get fakechroot to work)

Last edited by thomasqueirozb (2019-03-16 21:10:30)

Offline

#2 2019-03-16 22:05:41

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: Problems running GUI in chroot environment

How about systemd-nspawn?

If you create a user in the container with the same name, GID and UID (& ~.bashrc) as the host user then you can run something like

# systemd-nspawn --directory=/path/to/container --setenv=DISPLAY=:0.0 --user=$user $application

Replace $user with the actual user name and replace $application with the desired application, obviously.

thomasqueirozb wrote:

I also got this problem when trying to run something as sudo:

sudo: no tty present and no askpass program specified 

You need to (bind) mount /dev/pts as well.


Jin, Jîyan, Azadî

Offline

Board footer

Powered by FluxBB