Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mount /proc before starting chroot #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

timonsku
Copy link
Contributor

Some scripts like the installer for rust (rustup) rely on the existance of /proc/self/exe
This mounts /proc into the chroot folder before entering

@foosel
Copy link
Member

foosel commented Dec 15, 2021

Sorry for the late response... Possibly a stupid question, but couldn't this potentially cause issues when the mounted proc of the host doesn't even remotely match what should be there on the target?

@JoveToo
Copy link

JoveToo commented Jun 29, 2022

Mounting /proc before entering a chroot is standard practice.

Most of what proc contains is process and kernel information, both things that are identical inside and outside the chroot.

@foosel
Copy link
Member

foosel commented Jun 29, 2022

The problem is that we are not just entering a chroot here though but actually emulate a different system in that chroot in order to install stuff and run modification code. And that's where I'm worried that the proc from the host would cause issues with the guest.

@JoveToo
Copy link

JoveToo commented Jun 29, 2022

You are always emulating a different system with a chroot, that is the whole point of a chroot. The fact that it is a different distribution or so won't matter (as long as it is binary compatible with the running kernel).

The only time this could cause a problem is when code makes decisions about information in /proc when that is different from what /proc would be in your new system.... but that code would not function without /proc and thus would have already failed your build.

In any case, it should be easy enough to test...

@foosel
Copy link
Member

foosel commented Jun 29, 2022

as long as it is binary compatible with the running kernel

And exactly THAT, from my understanding, is not the case here (usually built on x86 against emulated arm), or is it?

but that code would not function without /proc and thus would have already failed your build.

From my understanding the whole reason for the PR was that exactly that happened, and in a context that sounded quite architecture specific to me.

@JoveToo
Copy link

JoveToo commented Jun 29, 2022

usually built on x86 against emulated arm

This is outside my comfort zone :)

From my understanding the whole reason for the PR was that exactly that happened, and in a context that sounded quite architecture specific to me.

This should just be tested. If you do not mount /proc, you will have more code that will fail because it is considered a standard feature of a linux kernel.

@foosel
Copy link
Member

foosel commented Jun 29, 2022

Well, so far building stock OctoPi via CustomPiOS as well as anything I've run through CustoPiZer has worked just fine, with that mechanism, without a mounted /proc, and I'd like that to continue to do this, hence my caution here ;)

@jneilliii
Copy link
Contributor

rust install via rustup script was definitely a pain. I ended up finding a workaround by using the command below. but I have yet to figure out how much I need to expand the disk space to allow it to build yet. keep running out of space.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sed 's#/proc/self/exe#\/bin\/sh#g' | sh -s -- -y

@jneilliii
Copy link
Contributor

ok added 30GB (random post I saw somewhere), but then got the next error relative to /proc/...

rustup: command failed: grep ^Features /proc/cpuinfo

@JoveToo
Copy link

JoveToo commented Jan 8, 2023

On my x86 machine, ^Features does not match any lines but it does on the pi:

Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32

In theory, you could try to create a file /proc/cpuinfo with the following content:

processor	: 0
model name	: ARMv7 Processor rev 4 (v7l)
BogoMIPS	: 38.40
Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

processor	: 1
model name	: ARMv7 Processor rev 4 (v7l)
BogoMIPS	: 38.40
Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

processor	: 2
model name	: ARMv7 Processor rev 4 (v7l)
BogoMIPS	: 38.40
Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

processor	: 3
model name	: ARMv7 Processor rev 4 (v7l)
BogoMIPS	: 38.40
Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

Hardware	: BCM2835
Revision	: a02082
Serial		: 00000000xxxxxxxx
Model		: Raspberry Pi 3 Model B Rev 1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Blocked
Development

Successfully merging this pull request may close these issues.

4 participants