How To Install Gentoo Onto Any OpenVZ VPS

2012-11-17 19:46 - Linux

I recently found a great deal on an OpenVZ VPS after lurking on lowendbox.com for a while. At least for a while I plan on mostly using it for backup purposes while I judge its reliability. But I want to run Gentoo on it! This isn't perfectly straightforward. OpenVZ is based on OS "templates" and they provide some precreated ones. The only Gentoo options are contribs, and as far as I can tell, they don't work. I spent a while working on my own which mostly works, but has a few niggling issues that I couldn't work out completely, at least at first.

Then I remembered reading about installing Gentoo from another distribution. Existing tutorials like that assume partitioning, which makes no sense in OpenVZ. But it was the catalyst to help me realize: all I need is the right files in the right layout! So I gave it a shot and it worked. I used a lot of information from the Gentoo template creation wiki page; but much of it is out of date; the Physical to container wiki page was also helpful.

I did this once by the seat of my pants, but now I'm repeating it with a local OpenVZ host (in its own virtual machine!), so I can write the steps down this time. That way they're available if I want to repeat them in the future, and if anyone else finds it useful. Start by installing something that is notGentoo into your container; I'm using Debian 6.0.

For completeness, on the host I start with debian-6.0-x86.tar.gz (the precreated template as linked above) in /vz/template/cache/. I assume that your selected VPS host will be able to install this for you, or you can through a control panel. Then create and start the container with:

Now it's time to get Gentoo running! We've got a working non-Gentoo OS installed in the guest. From now on, we are only acting within the guest -- as if this was a VPS from a third-party provider, and that's the only access we have. The above was just to set up a test environment to emulate that.

We start with a stage3 release tarball. Download one to /root from a local mirror and then run this script:

The one problem is to make sure the network is set up correctly. There's two possibilities here:

  1. If you have control of the host node, or cooperative people in charge, you can simply set OSTEMPLATE="gentoo" in the appropriate configuration file in /etc/vz/conf/. This sets all the appropriate files' contents when your VPS is starting.
  2. If not, you'll need to bootstrap the network settings yourself. This is the standard "Networking Information" subsection of the "Configuring your system" section of the Gentoo handbook, make sure /etc/conf.d/net is set up properly.

Now you can reboot and your VPS should be running Gentoo! Install a portage snapshot (section 5c) and then continue from "System Information" in section 8c of the Gentoo handbook. And clean up all the files left in /root/.

Take note of OpenVZ bug 1812. If the container has bash 4.2 or higher (which this version of Gentoo does by default), then vzctl enter will fail, with vzctl versions before 3.0.26.2. Up-to-date debian host nodes will have 3.0.24, which fails. (Yeah, it was fixed over a year and a half ago, but Debian updates glacially. My first attempts here were on Debian, and it took a while to figure out that this was why vzctl enter was failing.)

Comments:

Udev-pocalypse
2013-04-29 20:39 - arantius

Gentoo is updating udev, to require certain kernel settings, which openvz host kernels do not set. The solution is basically just don't use udev: http://nikolauspolak.info/en/blog/2013/03/gentoo-openvz-guest-udev-problems.

Post a comment:

Username
Password
  If you do not have an account to log in to yet, register your own account. You will not enter any personal info and need not supply an email address.
Subject:
Comment:

You may use Markdown syntax in the comment, but no HTML. Hints:

  • An empty line between text will create a paragraph boundary.
  • Use angle braces around a plain URL to auto-link it: <http://www.example.com/>.
  • Use this format to create a link with different text showing: [An Example](http://www.example.com/).
  • Use backticks (``), not leading spaces to enclose a code block.

If you are attempting to contact me, ask me a question, etc, please send me a message through the contact form rather than posting a comment here. Thank you. (If you post a comment anyway when it should be a message to me, I'll probably just delete your comment. I don't like clutter.)