[CentOS] HOWTO install CentOS 6 on low memory computer or virtual machine (even 192MB RAM)

Wed Jul 27 09:38:07 UTC 2011
Tomasz Ostrowski <tometzky+centos at prhn.dnsalias.org>

I've managed to install CentOS 6 on a 192MB virtual machine using LiveCD
install-to-disk graphical method.

This is not normally possible because of:
- hard-coded minimum supported memory in Anaconda installer - it will
show a message "You do not have enough RAM to install CentOS Linux on
this machine" if you try or force you to use seriously crippled text
installer;
- a bug in Anaconda installer, which prevents it from using swap during
installation.

I think it would be useful to be able to install CentOS 6 (or Scientific
Linux 6 or RedHat Enterprise Linux - RHEL 6) on low memory old computer
or laptop, as it can be very capable firewall, home www server, proxy etc.

So the procedure is as follows:

1. Boot to 32-bit CentOS LiveCD (CentOS-6.0-i386-LiveCD.iso) in
graphical mode (if you have at least 256MB RAM) or text mode (if you
have less than 256MB RAM).

2. Login as root.

3. Edit a file /usr/sbin/anaconda - using vim in text mode or gedit in
graphical mode - search for "within" and modify function
"within_available_memory" adding a line "return True" like this:
    def within_available_memory(needed_ram):
        return True
        # kernel binary code estimate that is
        # not reported in MemTotal by /proc/meminfo
        epsilon = 15360 # 15 MB
        return needed_ram < (iutil.memInstalled() + epsilon)
This would get rid of artificial hard-coded memory requirement.

4. Edit a file /usr/lib/anaconda/storage/__init__.py - search for 4th
occurrence of "swapoff" and modify a fragment of function
"umountFilesystems" from:
    for device in devices:
        if not device.format.mountable and \
           (device.format.type != "swap" or swapoff):
           continue
to:
    for device in devices:
        if not (device.format.mountable and \
           (device.format.type != "swap" or swapoff)):
           continue
(add parentheses - left one after "if not" and right one after "or
swapoff"). This would fix a bug in installer.

5. Run "liveinst" which should start graphical installer.

6. During installation create swap partition so that you have at least
1GB of available memory (RAM+swap) (default setup should suffice, but I
personally do not recommend it as it used LVM, which AFAIK prevents
disks from using barriers).

The bug is reported upstream:
https://bugzilla.redhat.com/show_bug.cgi?id=708966 but for Fedora Linux.

Regards
Tometzky
-- 
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
                                                      Winnie the Pooh