WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: vscodium in tinycore, from chroot to docker  (Read 5031 times)

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
vscodium in tinycore, from chroot to docker
« on: June 20, 2021, 09:38:06 PM »
Does anyone have a guide on how to start tinycore in chroot from another distro, maybe even graphically?
I am totally inexperienced but would be curious to try it.

Offline nick65go

  • Hero Member
  • *****
  • Posts: 595
Re: vscodium in tinycore, from chroot to docker
« Reply #1 on: June 21, 2021, 06:13:13 AM »
hi, you just need few folders (/bin /lib /proc /sys) and few mounts on them; plus a shell (static linked busybox is best)no need for a kernel; just the binaries and their *.so.* dependencies.
on x64 CPU you can have chroot for 32 bits also.what matters is a shell, libc and the apps.
https://wiki.alpinelinux.org/wiki/Alpine_Linux_in_a_chroot#Method_1.b_Manual_way:_Creating_needed_nodes

see also (self -descriptive):
http://landley.net/toybox/downloads/binaries/mkroot/latest/
http://www.giannone.ch/rescue/current/
« Last Edit: June 21, 2021, 06:17:31 AM by nick65go »

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: vscodium in tinycore, from chroot to docker
« Reply #2 on: June 21, 2021, 02:50:03 PM »
I have to go to sleep now but I looked at your links and I can tell you:
I am also an alpine user
About the chroot I tried to follow their guide once, succeeding but not understanding much of what I did.

I also tried junest but there were some problems that I don't remember now.
I realize I may need to read something simpler to get started, if you have any resources to recommend I appreciate it :)

Offline nick65go

  • Hero Member
  • *****
  • Posts: 595
Re: vscodium in tinycore, from chroot to docker
« Reply #3 on: June 21, 2021, 10:46:02 PM »

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: vscodium in tinycore, from chroot to docker
« Reply #4 on: June 22, 2021, 02:23:38 PM »
Eh ok, I'm good at decompressing things, think I can also remember tar parameter by heart, but I lack all the other notions for chroot.
I found this guide and I can try with alpine, however I didn't want to enter chroot of alpine but of tinycore, I searched on the forum and there are several posts about it, maybe after I succeed with alpine and get some confidence I'll try to rejoin the posts on the forum.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 13807
Re: vscodium in tinycore, from chroot to docker
« Reply #5 on: June 23, 2021, 12:49:01 AM »
You can also look at:

http://tinycorelinux.net/12.x/x86_64/release/src/toolchain/compile_tc12_x86_64

..which uses tinycore as a chroot host to build an updated tinycore - see from the line "sudo chown -R root:root $TC/{usr,lib,var,etc,bin,sbin,tools}"

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: vscodium in tinycore, from chroot to docker
« Reply #6 on: June 23, 2021, 02:31:45 PM »
@Juanito
thanks juan, i will take a look as soon as possible

@nick65go
I have run that guide once and it worked, although I think it is just the notions that I am missing

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: vscodium in tinycore, from chroot to docker
« Reply #7 on: June 26, 2021, 08:36:35 AM »
You can also look at:

http://tinycorelinux.net/12.x/x86_64/release/src/toolchain/compile_tc12_x86_64

..which uses tinycore as a chroot host to build an updated tinycore - see from the line "sudo chown -R root:root $TC/{usr,lib,var,etc,bin,sbin,tools}"

ehy juanito, I'm trying to follow those instructions but the procedure crashes almost immediately:
Code: [Select]
1) $ 7z x ./TinyCorePure64-12.0.iso -o./iso #get "corepure64.gz"
2) # zcat ./corepure64.gz  |  cpio -i -H newc -d #uncompress it with
3) # mknod -m 600 ./dev/console c 5 1
     mknod: ./dev/console: File exists

I don't know if this influences but I'm not doing this procedure with a tinycore as host computer

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: vscodium in tinycore, from chroot to docker
« Reply #8 on: June 26, 2021, 01:40:01 PM »
ok, as i said i don't have any experience with chroot and i didn't know the mknod command, from what i've understood reading on internet it's used to create FIFO files.
I erroneously thought it was to create a link between the files on the host system with the one in chroot.
So in theory I don't need to give those commands if I unzip corepure64.gz, correct?

Offline nick65go

  • Hero Member
  • *****
  • Posts: 595
Re: vscodium in tinycore, from chroot to docker
« Reply #9 on: June 27, 2021, 11:28:57 AM »
in theory, you need to have some folders under your new pseudo-root. It does not matter who created them (you manually with mknod, or ready made by others and you just lazy extract them).

These folders are requested by kernel API calls, or checked by programs (like busybox checks for /dev/console).To chroot means "change the root", so your new "root" (folder pseudo-root) is now seen as "/" by new shell and programs.
And that is ALL. You navigate from pseudo-root as in new jail system, but accessing /dev, /proc, /sys from main system.
PS: of course you need to MOUNT your new pseudo-PROC and pseudo-SYS and pseudo-DEV (BEFORE you enter into this pseudo-root !!) to "point" to the REAL /proc and REAL /sys and REAL /dev, from mother boot system. If you miss this step (to mount them before "sudo chroot busybox pseudo-root-path") you have problems (nothing works).
« Last Edit: June 27, 2021, 11:45:56 AM by nick65go »

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: vscodium in tinycore, from chroot to docker
« Reply #10 on: July 08, 2021, 04:18:47 PM »
Ok, I asked a friend to give me a hand with the chroot to make me understand what I didn't understand and this time I succeeded, I still don't know if everything is ok but I want to write what I did. I tend to write because maybe it can help someone else and also because it's good for me to reorganize my thoughts and because I can read it again if I forget.

So let's go through the code now then I explain what I understand:
Code: [Select]
0 $ mkdir ~/chroot; cd .~/chroot; _wget http://tinycorelinux.net/12.x/x86_64/release/distribution_files/corepure64.gz
1 $ sudo su
2 # zcat ./corepure64.gz  |  cpio -i -H newc -d
3 #  echo nameserver 208.67.222.222 > ./etc/resolv.conf
4 # TC=/home/tc/chroot
5 # mount -v --bind /dev $TC/dev
6 # mount -v --bind /dev/pts $TC/dev/pts
7 # mount -vt proc proc $TC/proc
8 # mount -vt sysfs sysfs $TC/sys
9 # mount -vt tmpfs tmpfs $TC/run
10# chroot "$TC" /bin/ash

It's basically a copy of the one juanito passed me minus several things.
0) prepare the dir
1) I log as root because in line 1 I probably should have written two sudo's (one before and one after the pipe)
2) unzip the root of tinycore
3) set dns for connection
4) environment variable for let juanito commands work
-) Skipped all the mkdir and mknod because all the dir's are already in corepure64.gz
5-9) All of these commands work. My friend and I couldn't figure out where sysfs is taken since it's not listed with the "df -h" command. For personal note he also told me that these dirs should be unmounted when you finish using the chroot with umount and that anyway when you turn off the pc these mounts are lost. He suggested to make a dedicated script to open and close the chroot.
10) then start! the first problem is that juanito's command requires the presence of bash in the chroot machine, but tinycore has only ash so it can't work with corepure64.gz. Second "problem", specifying PATH in that way means to assign less path than the basic ones, I removed this too, HOME, TERM and PS1 are identical, I removed them too. I also removed "/usr_/bin_/env_-i" but I don't know why, what is it for?

Please let me know if there is something wrong because I don't have the knowledge to understand it, for example doing everything from root risks that something won't work?
Currently the chroot works and also the connection but I can't install packages with tce-load -i, what's the problem?

My goal is to be able to use tinycore in chroot as if it was started directly from the host, so what I want to do is to install xorg and other programs afterwards. I've already seen someone who can do it with alpine and xephyr, so I want to do the same with tinycore!

Another thing i want to do, i've already prepared a version of tinycore that does what i like, when i want to create a chroot from that, will be enough to create an image of the booted disk? if yes, how?

Just a little off topic, I've written a little command that calculates the total of how much would occupy the sum of packages currently installed.
I would like to paste it but this code always make the server error, also if I replace all the spaces with _, so I attach it.
« Last Edit: July 08, 2021, 04:24:45 PM by vinnie »

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: vscodium in tinycore, from chroot to docker
« Reply #11 on: July 08, 2021, 05:10:14 PM »
let my guess about "/usr_/bin_/env_-i" removed from the chroot starting command, this is the command to execute the next environment variables assignment ?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10661
Re: vscodium in tinycore, from chroot to docker
« Reply #12 on: July 08, 2021, 11:04:03 PM »
You can't install packages because it doesn't know where to put them. It's like you booted a TC CD and didn't give it a tce dir, but with the additional complication that the CD's boot scripts set up a tce dir in RAM. Your chroot did not. There's a few things like this you need to set up, and no ready instructions exist.
The only barriers that can stop you are the ones you create yourself.

Offline nick65go

  • Hero Member
  • *****
  • Posts: 595
Re: vscodium in tinycore, from chroot to docker
« Reply #13 on: July 09, 2021, 01:18:09 AM »
@vinnie: Some tc scripts check if you are "user root" and then they do not run. You are "user tc", then when you "enter" into chroot you are user root. So from inside chroot maybe you need to "login" as user tc.

PS: you do not need to start another X server from chroot. As I said, you changed only the top start of tree hierarchy. Your appls see  (by new PATH) other libraries *.so. But they access the old "mother linux" devices, and kernel. In a chroot I can run a firefox on 32 bits (compiled against musl libc from Alpine), using Xorg on 64 bits (compiled against gnu libc) from Tinycore_64. Capisci?
« Last Edit: July 09, 2021, 01:45:42 AM by nick65go »

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: vscodium in tinycore, from chroot to docker
« Reply #14 on: July 09, 2021, 12:05:50 PM »
@curaga
You can't install packages because it doesn't know where to put them. It's like you booted a TC CD and didn't give it a tce dir, but with the additional complication that the CD's boot scripts set up a tce dir in RAM. Your chroot did not. There's a few things like this you need to set up, and no ready instructions exist.
So how could i do? i guess the command "tce-setdrive" is not enough because the packages would not be installed in the ram anyway, isn't it?

I'm in the condition of not knowing what to do and especially not knowing what else will not work in the enviorment.
The only things I can think are:
1) I could install the packages by hand in the root of chroot decompressing the tczs
2) I could just make an image of the booted distro avoiding to copy the dirs I need to mount in the chroot.
Tell me if these two solutions could work, although it would be great to be able to use chroot in the same way you would use the distro started in ram.


@nick65go
Yes when I logged into the chroot tinycore expressly forbids to use the tce-load command from root, so I had to do "su tc" even only for trying to install anything.
Yes, compriendo, and this is also interesting because it saves also on system resources, however i don't think I can avoid to install xorg on the chroot machine if I want to use graphic applications. Am I wrong?
« Last Edit: July 09, 2021, 12:11:07 PM by vinnie »