View previous topic :: View next topic |
Author |
Message |
Chewi Developer
Joined: 01 Sep 2003 Posts: 886 Location: Edinburgh, Scotland
|
Posted: Mon Apr 02, 2018 7:09 pm Post subject: |
|
|
PS1 disappears because it gets stripped out by sudo for security reasons. Try changing the chroot line to this.
Code: | exec env PS1=eden chroot '${ROOT}' /bin/bash -l |
|
|
Back to top |
|
|
Joseph_sys Advocate
Joined: 08 Jun 2004 Posts: 2712 Location: Edmonton, AB
|
Posted: Mon Apr 02, 2018 7:23 pm Post subject: |
|
|
Chewi wrote: | PS1 disappears because it gets stripped out by sudo for security reasons. Try changing the chroot line to this.
Code: | exec env PS1=eden chroot '${ROOT}' /bin/bash -l |
|
No, id didn't work:
Code: | syscon3 /home/thelma # sh chroot-eden
+ HOST=chroot-eden
+ HOST=eden
+ ROOT=/mnt/eden
+ PS1=eden
+ mkdir -p --mode=0755 /mnt/eden
+ exec sudo unshare -m /bin/sh -c '
set -e
mount -t nfs -o rw,noatime,nocto,actimeo=60,lookupcache=positive,vers=4,fsc '\''eden:/'\'' '\''/mnt/eden'\''
mount --bind {,'\''/mnt/eden'\''}/dev
mount --bind {,'\''/mnt/eden'\''}/dev/pts
mount --bind {,'\''/mnt/eden'\''}/dev/shm
mount --bind {,'\''/mnt/eden'\''}/proc
mount --bind {,'\''/mnt/eden'\''}/sys
mount --bind {,'\''/mnt/eden'\''}/usr/local/portage
mount --bind {,'\''/mnt/eden'\''}/usr/portage
mount --bind {,'\''/mnt/eden'\''}/var/cache/edb/dep
mount --bind {,'\''/mnt/eden'\''}/var/tmp/portage
#exec chroot '\''/mnt/eden'\'' /bin/bash -i
exec env PS1=eden chroot '\''/mnt/eden'\'' /bin/bash -i
'
syscon3 / # |
|
|
Back to top |
|
|
Chewi Developer
Joined: 01 Sep 2003 Posts: 886 Location: Edinburgh, Scotland
|
Posted: Mon Apr 02, 2018 7:30 pm Post subject: |
|
|
Oh of course, it'll be reset by ${ROOT}/etc/bash/bashrc. I guess you'll have to do something clever in there. |
|
Back to top |
|
|
guitou Guru
Joined: 02 Oct 2003 Posts: 534 Location: France
|
Posted: Tue Apr 03, 2018 1:35 pm Post subject: |
|
|
Hello.
I suppose PS1 is set... but out of chrooted env.
++
Gi)
Edit: replied too late! |
|
Back to top |
|
|
Joseph_sys Advocate
Joined: 08 Jun 2004 Posts: 2712 Location: Edmonton, AB
|
Posted: Tue Apr 03, 2018 6:17 pm Post subject: |
|
|
Chewi wrote: | Oh of course, it'll be reset by ${ROOT}/etc/bash/bashrc. I guess you'll have to do something clever in there. |
I was trying to run your script on another remote network but I get:
"Illegal instruction"
It worked find on one of my network but not remote one.
Code: | #!/bin/sh
set -x
HOST=${0##*/}
HOST=${HOST#*-}
ROOT=/mnt/${HOST}
PS1="${HOST}"
mkdir -p --mode=0755 "${ROOT}"
#env -i - HOME="/root" TERM="${TERM}" exec sudo unshare -m /bin/sh -c "
exec sudo unshare -m /bin/sh -c "
set -e
mount -t nfs -o rw,noatime,nocto,actimeo=60,lookupcache=positive,vers=4,fsc '${HOST}:/' '${ROOT}'
mount --bind {,'${ROOT}'}/dev
mount --bind {,'${ROOT}'}/dev/pts
mount --bind {,'${ROOT}'}/dev/shm
mount --bind {,'${ROOT}'}/proc
mount --bind {,'${ROOT}'}/sys
mount --bind {,'${ROOT}'}/usr/local/portage
mount --bind {,'${ROOT}'}/usr/portage
mount --bind {,'${ROOT}'}/var/cache/edb/dep
mount --bind {,'${ROOT}'}/var/tmp/portage
exec chroot '${ROOT}' /bin/bash -i
" |
Code: | + HOST=chroot-i5
+ HOST=i5
+ ROOT=/mnt/i5
+ PS1=i5
+ mkdir -p --mode=0755 /mnt/i5
+ exec sudo unshare -m /bin/sh -c '
set -e
mount -t nfs -o rw,noatime,nocto,actimeo=60,lookupcache=positive,vers=4,fsc '\''i5:/'\'' '\''/mnt/i5'\''
mount --bind {,'\''/mnt/i5'\''}/dev
mount --bind {,'\''/mnt/i5'\''}/dev/pts
mount --bind {,'\''/mnt/i5'\''}/dev/shm
mount --bind {,'\''/mnt/i5'\''}/proc
mount --bind {,'\''/mnt/i5'\''}/sys
mount --bind {,'\''/mnt/i5'\''}/usr/local/portage
mount --bind {,'\''/mnt/i5'\''}/usr/portage
mount --bind {,'\''/mnt/i5'\''}/var/cache/edb/dep
mount --bind {,'\''/mnt/i5'\''}/var/tmp/portage
exec chroot '\''/mnt/i5'\'' /bin/bash -i
'
Illegal instruction |
|
|
Back to top |
|
|
Chewi Developer
Joined: 01 Sep 2003 Posts: 886 Location: Edinburgh, Scotland
|
Posted: Tue Apr 03, 2018 6:27 pm Post subject: |
|
|
Judging by the "i5" name, this is a Core i5 that has had its software built with CFLAGS that are not compatible with the processor you are now trying to run it on. Also be careful not to use -march=native or you might end up breaking the remote system. |
|
Back to top |
|
|
Joseph_sys Advocate
Joined: 08 Jun 2004 Posts: 2712 Location: Edmonton, AB
|
Posted: Tue Apr 03, 2018 7:49 pm Post subject: |
|
|
Chewi wrote: | Judging by the "i5" name, this is a Core i5 that has had its software built with CFLAGS that are not compatible with the processor you are now trying to run it on. Also be careful not to use -march=native or you might end up breaking the remote system. |
The computer that would be doing the compiling is:
AMD FX(tm)-8350 Eight-Core Processor
CFLAGS="-march=native -O2 -pipe"
What should I use on the above computer?
The i5 (you are correct) is (chroot failed on this)
Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
CFLAGS="-march=native -O2 -pipe"
Though, I was able to run the chroot-script OK on another remote box (same network):
Intel(R) Atom(TM) CPU 330 @ 1.60GHz
CFLAGS="-march=core2 -O2 -pipe"
--------------
On my local network I recompile/upgraded my via chroot
VIA Eden Processor 1200MHz
CFLAGS="-O2 -march=i686 -pipe"
The computer that was doing compiling was:
AMD Ryzen 5 1400 Quad-Core Processor
CFLAGS="-march=native -O2 -pipe" |
|
Back to top |
|
|
Chewi Developer
Joined: 01 Sep 2003 Posts: 886 Location: Edinburgh, Scotland
|
Posted: Tue Apr 03, 2018 8:10 pm Post subject: |
|
|
Your Eden/Ryzen combo didn't break anything because only the Ryzen system had -march=native. If the Eden system had had that too, you would have found it broken following your upgrade. To be absolutely safe, stop using -march=native everywhere.
Your i5 system is a Haswell and your FX system is a Piledriver (bdver2). The gcc man page shows some slight differences between these and it only takes one instruction to break things. I think the most likely culprit is AVX2. For this to work, you would need to rebuild the i5 system or maybe even both with the lowest common denominator but it's hard to say what that would be. Usually this kind of problem is avoided because it is a much newer system doing the building. In your situation, you may want to consider distcc instead. In theory, the new stuff arriving in EAPI 7 will allow you to mount your remote system and build without chrooting but it is likely to break in other ways because this approach is mainly intended for cross-compiling. |
|
Back to top |
|
|
pablocool n00b
Joined: 27 Jul 2017 Posts: 58
|
Posted: Tue Jul 17, 2018 9:59 am Post subject: |
|
|
Hello Guys
I also wanted to use this cool method but failed. Please help in tshooting.
Code: | pablocool@wloski ~ $ cat chroot-10.0.0.100
#!/bin/sh
set -x
HOST=${0##*/}
HOST=${HOST#*-}
ROOT=/mnt/${HOST}
PS1="${HOST}"
mkdir -p --mode=0755 "${ROOT}"
#env -i - HOME="/root" TERM="${TERM}" exec sudo unshare -m /bin/sh -c "
exec sudo unshare -m /bin/sh -c "
set -e
mount -t nfs -o rw,noatime,nocto,actimeo=60,lookupcache=positive,vers=4,fsc '${HOST}:/' '${ROOT}'
mount --bind {,'${ROOT}'}/dev
mount --bind {,'${ROOT}'}/dev/pts
mount --bind {,'${ROOT}'}/dev/shm
mount --bind {,'${ROOT}'}/proc
mount --bind {,'${ROOT}'}/sys
mount --bind {,'${ROOT}'}/usr/local/portage
mount --bind {,'${ROOT}'}/usr/portage
mount --bind {,'${ROOT}'}/var/cache/edb/dep
mount --bind {,'${ROOT}'}/var/tmp/portage
exec chroot '${ROOT}' /bin/bash -i
"
|
Code: | pablocool@wloski ~ $ sh chroot-10.0.0.100
+ HOST=chroot-10.0.0.100
+ HOST=10.0.0.100
+ ROOT=/mnt/10.0.0.100
+ PS1=10.0.0.100
+ mkdir -p --mode=0755 /mnt/10.0.0.100
+ exec sudo unshare -m /bin/sh -c
set -e
mount -t nfs -o rw,noatime,nocto,actimeo=60,lookupcache=positive,vers=4,fsc '10.0.0.100:/' '/mnt/10.0.0.100'
mount --bind {,'/mnt/10.0.0.100'}/dev
mount --bind {,'/mnt/10.0.0.100'}/dev/pts
mount --bind {,'/mnt/10.0.0.100'}/dev/shm
mount --bind {,'/mnt/10.0.0.100'}/proc
mount --bind {,'/mnt/10.0.0.100'}/sys
mount --bind {,'/mnt/10.0.0.100'}/usr/local/portage
mount --bind {,'/mnt/10.0.0.100'}/usr/portage
mount --bind {,'/mnt/10.0.0.100'}/var/cache/edb/dep
mount --bind {,'/mnt/10.0.0.100'}/var/tmp/portage
exec chroot '/mnt/10.0.0.100' /bin/bash -i
mount: mount point {,/mnt/10.0.0.100}/dev does not exist |
I cannot understand these {,' ... '} construction. Appreciate any explaination. |
|
Back to top |
|
|
Chewi Developer
Joined: 01 Sep 2003 Posts: 886 Location: Edinburgh, Scotland
|
Posted: Tue Jul 17, 2018 10:07 am Post subject: |
|
|
Turns out brace expansion is a Bashism. You learn something every day. Replace #!/bin/sh with #!/bin/bash. |
|
Back to top |
|
|
pablocool n00b
Joined: 27 Jul 2017 Posts: 58
|
Posted: Tue Jul 17, 2018 11:07 am Post subject: |
|
|
Point for you even still it is not working.
Old PC is gentoo system it has:
lrwxrwxrwx 1 root root 4 07-14 21:04 /bin/sh -> bash
However only to test purposes as strong machine I used Debian VPS. It has:
lrwxrwxrwx 1 root root 4 lip 20 2016 /bin/sh -> dash
I am closer but still not working:
Code: | + HOST=chroot-10.0.0.100
+ HOST=10.0.0.100
+ ROOT=/mnt/10.0.0.100
+ PS1=10.0.0.100
+ mkdir -p --mode=0755 /mnt/10.0.0.100
+ exec sudo unshare -m /bin/sh -c '
set -e
mount -t nfs -o rw,noatime,nocto,actimeo=60,lookupcache=positive,vers=4,fsc '\''10.0.0.100:/'\'' '\''/mnt/10.0.0.100'\''
mount --bind {,'\''/mnt/10.0.0.100'\''}/dev
mount --bind {,'\''/mnt/10.0.0.100'\''}/dev/pts
mount --bind {,'\''/mnt/10.0.0.100'\''}/dev/shm
mount --bind {,'\''/mnt/10.0.0.100'\''}/proc
mount --bind {,'\''/mnt/10.0.0.100'\''}/sys
mount --bind {,'\''/mnt/10.0.0.100'\''}/usr/local/portage
mount --bind {,'\''/mnt/10.0.0.100'\''}/usr/portage
mount --bind {,'\''/mnt/10.0.0.100'\''}/var/cache/edb/dep
mount --bind {,'\''/mnt/10.0.0.100'\''}/var/tmp/portage
exec chroot '\''/mnt/10.0.0.100'\'' /bin/bash -i
'
mount: mount point {,/mnt/10.0.0.100}/dev does not exist |
Why do we need these brackets { } ?
EDIT:
Also this line needed update
+ exec sudo unshare -m /bin/sh -c ' |
|
Back to top |
|
|
Chewi Developer
Joined: 01 Sep 2003 Posts: 886 Location: Edinburgh, Scotland
|
Posted: Tue Jul 17, 2018 12:08 pm Post subject: |
|
|
Oh, I missed the /bin/sh in the middle of the script. Replace that too.
It's just a short way of saying:
Code: | mount --bind /dev /mnt/10.0.0.100/dev |
|
|
Back to top |
|
|
pablocool n00b
Joined: 27 Jul 2017 Posts: 58
|
Posted: Wed Jul 18, 2018 7:40 am Post subject: |
|
|
Thank you for help! IT is working.
To just information, its overkill of course but it is even working over internet over OpenVPN. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|