Sunday, January 31, 2010

Custom Lightweight Ubuntu Installation How-To - Part 1

In this how-to, we'll go over the task of installing a very lightweight Ubuntu-based Linux system, tailoring it for speed and, more importantly, small size. It is based on standard Ubuntu packages and repositories, and with an installation footprint of about 1GB, memory usage in the range of 150MB, it is perfect for UMPCs and even laptops.
However, this isn't a 5 minute tutorial. There are many steps, and it involves using the terminal in more than one situation. Each step will be well documented, and because of that I decided to keep to break the tutorial into three parts: installing a minimal Ubuntu core system, fitting an X server with a window manager (openbox) in it, and installing the other applications.
Jigsaw Ubuntu Logo

Without further ado, let's see what how we can go from some empty hard drive space to a tiny, and pretty useless at this stage, Ubuntu system.

  1. Getting a bootable installer
    If you haven't guessed from the description, we will base this system on the Ubuntu Minimal CD. Grab a copy of it from the Ubuntu Community Documentation page. Since the instructions presented here are pretty generic, you can even choose an older version if you feel more comfortable that way, although we recommend the 9.10 "Karmic Koala" ISO.
    Now that you have the installer, go ahead and burn it on a CD or, considering the small size and the fact that many netbooks don't have an optical drive, an USB flash pen. Unfortunately, the Ubuntu USB Startup Disk Creator doesn't seem to work with the Minimal CD, but Unetbootin does a stellar job, and it's straightforward to use.

  2. Booting it up and starting the installation process
    Now that you have a bootable medium, start the target computer from it, either by plugging it in and hoping that it will run, or by setting the specific BIOS options and making sure that it will boot. If everything goes ok, you will be presented with a boot: prompt - just press enter. Now the Installer boot menu will appear, with the Install entry already highlighted - another press of the return key and we're underway.

  3. Language and location settings
    You probably remember from the graphical Ubuntu installation that the first steps are related to the regional settings of the new system. This ncurses-based installer is no different, so it will ask you to select the language (locale). If you are comfortable with English and you want to save up some space, pick the C - No localization entry, otherwise choose the one corresponding to your native language.

    Next up - picking the place you live. Note that this isn't some sort of personal data collection trick, the installer will use that information to set the proper time zone for the system clock. If you went into the submenu for the wrong continent/area, just press the TAB key so that Go Back will be highlighted, and confirm with enter.
    You will then be inquired about your keyboard layout. I find that choosing it from a list is quicker, so I chose NO at this step, but it doesn't really matter which method you will want to use.
    After dealing with the keyboard layout, the console character set will demand your attention. If you don't really need to read/write characters in your native language from a terminal, go with the default setting. Otherwise, pick the one that matches your language best.

  4. Network setup
    The installer will now ask you to enter a hostname. If you don't want to integrate your computer into a home or work network, or you are happy to use IP addresses instead (like me), just enter whatever you wish in the text box, as long as it is all small caps, no spaces and it doesn't start with a number.

    Once the hostname business is sorted out, the installer will try to connect to your home network and adequately detect the system IP and gateway. Those are needed so that the required packages can be downloaded from the Ubuntu package repositories. You weren't actually believing that a whole Ubuntu base system can be crammed in 12MB - this is not TinyCore, you know... If you do have a DHCP-enabled router, everything will go smoothly and no intervention will be required from you. Otherwise, you will need to provide a system IP, a DNS server and a gateway.
    One more detail to set up, and we can move on to partitioning: picking an Ubuntu archive mirror that can give us the best download speed. Probably the best option here will be already highlighted, based on your country selection. If you know that one of the alternatives is a better choice, just navigate the list and choose it.

  5. Partitioning
    After downloading some packages, the disk partitioning will need to be sorted out. If your computer is new or you don't really care about saving the data that is already on your hard drive, you can pick the Guided - use entire disk entry. Since we are going for a highly optimized system, the Manual mode will allow us to make the most of our hard drive space.
    Selecting the proper hard drive to partition can be a little tricky if you are installing from USB, or if you are on some ASUS EEE models that have two drives (a 4GB faster SSD and a slower 16GB drive connected to the Mini PCI-E slot). So pick your drive, and confirm with enter. If your computer is new, you will be asked to confirm the creation of a new partition table on the device. That is a necessary step in preparing your computer to receive an operating system, so you will need to select Yes to continue.

    Let's talk partitions. If you have plenty of space, you'll want to create a swap partition that is at least as large as the quantity of RAM currently installed on your computer, as that will enable you to use hibernation for the installed OS. If you're on a netbook with a limited amount of storage, create only a data partition. Unless you have other operating systems installed, make all partitions primary, otherwise you may need a more complex partitioning setup, using logical partitions. Don't forget to set the Mount point to / and the Bootable flag to on for your data partition.
    Another good idea of you are on a solid-state drive is to set Use as to Ext2 file system and at Mount options to check noatime. My setup looks like this:

    Once you are happy with everything, go to Finish partitioning and write changes to disk, then confirm.
  6. User setup
    After the installer will download some other base packages, it will ask you to enter your name. Insert your name there, or whatever else you see fit. Next up - the username. Keep it simple, as you will need to enter it everytime you log in.

    The insert a password, preferably longer than 8 characters and which contains a mix of upper and lower case letters. If your password is shorter, the installer will warn you of that, but you can choose to continue.
    Next you will be given the chance to encrypt your home directory. This is especially useful for laptops, which are more prone to being misappropriated. You will also need to consider the fact that encryption will shorten your battery life, as it requires more processing power to move data around. Choose accordingly to your needs.
  7. Automatic updates
    Update management is another important step to consider, from a security and stability standpoint. The installer will give you two applicable settings, as the Manage system with Landscape requires a dedicated server in your network. If you want to manage updates yourself, or if you won't have stable internet connectivity, choose No automatic updates.

  8. Software selections
    Looking through the options presented in the Software selection, you will observe that most of them are server oriented. The trick here is that we will continue without actually selecting anything. This way we will be left with only the base operating system, atop which we can add any packages we like, using apt later on.

  9. Last steps
    Before finishing the installation process, you will need to set whether your system clock will be set to the UTC time (GMT), or to your local time zone. If you want a dual boot setup with Windows as an alternative OS, pick No here.

    That's it, you will be warned to remove the bootable media and by pressing Continue your system will be restarted.

Let's check out the newly installed system. You will notice that it does not have a graphical medium, not even a login screen, and that is ok. Starting off with this bare system, we will be able to add on top of it an X server, a window manager and all the necessary applications.
Right now, it all weighs in at 681MB, probably a little different on your installation if you chose different localization options.

Head over to part 2, in which we will add an X server, making sure that only the necessary components are installed. Then we will configure the openbox window manager on top of that, add a dock and some generic commodity software.

1 comment: