Wednesday, February 3, 2010

Custom Lightweight Ubuntu Installation How-To - Part 2: Getting Graphical

In part 1 of this how-to, we went over installing an Ubuntu base system, using the minimal (netboot) CD. Picking up from where we left off, in part 2 we will install an X server and the accompanying drivers, the openbox window manager and some other small utilities that make the system more usable, like a network manager.

Since we will be installing a lot of packages from the Ubuntu repositories, you will need an active Internet connection, and it's a lot easier to set up an Ethernet wired one. However, network configuration will be simplified a lot after the installation of the wicd network manager. Enough introduction, let's get this how-to going!
Before everything else, update your repository information, so that you'll be sure to get the latest software:
sudo apt-get update

  1. There is an X Server for everyone
    On Linux, the graphical side of things, along with many input methods, is managed by the Server. That's why our installation will need such a server, and the appropriate drivers for the components in your system. First up, let's get the core set of binaries, and then we'll get to properly supporting all of the hardware.
    sudo aptitude install --without-recommends xserver-corg-core xserver-xorg-input-evdev xserver-xorg-input-mouse xserver-xorg-video-vesa xserver-xorg-video-fbdev xinit

    Some more packages will be automatically marked, but they are necessary for X to work properly.
    Of course, to support your specific hardware better, you will need to install specific drivers. Here is a short list of common video card brands and the corresponding driver installation commands:
    ATIsudo aptitude install xserver-xorg-video-ati
    Intelsudo aptitude install xserver-xorg-video-intel
    Sissudo aptitude install xserver-xorg-video-sis
    Nvidiasudo aptitude install xserver-xorg-video-nv

    Also, if you are on a laptop with a Synaptics touchpad, you will want to install the xserver-xorg-input-synaptics. Wacom tablet users, xserver-xorg-input-wacom is for you.
  2. Installing openbox
    As the window manager we will be using openbox. It's small and flexible, but lightweight. Along with it we'll add obconf, a helper program that can aid in theme selection and fine-tuning of the desktop environment. Just pop this command into the terminal:
     sudo aptitude install --without-recommends openbox obconf

    Once apt does its thing, it's time for a test run, all you need is:

    Right now openbox is barely usable, since there are no GUI programs installed. Choose Exit from the menu, and let's work a little bit on user friendliness.

  3. Customizing openbox
    Since now we know that openbox is running, we can start to tweak it a little. First up, we'll add a few applications like a terminal emulator and a text editor:
    sudo aptitude install --without-recommends gmrun leafpad xterm python-software-properties gmrun

    Now that we have those, let's add a panel. Note that this command does three different things: it first adds a personal package archive, or PPA, that contains a newer version of our panel of choice, tint2. Then it updates the repository information, and after that it installs the software.
    sudo add-apt-repository ppa:killeroid/ppa && sudo apt-get update && sudo aptitude install --without-recommends tint2

    Note for Ubuntu versions older that 9.10 (Karmic Koala): The method above, which relies on python-software-properties, doesn't work on older versions of Ubuntu. You will need to follow the instructions from the tint2 wiki to install. Also, older versions of tint2's executable may be in fact named tint, so you will need to change the commands accordingly.
    Once tint2 is installed, we'll need to create a .config directory in the home folder, or it won't run.
    mkdir ~/.config

    Again, it's testing time, so fire up X (startx), right-click somewhere and click Terminal emulator. Then, just type tint2.
    If you feel that the panel isn't wide or high enough, kill the running tint2 instance (by pressing Ctrl+C), then edit the tint2 configuration file:
    leafpad ~/.config/tint2/tint2rc

    The structure is quite simple to grasp, but if you have any problems you can get some more hints from this page.

  4. Network configuration
    Next up, let's cover the networking. You can just open another terminal emulator and pop this command in it:
    sudo aptitude install --without-recommends wicd

    When apt's run is done, test it by typing wicd-client in the same terminal window. You will see an icon appearing in the tint2 panel, which you can then click to access the main interface of the program.

  5. Making it all work together
    After installing all this software, let's make sure that it will be available and doing its job instead of just existing on the system. Since tint2 and the wicd network manager ar intended to start at the same time with the graphical session and to remain running in the bacground, we need to let openbox know about these programs. We will do that by editing the file that is read and executed by openbox everytime it starts:
    leafpad ~/.config/openbox/

    In that file we will add a couple of lines, then we'll save it:
    (sleep 2s && tint2) &
    wicd-client &

    Now, every time openbox starts up, it will also run tint2 and wicd.
    Back in step 3, we also installed gmrun. This program is a lighweight run box which allows us to quickly start programs by typing a few letters from their name, then pressing the TAB key for autocomplete to kick in. But we won't gain anything is we need to start gmrun from a terminal, that's why we will bind gmrun to the Super+E key combination. For that we need to edit openbox's configuration file:
    leafpad ~/.config/openbox/rc.xml

    Lower down in the file there is a section that looks like this:
    <keybind key="W-e">
      <action name="Execute">
        <command>kfmclient openProfile filemanagement</command>

    We will modify this section to look like this:
    <keybind key="W-e">
      <action name="Execute">

    Save the file, then choose Restart from the openbox menu. Don't worry, this will not reboot your machine, it will only trigger a reload of openbox. Now, when you press Super+E, gmrun will pop up and it will expect a command from you.

    Another thing to sort out would be getting rid of the extra startx command after login, and just going into the openbox environment. To do that, we will edit (or, rather, create) the .bash_profile configuration file in our home folder.
    leafpad ~/.bash_profile

    In it, we'll add a quick snippet of code that issues the startx command only when you login from the local machine. If you will do that through, let's say, and SSH session, thr graphical environment won't start up, which is how it's supposed to happen.
    if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
  6. A few more things
    Any decent computer is able to play music, or just emit annoying beeps from it's speakers. To do that, you need a sound system. So let's install one:
    sudo aptitude install --without-recommends alsa-base alsa-utils

    That way, when we will install a music player, we'll be sure that sound will work.
    Another thing is ACPI, or the Advanced Configuration and Power Interface, if I remember correctly. Basically, this framework allows our operating system to know when you've pressed the power button (way faster than typing sudo halt into a terminal to power off your computer), or to allow tint2 to read the laptop battery's state (you will have to enable that in the tint2 configuration file). So let's install it:
    sudo aptitude install --without-recommends acpid acpi-support

    After a reboot, acpid will be running and waiting for you to press that power button.
  7. Cleaning up
    In part 1 we briefly touched the subject of locales. Even if you did choose the C locale while installing the base system, most packages still contain man pages and localizations. Don't fret, localepurge will take care of those.
    sudo apt-get install localepurge

    After installing localepurge, it will ask us if we want to keep any locales. If you selected something in the base OS installation, it's advisable to pick the same thing over here. Otherwise, just don't select anything. Localepurge will warn us that removing all the locales may be unwise, but you will just have to trust me this time.

    One last command, to clean all the installation files that apt has downloaded, and then we can sit back and look at what we have done until now:
    sudo apt-get clean

So, let's see how this minimal operating system weighs in. In just 730MB we stuffed a Linux kernel with all the userland utilities, sound and networking support and a graphical medium managed by openbox. Not bad, eh?

Stay tuned, because in part 3 we will install all the necessary applications to turn this OS into something that is really usable.

No comments:

Post a Comment