maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Alternatives (https://talk.maemo.org/forumdisplay.php?f=36)
-   -   [Debian] Running Debian in a chroot (https://talk.maemo.org/showthread.php?t=20342)

Benson 2008-08-07 17:33

Re: Running Debian in a chroot
 
So have you (qole, or actually anyone) tested that yet with a non-broken iceweasel? I'd like to know if it's working correctly.

(And I think I may have been a bit over-the-top with that post, actually. I'd forgotten about posting that when I went to set up my own chroot scripts from scratch on a clean flash (I was off-line, and hadn't got my backups handy), and even having looked at and tweaked your version previously, I only got perhaps over half the mounts and file clones right before I gave up a couple hours later. Major hat-tip for your success!)

qole 2008-08-07 17:55

Re: Running Debian in a chroot
 
Quote:

Originally Posted by Benson (Post 211179)
I will warn that iceweasel now looks horrible here, but I think that's because I clobbered something else, not from debbie.

Looks fine here. Thanks a lot.
(...I won't ask what you've clobbered now... :rolleyes:)

qole 2008-08-09 23:34

Re: Running Debian in a chroot
 
EDIT: Script attachment removed. See below for better scripts.

Ok, here are the new chroot scripts for beta testing.

The big news is that the chroot script is now BOOTABLE-DEBIAN-SAFE.

I have taken out all of the file copy commands and put them into a separate script, called "synchroot" which makes a unique backup of all copied files. This script is only run when the user creates an empty file called ~/.synchroot (which is deleted when the script completes). This way, the files are only copied into the chroot when the user requests it, which may be never, in the case of those with custom setups.

This will allow you to chroot into your OS2007 partition, for example, or into your bootable beta3 partition, without worrying about copying over any files. All you do is modify your ~/.chroot file.

I have also included a closechroot script, which closes all chroot apps and unmounts the chroot. This is useful for changing chroots, etc.

This also includes Benson's fixed debbie script.

qole 2008-08-10 06:39

Re: Running Debian in a chroot
 
Quote:

Originally Posted by Matan (Post 196824)
About unmounting: I found that killing all chrooted programs like this:


for i in [0-9]* ; do if ls -dl $i/root | grep -q /opt ; then kill $i ; fi ; done


And then unmounting in the correct order (basically reversed order of mounting), works everytime.

I used that line in my closechroot script, but it doesn't work. All I get is,
Code:

ls: [0-9]*/root: No such file or directory
What is that line supposed to do?

Stskeeps 2008-08-10 06:52

Re: Running Debian in a chroot
 
Quote:

Originally Posted by qole (Post 211962)
I used that line in my closechroot script, but it doesn't work. All I get is,
Code:

ls: [0-9]*/root: No such file or directory
What is that line supposed to do?

Can't you use 'fuser' or the likes instead of some voodoo solution of killing processes in chroot?

qole 2008-08-10 07:37

Re: Running Debian in a chroot
 
Quote:

Originally Posted by Stskeeps (Post 211964)
Can't you use 'fuser' or the likes instead of some voodoo solution of killing processes in chroot?

I don't know, can I? Please post the proper command.

EDIT: Thanks for the tip! I figured it out, it is really straightforward and "non-voodoo" :D

Code:

fuser -m "$CHROOT" -k
It's as simple as that, all chroot processes are killed!

EDIT2: For those of you trying this at home: DO NOT RUN THIS IF YOUR CHROOT IS NOT MOUNTED! The fuser command will say, "Oh, I need to kill all processes in the filesystem that the empty /debian directory is in. That would seem to be, um, everything." :eek:

qole 2008-08-10 08:56

Re: Running Debian in a chroot
 
1 Attachment(s)
HOORAY!

Here are even better scripts. I have fixed closechroot so it works every time (thanks Stskeeps!), and, thanks to a new USB drive, I finally cleaned up the external device mounting routine in debian; now it gets the list of devices mounted under /media and mounts them all in Debian, creating the directory if needed first. I believe that this closes the "FIXME" that Benson put on this section of the script.

Code:

#Any external devices
  MNTD=`cat /proc/mounts | grep ' /media/' | awk '{print $2}'`
  for MDRV in $MNTD ; do
    if [ ! -d "$CHROOT$MDRV" ] ; then
      mkdir "$CHROOT$MDRV"
    fi
    mount -o bind "$MDRV" "$CHROOT$MDRV"
  done

For the sake of completeness, I've included the /home/user/.chroot file, too, so in theory you can untar this as root into your root directory, and you are good to go.

Everything I said above applies here, too:
Quote:

Originally Posted by qole (Post 211922)
The big news is that the chroot script is now BOOTABLE-DEBIAN-SAFE.

I have taken out all of the file copy commands and put them into a separate script, called "synchroot" which makes a unique backup of all copied files. This script is only run when the user creates an empty file called ~/.synchroot (which is deleted when the script completes). This way, the files are only copied into the chroot when the user requests it, which may be never, in the case of those with custom setups.

This will allow you to chroot into your OS2007 partition, for example, or into your bootable beta3 partition, without worrying about copying over any files. All you do is modify your ~/.chroot file.

I have also included a closechroot script, which closes all chroot apps and unmounts the chroot. This is useful for changing chroots, etc.

This also includes Benson's fixed debbie script.


qole 2008-08-10 19:31

Re: Running Debian in a chroot
 
I guess the next thing to do is make the debian script check to see if $CHROOT and other variables are already there (perhaps set before running the script), and if they are, use those values. It would need to be crafted such that you could define one or more variables and only undefined variables are retrieved from the ~/.chroot file. However it is done, it would have to also be integrated into the closechroot script... Also, the "chroot-complete" marker file would have to be chroot-specific, so the debian script will properly mount multiple chroots.

I would like to be able to do something like:
Code:

sudo 'CHROOT=/debian IMGFILE=/dev/mmcblk0p4 debbie iceweasel'
This would run Debian Iceweasel.

And then, later, I could do...

Code:

'CHROOT=/os2007 IMGFILE=/dev/mmcblk0p3 debbie xmame froggers.zip'
This would run my OS2007 version of xmame to let me play frogger... :D

qole 2008-08-11 19:29

Re: Running Debian in a chroot
 
Ok, found another problem... Tried to use the scripts to mount the internal flash. It doesn't know the jffs2 file system type, so it falls back to ext2. Sigh...

WORKAROUND: mount the partition ahead of time, then run the script. It fails to mount, but it is already mounted, so the chroot proceeds as normal.

midwinter 2008-08-12 00:35

Re: Running Debian in a chroot
 
Hi all. I'm trying to track down some digitizer errors (presses not registering, presses registering in the wrong place) and would like to uninstall Debian. Can I just do it through the application manager, or do I need to do anything fancy?


All times are GMT. The time now is 10:28.

vBulletin® Version 3.8.8