WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [Solved] chroot other Linux distros under Tinycore  (Read 3395 times)

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
[Solved] chroot other Linux distros under Tinycore
« on: April 12, 2021, 02:39:22 PM »
... i'm mostly using tinycore, and i use alpine inside a chroot when i'm lazy to compile missing stuff myself, debian packages are often too outdated for my usage. ...

Hi, hiro. Alpine inside TCL as a chroot sounded interesting, so I decided to try it. These directions work like a charm for CLI applications:
https://wiki.alpinelinux.org/wiki/Alpine_Linux_in_a_chroot

For GUI applications it seems much more tricky (X, fontconfig, and dbus seem to create complications). Have you been able to run GUI applications from inside the chroot? If so, can you please share how you made it work?

P.S. Rich, I just realized that my question is unrelated to the thread subject. Please feel free to move my post to a new thread if you think it would be better.
« Last Edit: April 13, 2021, 02:08:38 PM by Rich »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: chroot other Linux distros under Tinycore
« Reply #1 on: April 13, 2021, 12:27:04 AM »
Hi GNUser
I split your post off into its own topic. I also added the quote from hiro to provide context to your post.
« Last Edit: April 13, 2021, 07:48:29 AM by Rich »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: chroot other Linux distros under Tinycore
« Reply #2 on: April 13, 2021, 03:03:13 AM »
I've run X apps in a chroot by bind-mounting /tmp into it. As long as the UID inside matches the one outside, the apps can access the unix socket there.

Without that, you would have to run them over the network (loopback, but still). Enable TCP listening on your X server, and tell the chroot apps to go over the network with a proper DISPLAY variable. This is insecure unless you firewall off external TCP connections, and slower.
The only barriers that can stop you are the ones you create yourself.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: chroot other Linux distros under Tinycore
« Reply #3 on: April 13, 2021, 08:44:56 AM »
Thanks for the tip, curaga. I've made progress, but am running into font issues. Here are commands run in TCL host:

Code: [Select]
TCL$ chroot_dir=/opt/alpine
TCL$ sudo mount -o bind /dev ${chroot_dir}/dev
TCL$ sudo mount -t proc none ${chroot_dir}/proc
TCL$ sudo mount -o bind /sys ${chroot_dir}/sys
TCL$ sudo mount -o bind /tmp ${chroot_dir}/tmp
TCL$ xhost +local:
TCL$ sudo chroot ${chroot_dir} login bruno

Now in chroot, using  gvim  as a representative GUI application:
Code: [Select]
Alpine:~$ export DISPLAY=:0
Alpine:~$ gvim
E665: Cannot start GUI, no valid font found
Press ENTER or type command to continue18;0M

Any ideas how to solve the font problem? I've already tried bind-mounting /usr/local/etc/fonts to chroot's /etc/fonts, to no avail.

P.S. UID inside and outside are the same:
Code: [Select]
TCL$ id
uid=1000(bruno) gid=50(staff) groups=50(staff)

Code: [Select]
Alpine$ id
uid=1000(bruno) gid=1000(bruno) groups=1000(bruno)



« Last Edit: April 13, 2021, 08:49:22 AM by GNUser »

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: chroot other Linux distros under Tinycore
« Reply #4 on: April 13, 2021, 10:08:14 AM »
xterm also fails in the chroot:
Code: [Select]
Alpine$ xterm
xterm: Error 32, errno 2: No such file or directory
Reason: get_pty: not enough ptys

But  xeyes  works fine. So it seems barebones GUI apps work, but more complicated GUI apps (e.g., gvim, xterm) need access to things (e.g., fonts, ptys) that are not readily available in a chroot environment.

I prefer to contribute missing packages to TCL rather than run them in a chroot, so this is not a big deal. I just thought it would be an interesting experiment.
« Last Edit: April 13, 2021, 10:13:27 AM by GNUser »

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: chroot other Linux distros under Tinycore
« Reply #5 on: April 13, 2021, 10:22:10 AM »
It turns out that the /dev bind mount doesn't include /dev/pts, which seems to be a separate filesystem.

I ran this in the TCL host system and now  xterm  works in the chroot :)
Code: [Select]
sudo mount -t devpts devpts ${chroot_dir}/dev/pts
It would still be nice to figure out how to satisfy  gvim  in the chroot.


Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: chroot other Linux distros under Tinycore
« Reply #6 on: April 13, 2021, 12:27:51 PM »
IIRC I didn't have to do anything with fonts, but my chroot had its own fonts and font libs installed.
The only barriers that can stop you are the ones you create yourself.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: chroot other Linux distros under Tinycore
« Reply #7 on: April 13, 2021, 12:32:51 PM »
I figured it out.

This allows X to work generally (it makes host's /tmp/.X11-unix available to the chroot) (thanks curaga!):
Code: [Select]
TCL_host$ sudo mount -o bind /tmp ${chroot_dir}/tmp

This is required for xterm to work in the chroot:
Code: [Select]
TCL_host$ sudo mount -t devpts devpts ${chroot_dir}/dev/pts

Installing a suitable font in the chroot is required for some apps (e.g., gvim) to work:
Code: [Select]
Alpine_client$ sudo apk add ttf-hack
Other GUI applications may have their own quirks.

Thread may be marked as solved :)

In case it helps anyone, I attached my initial setup notes and the script that I use to subsequently start the alpine chroot.



Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: chroot other Linux distros under Tinycore
« Reply #8 on: April 13, 2021, 12:37:21 PM »
IIRC I didn't have to do anything with fonts, but my chroot had its own fonts and font libs installed.
Thanks, curaga. I should have tried such easy things first ::) Maybe next time.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: [Solved] chroot other Linux distros under Tinycore
« Reply #9 on: April 13, 2021, 02:10:19 PM »
Hi GNUser
... Thread may be marked as solved :) ...
Done. ;D