Hybrid Linux Distribution Without Emulation

2 02 2007

Introduction

At the end of the year that had just passed, I completed seven years of, good and bad, experiences with linux. The first contact occurred with Conectiva Linux, a national (Brazilian) distribution, which was one of their first versions, 3.0, if I´m not mistaken. Fascinated with this new world, new interfaces and new software, I started to use Slackware, and used it for about 6 years, but because of the lack of time and Patrick´s taste, i´ve decided, after building a good knowledge with Slack, to change the distribution that I use at home.

Discovering new worlds
(no flames!)

Like all problems that we face, I started lookking for a new solution. In this case, I began to try some other distributions, looking for something… more easier to keep. First I tried Debian, I couldn´t make it… I kind of felt a bit bothered using Debian system. I Couldn´t use it for long time, but the way that apt works was really impressive to me, it´s simply, easy and fast. Second try, Ubuntu, but… ubuntu is ubuntu, all that stuff of “general as possible” really bugs me, the “every day” softwares were… slow… it really piss me off. Finally following lot of indications I tried Gentoo, after a long time compiling everything, the reward: wowww what a great performance! Everything is fast on gentoo (you get used to it really fast), but, besides that, the maintenance of the system is virtually impossible, all compilations gives you lot of performance, but just to test a new software, not that I will really use it, sometimes it takes 30 minutes or more, to compile all libraries, and dependencies. If you wanna fell it, try to compile all Haskell stuff!.

The more I tried to keep my system up-to date, the more it looks impossible to do. Every day there are new updates, and some of then lock the “world upgrade” of my system. Part of it is my fault, I didn´t expand much time to find solutions for broken updates. So finally, I tried to find another solution, I was looking for the speed of gentoo (If you use it one time you will never find other distribution that is faster) and, why not, the speed of aptitude, meaning the agility of installing software.

And from there comes the idea of Genbuntu! That is a base system, compiled, generated by gentoo and emerge, while the software that are less used, or do not need a good speed of execution are executed in ubuntu inside gentoo. For sure there are many other ways of doing this, but I chose using this way: Using what I learnt in gentoo installation, I installed Ubuntu and used chroot to bring to Gentoo the Ubuntu softwares.

Hand´s On

In the first try, I simply called:

chroot /mnt/ubuntu /bin/bash

The intention was to get a bash logged on my Ubuntu partition. It worked. It was exactly that what I needed, but lot of things weren´t working right. After some research (I mean google) I “wrote” a small bash script that gives me a functional console of ubuntu inside the Gentoo system. Done that I could run any console program from Ubuntu on Gentoo.

mount -t proc none /mnt/ubuntu/proc
mount -o bind /dev /mnt/ubuntu/dev
mount -o bind /sys /mnt/ubuntu/sys
mount -o bind /tmp /mnt/ubuntu/tmp
chroot /mnt/ubuntu /bin/bash

Fine, With the base system (/dev /proc /sys and /tmp) replicated on both root mount points ( “/” and “/mnt/ubuntu”) I could run any Ubuntu console software into Gentoo, but what about showing the graphical softwares that uses xorg? Every time I tried to run one of these softwares, I got a

** CRITICAL **: Unable to open display

So using xhost and mounting /dev/pts I allowed that local Ubuntu softwares were exhibited in my own Gentoo xorg server, so finally I could run a console mostly functional from Ubuntu on Gentto and run, from it, synaptic, gimp, <choose your software here>.

#!/bin/bash
mount -t proc none /mnt/ubuntu/proc
mount -o bind /dev /mnt/ubuntu/dev
mount -o bind /sys /mnt/ubuntu/sys
mount -o bind /tmp /mnt/ubuntu/tmp
mount -o bind /dev/pts /mnt/ubuntu/dev/pts
cp /home/fcpn/.Xauthority /mnt/ubuntu/root/
cp /home/fcpn/.Xauthority /mnt/ubuntu/home/fcpn/
xhost +local:root
chroot /mnt/ubuntu /bin/bash
xhost -local:root

The only inconvenient is that I needed to execute everything on ubuntu as root. But for now on, it is limited only by creativity. With chroot, it is possible to run directly any software, for example chroot /mnt/ubuntu xmms. Besides that you can use any other distribution for the non essential softwares as a way that can lead to, maybe, a create a Gentora (Gentoo + Fedora), or Genware (Gentoo + Slackware), or you can just spend your time creating funny names for hybrid distributions = P

Below are some screenshots of using my hybrid system:

emerge + aptitudeSynaptic





Genbuntu

18 12 2006

Introdução

Ao final desse ano serão praticamente 7 anos de experiências, boas e ruins, com linux. Primeiro contanto, foi com o conectiva, que estava em uma das suas primeiras versões, 3.0 se não me engano, fascinado com todo esse mundo novo, novas interfaces, novos softwares migrei para o Slackware, por onde fiquei cerca de 6 ou 5 anos, mas por sua falta de tempo e pelo gosto do Patrick, resolvi, depois de fazer residência no Slack, trocar de distribuição.

Descobrindo novos mundos
(sem flames!)

Como toda crise comecei a testar outras distribuições procurando por alternativas mais práticas. O Debian, foi a primeira distribuição que não consegui me adaptar bem, mas a facilidade de manter o sistema me agradou, e muito. O apt-get (aptitude) é simplesmente fantástico. Ubuntu é ubuntu, mas serve. Finalmente ao final da minha jornada, encontrei o Gentoo, desempenho fantástico, mas a mantenibilidade do sistema é impraticável.

Por mais que eu tentasse manter meu sistema up-to-date não conseguia, sempre novas atualizações, algumas delas travaram toda a atualização do sistema, e por ai vai. Assumo que não me dediquei o suficiente para achar soluções para os updates quebrados. Resolvi então achar outra solução. Precisava de facilidade e, uma vez usuário gentoo, desempenho.

Eis que surge a idéia do Genbuntu! Que seria uma base do sistema compilada, gerada pelo gentoo+emerge e programas menos utilizados, que não necessáriamente precisariam de um desempenho grande, executados no ubuntu mas pelo gentoo. Com certeza existem N outras soluções para esse “problema” mas resolvi abordar dessa forma. Usando o que aprendi na instalação do gentoo, escolhi instalar o Ubuntu e usar o chroot para trazer para o gentoo os softwares instalados no Ubuntu.

Mão na massa

Na primeira tentativa, usei simples e cru:

chroot /mnt/ubuntu /bin/bash

A intenção era conseguir um bash logado no ubuntu. Sucesso, basicamente era exatamente isso que eu precisava, mas várias coisas não estavam funcionando direito. Depois de alguma pesquisa “escrevi” um pequeno script que me dá um terminal funcional do Ubuntu dentro do Gentoo, a partir deste posso rodar qualquer coisa dentro do ubuntu estando no Gentoo.

mount -t proc none /mnt/ubuntu/proc
mount -o bind /dev /mnt/ubuntu/dev
mount -o bind /sys /mnt/ubuntu/sys
mount -o bind /tmp /mnt/ubuntu/tmp
chroot /mnt/ubuntu /bin/bash

Com agora a base do sistema (/dev /proc /sys e /tmp) replicada em ambos os pontos montados “/” e “/mnt/ubuntu”, podia fazer praticamente qualquer coisa no ubuntu que o mesmo funcionava perfeitamente, faltava então conseguir exibir os softwares rodados no ubuntu no Xorg do gentoo. Usando o xhost, liberei o acesso a mim mesmo em meu X, exportando os /dev/pts consegui finalmente fazer um sistema híbrido com ambas as distribuições rodando ao mesmo tempo. A versão final do script ficou:

#!/bin/bash
mount -t proc none /mnt/ubuntu/proc
mount -o bind /dev /mnt/ubuntu/dev
mount -o bind /sys /mnt/ubuntu/sys
mount -o bind /tmp /mnt/ubuntu/tmp
mount -o bind /dev/pts /mnt/ubuntu/dev/pts
cp /home/fcpn/.Xauthority /mnt/ubuntu/root/
cp /home/fcpn/.Xauthority /mnt/ubuntu/home/fcpn/
xhost +local:root
chroot /mnt/ubuntu /bin/bash
xhost -local:root

O único inconveniente é ter que executar tudo no ubuntu como root. Porém dai por diante, só a criatividade é o limite, com o chroot é possível executar qualquer comando chroot /mnt/ubuntu xmms ou qualquer outra coisa que você queira.

emerge + aptitudeSynaptic

Conclusão

Agora posso fácilmente posso manter meu sistema atualizado, mantendo a base do sistema com alto desempenho e sólida, e nesse esquema de sistema híbrido pretendo ficar um bom tempo. Talvez fazer nova residência no gentoo.

Até mais, Fábio.