maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N800 (https://talk.maemo.org/forumdisplay.php?f=25)
-   -   Using a chroot shell to run non-Maemo text mode apps (https://talk.maemo.org/showthread.php?t=17653)

qwerty12 2008-03-18 17:17

Re: Using a chroot shell to run non-Maemo text mode apps
 
"
I am doing this in sudo gainroot mode. I assumed that was the same as "chroot shell", but is it?"

No. AFAIK.

"I got the message:
Quote:
WARNING: The following packages will be removed.
This should NOT be done unless you know exactly what you are doing!
busybox sysvinit
Is this OK?"

It's ok if you want to kill your internet tablet... They make up core components.

dormant 2008-03-18 17:32

Re: Using a chroot shell to run non-Maemo text mode apps
 
Thanks.

I am clearly WAY out of my depth here, so I'll give up ... for now.

Benson 2008-03-18 17:45

Re: Using a chroot shell to run non-Maemo text mode apps
 
A chroot shell means a shell obtained by chrooting.

The chroot command (implementing the chroot call) makes all processes spawned by it (typically a shell, and whatever is run from that shell) see something other than the real root directory ( / ) as the root directory.

Perhaps the most common use of chroot is on rescue CDs for fixing broken Linux installs, which boot up using an image on the CD, mount your harddrive somewhere, and chroot there. It's also used for running things (daemons, typically) in a "chroot jail", so that any exploits that compromise that service can't propagate upward and compromise the whole machine. A particularly famous instance of that use is in the iPhone, hence the term "jailbroken" for an iPhone from whose chroot jail has been compromised. But it's also used for running similar, but different, systems on the same machine. The kernel has to be the same, since there's only one kernel running, but system libraries can differ.

So you could set up a debian root filesystem on your SD card, then
Code:

chroot /media/mmc2/debroot/
would start /media/mmc2/debroot/bin/sh (which would think it was /bin/sh) thinking that /media/mmc2/debroot/ was /. And you could have completely different libraries in that filesystem, and programs linked against them rather than the N800 versions, and they'd run just fine.

dormant 2008-03-18 20:16

Re: Using a chroot shell to run non-Maemo text mode apps
 
Ah, I see.

The original poster said:

Quote:

You'd need a SD card formated ext2 or ext3 that has at least 500Mbytes of free space. It would probably be easiest to format the card and unpack the file on another computer running linux, but everything can be done on the N800. There are various articles that explain how to do that and I can provide pointers. The only other thing is the gzipped environment is 90Mbytes. Any ideas where I could post it?
I could do all that, but where to find the files?

Edit: found it!

Benson 2008-03-18 20:20

Re: Using a chroot shell to run non-Maemo text mode apps
 
gjarboni has the files, but is apparently still looking for someplace to host them.

Alternatively, the debian sneak preview thread has links, I believe. That image would probably work too.

gjarboni 2008-03-20 05:12

Re: Using a chroot shell to run non-Maemo text mode apps
 
Actually, I finally did manage to get gphoto2 to detect my camera. The problem was that the /dev directory in the chroot directory didn't have entries for the usb camera (or the usb adapter in host mode, I'm not sure which). Once I did that I can run gphoto2 -L (or -P) once with no problem. However the second command always causes the tablet to reboot. I just tried with a clean installation of the latest release of OS2008 (with becomeroot as the only package installed) and I'm getting the same results. So there's either something wrong with the OS2008 kernel, something inherently wrong with two different applications (using different libraries) trying to access the same USB port.

If someone wants to try the chroot environment that Dormant found, after doing a few apt-get install commands you will reach a point where you'll have to remove a key package and type in the phrase "Yes, do as I say!". This is fine AS LONG AS YOU ARE INSIDE THE CHROOT JAIL. The worst thing that can happen is that you'd break the armel-root-fs directory and have to unpack it again. I did such an update/upgrade and the chroot jail still worked fine. I believe I installed, joe, bash, & some of the networking utilities that I mentioned before to get to that point.

I might try to download the NSLU2 version of gphoto2 to see if that makes any difference. Actually, could someone point me to a link for that? Thanks.

qole 2008-05-08 22:14

Re: Using a chroot shell to run non-Maemo text mode apps
 
Hi, I have a working Debian chroot, just as you describe. It uses Johnx's bootable Debian install, and then, with a small script that mounts the partition, binds /dev and /proc and then chroots into Debian, I can apt-get anything in the Debian armel repositories (which need to be updated in the linked install that I gave you), and run it on the command line or, if I need a desktop, I've installed XFce4 and tightvncserver in the chroot so I can start that up and use VNC Viewer to use the app.

EDIT: I got X applications working, too. They won't be "hildonized" but they work! Check this post for details.

qole 2008-05-11 02:54

Re: Using a chroot shell to run non-Maemo text mode apps
 
Quote:

Originally Posted by Benson (Post 156913)
Perhaps the most common use of chroot is on rescue CDs for fixing broken Linux installs, which boot up using an image on the CD, mount your harddrive somewhere, and chroot there. It's also used for running things (daemons, typically) in a "chroot jail", so that any exploits that compromise that service can't propagate upward and compromise the whole machine. A particularly famous instance of that use is in the iPhone, hence the term "jailbroken" for an iPhone from whose chroot jail has been compromised. But it's also used for running similar, but different, systems on the same machine. The kernel has to be the same, since there's only one kernel running, but system libraries can differ.

chroot is very commonly used for exactly what we want to do here, which is running applications from a different variation of the OS. For instance, people who install 64-bit Linux on their desktop machines soon discover that many programs don't work with their OS. So they install a 32-bit version of Linux in a chroot and then they can run both 32-bit and 64-bit applications. That's where I learned how to do the tricks I mention in the linked post above.

Benson 2008-05-11 03:17

Re: Using a chroot shell to run non-Maemo text mode apps
 
Interesting; in most of what I'm familiar with, people install full 32-bit and 64-bit userlands in the same fs hierarchy. Most 64-bit distros (that I know about) put 64-bit libraries in /lib64/, /usr/lib64/, etc., and 32-bit libraries in the usual places.

If your distro had 64-bit libs in /lib/, then that would definitely be the way to go, if you need 32-bit programs. (If you can duck proprietary software, you can just compile all the extra stuff from source...)

Bundyo 2008-05-11 05:16

Re: Using a chroot shell to run non-Maemo text mode apps
 
Yeah, chroot is not needed for 32bit programs in a 64bit environment. You just have to be careful not to mix the libs :)


All times are GMT. The time now is 14:13.

vBulletin® Version 3.8.8