How to set up a chroot of one distro within another distro

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
I found something interesting in http://www.leapster.org/linux/redhat/rhel/ that says:

"You don't need a dedicated Fedora system, however - a chroot environment within another distribution will work, too. I compiled my Enterprise system within Fedora chroot on a Debian machine."

This would solve an issue I have where I have two seperate machines, a RHEL4 machine and a RHEL5 machine, set up for compiling packages. Doing this with chroot environments on a single machine would be awesome.

I've tried googling and came up with nothing useful (it's all about chrooting BIND or something like that). Does anyone know how to do this and could point me to some usefull information?
 

QuixoticOne

Golden Member
Nov 4, 2005
1,855
0
0
Sounds interesting, and for something that's more about compatibility than security I can see its place.

Wouldn't it be easier to just use kvm/qemu though and have a second distribution running in a VM?

 

silverpig

Lifer
Jul 29, 2001
27,703
12
81
I'm not entirely sure, but when you install gentoo you boot off the livecd, copy some files to the hard disk, then chroot over. I'd imagine it'd be something similar.

Basically you'd copy most of / over to some directory (or install there), then cd to that directory and do a chroot /new/directory/ /bin/bash and that should be it.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Wouldn't it be easier to just use kvm/qemu though and have a second distribution running in a VM?

Not really, if all you want is to make sure the same versions of compiler, libraries, etc are used then you just chroot to /blah/rhel4 and you're there. Nothing but extra disk space is used since there's no VM running in the background.

I've tried googling and came up with nothing useful (it's all about chrooting BIND or something like that). Does anyone know how to do this and could point me to some usefull information?

With Debian it's simple, as usual, debootstrap is designed to install a fresh Debian system into any target directory since that's how the installer works.

There's also mach and rinse in Debian that claim to do the same things for rpm-based distributions but I've never used them.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Originally posted by: Nothinman
Wouldn't it be easier to just use kvm/qemu though and have a second distribution running in a VM?

Not really, if all you want is to make sure the same versions of compiler, libraries, etc are used then you just chroot to /blah/rhel4 and you're there. Nothing but extra disk space is used since there's no VM running in the background.

I've tried googling and came up with nothing useful (it's all about chrooting BIND or something like that). Does anyone know how to do this and could point me to some usefull information?

With Debian it's simple, as usual, debootstrap is designed to install a fresh Debian system into any target directory since that's how the installer works.

There's also mach and rinse in Debian that claim to do the same things for rpm-based distributions but I've never used them.

Unfortunately, I need to use Redhat. I'm wondering though, if I could just install it to a harddrive, then just copy the contents of / into my chroot folder? I think I'll just give that a try and see what happens.

Originally posted by: QuixoticOne
Sounds interesting, and for something that's more about compatibility than security I can see its place.

Wouldn't it be easier to just use kvm/qemu though and have a second distribution running in a VM?

This is actually what I'm doing now (except using VMWare Server). The nice thing I can see about doing it this chroot way is that they can share harddrive space and ram, and not having the resource overhead of virtualization.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Unfortunately, I need to use Redhat. I'm wondering though, if I could just install it to a harddrive, then just copy the contents of / into my chroot folder? I think I'll just give that a try and see what happens.

That'll probably work, just make sure you use tar/cpio to preserve links, permissions, etc properly.