WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: chroot: how to run TC4_x86 from tc12_x86_64  (Read 2361 times)

Offline nick65go

  • Hero Member
  • *****
  • Posts: 820
chroot: how to run TC4_x86 from tc12_x86_64
« on: November 19, 2021, 03:04:28 PM »
The chroot" process is very simple actually. You just need to copy (from Tinycore-4x-32bits.iso) the /core.gz and extract this cpio archive some where. Then simple chroot inside it like this:
Code: [Select]
tc@box:/mnt/sda8/chroot/playQemu/TC/wow$ sudo chroot .
@box:/# busybox uname -a
Linux box 5.10.3-tinycore64 #2021 SMP Mon Dec 28 16:17:51 UTC 2020 x86_64 GNU/Linux
@box:/# ldd /bin/editor
        linux-gate.so.1 (0xf7f8c000)
        libfltk.so.1.1 => /usr/lib/libfltk.so.1.1 (0xf7f07000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xf7e43000)
        libm.so.6 => /lib/libm.so.6 (0xf7d66000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0xf7d4f000)
        libc.so.6 => /lib/libc.so.6 (0xf7baa000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xf7b8c000)
        libdl.so.2 => /lib/libdl.so.2 (0xf7b87000)
        libXext.so.6 => /usr/lib/libXext.so.6 (0xf7b7a000)
        libX11.so.6 => /usr/lib/libX11.so.6 (0xf7a79000)
        /lib/ld-linux.so.2 (0xf7f8e000)
        libXau.so.6 => /usr/lib/libXau.so.6 (0xf7a76000)
        libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xf7a71000)
@box:/#
@box:/# ldd /usr/lib/libX11.so.6.3.0
        linux-gate.so.1 (0xf7fbe000)
        libXau.so.6 => /usr/lib/libXau.so.6 (0xf7eb4000)
        libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xf7eaf000)
        libdl.so.2 => /lib/libdl.so.2 (0xf7eaa000)
        libc.so.6 => /lib/libc.so.6 (0xf7d05000)
        /lib/ld-linux.so.2 (0xf7fc0000)
@box:/# editor
_X11TransSocketINETConnect() can't get address for localhost:6000: System error
Can't open display: :0.0
@box:/#
As you can see, after I did "sudo chroot .", the tc-host is 64 bits, all files inside this "container" are 32 bits (from TC4.7.7).
Nothing is missing for "editor", neither for "/usr/lib/libX11.so". But Xorg (from TC12 64 bits) does not want to run my 32 bits "editor".

Xorg (from host) depends on libX11.so and many other *.so. But because Xorg already found a file libX11.so (in the "container" chroot) it loaded it, but missed libxcb.so which Xorg needs / depends.

The trick was to manually copy from host the newer libX11.so and its dependent libxcb.so into guest-chroot /usr/lib folder. And all is solved now. To prove that my guest-chroot has only few files (busybox, sh, editor, fltk*.so, and editor dependencies) and only few folder (bin, lib, usr/lib) I run "busybox ls" and "busybox du". It shows no fonts, etc in container.
Code: [Select]
@box:/# busybox ls /
bin       lib       root      test.txt  usr
@box:/# busybox ls -l
total 16
drwxr-xr-x    2 1001     50            4096 Nov 19 19:52 bin
drwxr-xr-x    2 1001     50            4096 Nov 19 19:15 lib
drwxr-xr-x    2 1001     50            4096 Nov 19 01:14 root
 -rw-r--r--    1 1001     50                 0 Nov 19 14:28 test.txt
drwxr-xr-x    3 1001     50            4096 Nov 19 19:09 usr
@box:/#
@box:/# busybox du /
2832    /usr/lib
2836    /usr
8          /root
4836     /lib
532      /bin
8216    /
@box:/#
« Last Edit: November 19, 2021, 03:10:18 PM by nick65go »

Offline nick65go

  • Hero Member
  • *****
  • Posts: 820
Re: chroot: how to run TC4_x86 from tc12_x86_64
« Reply #1 on: November 19, 2021, 04:35:09 PM »
updates: I started from zero (again, to be sure) with minimal file structure; like /bin/busybox needs /lib/{ld*.so, libc*.so, libcrypt*.so}. Then added all /bin/editor dependencies (obtained with ldd). And the new "discovery" libX11*.so and libxcb*.so.
And now the moment of truth:
Code: [Select]
@box:/# editor
editor: /lib/libc.so.6: version `GLIBC_2.28' not found (required by /usr/lib/libX11.so.6)
editor: /lib/libc.so.6: version `GLIBC_2.26' not found (required by /usr/lib/libX11.so.6)
editor: /lib/libc.so.6: version `GLIBC_2.28' not found (required by /usr/lib/libxcb.so.1)
@box:/#
hm, updated libc (taken from host), back again in chroot, try again and:
Code: [Select]
@box:/# editor
editor: symbol lookup error: /lib/libpthread.so.0: undefined symbol: h_errno, version GLIBC_PRIVATE
@box:/#
Summary: not hard to replace few (5) libs, but lesson was learned and shared, about library version and symbol missing in old ones.
In the end I have to replace / update few basic libraries (from 2.11.1 to 2.32) in /lib: ld, libc, libphread
It was worthy, because now I can use all small tcz from TC4 without running qemu, just chroot. I hope you enjoyed the process.

PS: Maybe now is more clear why I chase small statically linked busybox applets where toybox is not up to task (yet): to allow me to mix and match a lot of various little gems, independent of 32/64 bits or the base libc/musl, etc.
« Last Edit: November 19, 2021, 04:57:06 PM by nick65go »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11028
Re: chroot: how to run TC4_x86 from tc12_x86_64
« Reply #2 on: November 20, 2021, 04:52:52 AM »
You're going over network there, which will slow down X apps. See other threads and docs, in short you should mount proc and sys, and bind-mount tmp and dev before chrooting. Doing this you won't need to replace libs.
The only barriers that can stop you are the ones you create yourself.

Offline nick65go

  • Hero Member
  • *****
  • Posts: 820
Re: chroot: how to run TC4_x86 from tc12_x86_64
« Reply #3 on: November 20, 2021, 08:38:42 AM »
@curaga: THANK YOU. I will try as you advised.

I must make a correction to my assays: I think the test was for TC-3.8.4-K_2.6.33.3.iso. I will report soon about it, properly using curaga tips.

Because for TC-4.7.7-K_3.0.21.iso is working out of the box! Here below is the reproducible process.
Code: [Select]
tc@box:/mnt/sda8/chroot/playQemu/TC$ mkdir -p ./mnt/iso
tc@box:/mnt/sda8/chroot/playQemu/TC$ sudo mount ./TC-4.7.7-K_3.0.21.iso ./mnt/iso/
tc@box:/mnt/sda8/chroot/playQemu/TC$ mkdir ./tc4-32
tc@box:/mnt/sda8/chroot/playQemu/TC$ cp ./mnt/iso/boot/core.gz ./tc4-32/
tc@box:/mnt/sda8/chroot/playQemu/TC$ unsquashfs -f ./mnt/iso/cde/optional/Xprogs.tcz /usr/local/bin/editor
tc@box:/mnt/sda8/chroot/playQemu/TC$ unsquashfs -f ./mnt/iso/cde/optional/fltk-1.1.10.tcz
tc@box:/mnt/sda8/chroot/playQemu/TC$ unsquashfs -f ./mnt/iso/cde/optional/Xlibs.tcz
tc@box:/mnt/sda8/chroot/playQemu/TC$ cp -a ./squashfs-root/* ./tc4-32/

tc@box:/mnt/sda8/chroot/playQemu/TC$ sudo umount ./mnt/iso/

tc@box:/mnt/sda8/chroot/playQemu/TC$ cd ./tc4-32/
tc@box:/mnt/sda8/chroot/playQemu/TC/tc4-32$ zcat ./core.gz | sudo cpio -i -H newc -d
tc@box:/mnt/sda8/chroot/playQemu/TC/tc4-32$ sudo chown -R tc:staff ./*

tc@box:/mnt/sda8/chroot/playQemu/TC/tc4-32$ sudo chroot .
root@box:/# ldd /usr/local/bin/editor
        linux-gate.so.1 =>  (0xf7fdb000)
        libfltk.so.1.1 => not found

root@box:/# ldconfig
root@box:/# editor
root@box:/#
==Now is OK!, even without any new library, and  with NOT mounted /dev, /proc /sys==
I think the main strong points here were running ldconfig (to find all libs), the full linux file hierarchy (/etc folder ?) and maybe tc:staff full access to every file from container.

Offline nick65go

  • Hero Member
  • *****
  • Posts: 820
Re: chroot: how to run TC4_x86 from tc12_x86_64
« Reply #4 on: November 20, 2021, 09:47:16 AM »
@curaga: I own you a (virtual) beer!
The important command was to mount /tmp from host; (maybe because /tmp has the /tmp/tcloop/* with all libs for Xorg?).
If I tried without  this /tmp mount, then all other mounts, or ldconfig, etc are for nothing. Here below is the full procedure for TC3x:
Code: [Select]
tc@box:/mnt/sda8/chroot/playQemu/TC$ mkdir -p ./mnt/iso
tc@box:/mnt/sda8/chroot/playQemu/TC$ sudo mount ./TC-3.8.4-K_2.6.33.3.iso ./mnt/iso/
tc@box:/mnt/sda8/chroot/playQemu/TC$ mkdir ./tc3
tc@box:/mnt/sda8/chroot/playQemu/TC$ cp ./mnt/iso/boot/tinycore.gz ./tc3/
tc@box:/mnt/sda8/chroot/playQemu/TC$ sudo umount ./mnt/iso/

tc@box:/mnt/sda8/chroot/playQemu/TC$ cd ./tc3/
tc@box:/mnt/sda8/chroot/playQemu/TC/tc4-32$ zcat ./tinycore.gz | sudo cpio -i -H newc -d
tc@box:/mnt/sda8/chroot/playQemu/TC/tc4-32$ sudo chown -R tc:staff ./*

tc@box:/mnt/sda8/chroot/playQemu/TC/tc3$ sudo mount /proc ./proc/
tc@box:/mnt/sda8/chroot/playQemu/TC/tc3$ sudo mount /sys ./sys/
tc@box:/mnt/sda8/chroot/playQemu/TC/tc3$ sudo mount -o bind /dev/ ./dev/
tc@box:/mnt/sda8/chroot/playQemu/TC/tc3$ sudo mount -o bind /tmp/ ./tmp/

tc@box:/mnt/sda8/chroot/playQemu/TC/tc3$ sudo chroot .
root@box:/# ldconfig  <-- not need, because tinycore.gz is full_core.gz + /cde_tczs
root@box:/# /usr/bin/editor
root@box:/#

PS: Of course it is too permissible the allow for an "alien container" to see (and use) all my host devices (usb, webcam, hdd partitions); but this is already out of this topic scope. Bootom line is that (with curaga help) I could share an effective procedure to chroot many TC versions.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11028
Re: chroot: how to run TC4_x86 from tc12_x86_64
« Reply #5 on: November 20, 2021, 01:33:00 PM »
The key is the /tmp/.X11* files that X uses for local messaging.
The only barriers that can stop you are the ones you create yourself.

Offline nick65go

  • Hero Member
  • *****
  • Posts: 820
Re: chroot: how to run TC4_x86 from tc12_x86_64
« Reply #6 on: November 21, 2021, 12:17:05 PM »
Thanks.
Code: [Select]
tc@box:~$ strings /tmp/tcloop/xorg-server/usr/local/lib/xorg/Xorg | grep tmp
/var/tmp
/tmp/
/tmp/launch
/tmp/.X11-unix
/tmp/.X11-unix/X
tc@box:~$

It looks like this X.Org X Server 1.20.11 from TC12 does not use /tmp/.ICE-unix, it uses only X0 socket from /tmp/.X11-unix