[Techtalk] chroot environment

Pat Day patday at sunbirdsystems.net
Mon Dec 20 03:33:13 UTC 2010


On 12/8/10 12:44 PM, Wim De Smet wrote:
> Hi,
>
> On Tue, Dec 7, 2010 at 2:55 PM, Gwen Morse<gwen.morse at gmail.com>  wrote:
>    
>> I want to set up a Playstation 2 emulator (http://pcsx2.net/) on linux
>> (I already have it working on Windows). There is a linux build,
>> however, it doesn't run on 64-bit systems.
>>
>> They suggest setting up a 32 bit chroot environment. My experience
>> with chroot is exactly encompassed by typing it when using a livecd to
>> fix something I've borked. I've never set one up.
>>
>> I'm on Fedora 13 using KDE and I've installed mock and installed the
>> base 386 package for Fedora 12, as well as yum, gnome, and a few
>> libraries the emulator needs. (it seemed easier to use different
>> versions of everything to help keep it all straight). But, I don't
>> really understand what the chroot environment *is*.
>>      
I fully understand wanting to understand, rather than blindly follow, 
knowing I could Really bork things.  So I'd like to elaborate on Wim's 
accounting of chroot.  Because my distro is gentoo, it pretty much 
mandates I understand it or I'd never get the dang thing booted.  So, if 
you please, I will try to explain my experience.

As Wim said, root partition changes during chroot to wherever you have 
mounted the target partition.
/mnt/pcsx2/
/mnt/pcsx2/boot
/mnt/pcsx2/other

Or it might be
/mnt/rh/pcsx2/   for the virtual root system

It is a way to put a root filesystem and its subdirectories into a 
sandbox, for play or experimentation, so you don't clobber the system.

Access to the non chroot environment is restricted.  There are several 
steps to get it working.  chroot is a unix system call.

It is a bit of a fragile little house.  It is easy to un-chroot by 
accident, but getting out properly can be a procedure. I found that 
printing out a list of steps into and out of was very helpful, including 
every last little mount/unmount/, environment update, and cd command.  
Steps you realize are needed for why you can't end the chroot because 
you still have a terminal open somewhere in that bogus subdirectory.  So 
a checklist makes it go always the same each time without a problem, and 
also is about 10 times faster.

And I like to have a temp alias list too, making CL commands easier to 
use in the sandbox.  You will know which ones you like when you get in 
there and try to less a file, list directories, etc.    so make a 
.profile/.bash_profile/.bashrc to copy into the bogus root subdirectory.

http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=2
The actual instructions in chap. 2 are for intel, but mentions amd64 
variations if any.

Here is a link dealing with the specifics of pcsx2 64-bit compile
http://forums.gentoo.org/viewtopic-t-578192-highlight-pcsx2+chroot.html

If that above forum goes away, type "pcsx2 chroot" into forums search 
box to get it again.  There was only one response but it looks good.
The directions for your 32 bit version should be much the same to get 
into your chroot.
For comparison, see this for gentoo.  Differences can be instructive.  
The stages thing isn't relevant here.
But the conditions of the compilation (definitions affecting compiler) 
should apply, and most of the other calls will be relevant.

When I first discovered chroot I thought I'd found the gold.

Hope this is helpful and didn't make it worse.

--Pat










More information about the Techtalk mailing list