# chroot instead of kvm

## depontius

Is there some simple way to chroot into a KVM guest image, instead of virtualization?

My work laptop now has 5 OS installs.  It came with WinXP, and I've installed Gentoo, a company-tweaked Fedora Core 13, and a company-tweaked RedHat 6.  But nearly all of the job-related software I need to run is design around the company-tweaked RedHat 5 - and ONLY that release.  In days of yore, principally back when The Platform was RedHat 4.x, I could work around it.  But since the migration to RedHat 5 they've put teeth into the applications software platform detection, and made it harder to work around.

Side note...  The laptop is a Thinkpad W510 - really too new for RedHat 5 to install or run gracefully - at least natively.

The RedHat 5 requirement is so stiff that even RedHat 6 doesn't work for these applications.  So yesterday I installed a RedHat 5 KVM image on the machine.  There are rough edges, even at the basic level.  I don't have networking really working yet, but that's probably a matter of plugging away.  But I'm struck that virtualization is a very heavy solution, and destined to become even heavier as I get the extras needed for full functionality - things like OpenAFS, etc.

Question 1:  Once I have this RedHat 5 image running from RedHat 6, how much trouble would it be to install the KVM stuff in Gentoo and run it from there, instead?

Question 2: I'd really rather just chroot into the RedHat 5 install instead of virtualizing.  After all, it's Linux-on-Linux, not Windows-on-Linux, and it's not really a security issue in this case.  On RedHat 6 someone suggested "guestfish" and I've tried it out, but that only lets you inspect/update the image, not chroot into it.  I guess if it came down to it, I could start the KVM and rsync the whole image out onto my regular disk, but I was looking for something a little simpler.

Software strategy has been pushing me off of Gentoo, but if even my normal work requires virtualization/chroot, it seems I could move my main boot and desktop back to Gentoo, using the virtualization/chroot for the CAD software I need to run.

----------

## Sadako

1; You mean using gentoo as the host?

Should be very simple, only tricky bit might be replicating the network setup that you eventually get set up on your current host, but once you figure out how to di it yourself on Red Hat you should more or less know how to do it on gentoo too, tools are the same.

2; The image should be mountable via a loop device, but if it's anything other than a raw image you'll need to figure out where the filesystem within the image starts, or the mbr if partitioned, and provide that as an offset to losetup.

Make a backup before trying, though.  :Razz: 

----------

## depontius

 *Sadako wrote:*   

> 1; You mean using gentoo as the host?
> 
> Should be very simple, only tricky bit might be replicating the network setup that you eventually get set up on your current host, but once you figure out how to di it yourself on Red Hat you should more or less know how to do it on gentoo too, tools are the same.

 

Yes.  I've been using FC13 since getting the W510 and it has worked.  But the most recent rev of the CAD tools is very picky about having RH5.  Since my W510 is too new to run RH5 well, I've been making do with FC13 and recently started playing with RH6.  But both of those only work with older tool revs, not the newest stuff I need for non-legacy work.  If I'm going to have to work in a VM or chroot anyway, then I'd just as soon host that from Gentoo as from FC13 or RH6.

Besides, recently my FC13 install has started having DNS problems with all Mozilla products - fireox, thunderbird, and I did a quick install of seamonkey.  None of them can reach a host by name, only by numeric IP.  Even if I reach a website by numeric IP, it's highly likely that that site will make other references by name, if even to itself.  I did some probing with wireshark, and see no sign of DNS requests going out, and I'm not sure why.  Then Monday Lotus Notes started apparently having the same problem.

Add to that the fact that the rpmfusion repository isn't yet available here for RH6, which means that I'm missing some other tools that I consider pretty important.

It has been a frustrating week, and at the moment I don't have a fully workable solution other than to ssh into someone else's machine.  The RH5 VM/chroot just might be the solution, and if that is the solution I see no particular reason why it shouldn't be under Gentoo instead of FC13 or RH6.

 *Sadako wrote:*   

> 2; The image should be mountable via a loop device, but if it's anything other than a raw image you'll need to figure out where the filesystem within the image starts, or the mbr if partitioned, and provide that as an offset to losetup.
> 
> Make a backup before trying, though. 

 

As best I can tell I have a ".raw" file and it appears to have 3 partitions on it.  / is /dev/vda3, /boot is /dev/vda1, and I'll presume that /dev/vda2 exists and is swap.  With what you say in mind, I'll copy the KVM image over to my Gentoo partition and play with that, there.

----------

## zeek

What you want describes OpenVZ and VServer.  Have you looked at either of those solutions?

----------

## depontius

Not really.  I've heard of them, but figured that they're both virtualization options, and heavier than I'd ideally like to use.  I guess I can look them up, thanks.

----------

## Goverp

 *depontius wrote:*   

> Not really.  I've heard of them, but figured that they're both virtualization options, and heavier than I'd ideally like to use.  I guess I can look them up, thanks.

 

I used VServer a couple of years back to host two incompatible versions of IBM MQ server in two different VServer clients on the same laptop.  It works very well for that.  Of course, you're using the same kernel in the host and VServer systems.  I wonder whether that would trigger your application's platform detection.

If you do try VServer, I recommend enabling all the options as per the Gentoo VServer HowTo.  When I used it, I ignored some apparently optional features (I forget what) and regretted it.

----------

## Goverp

Following some links from the developer blogs on the Gentoo home page, I found a description of "linux containers" (lxc) in the Gentoo wiki.

It says that lxc supersedes VServer and OpenVZ.  I certainly recognize much of the configuration stuff from my VServer usage.  If I were looking for a chroot virtualization now, lxc looks to be the place to start.

----------

