2008/05/13

The Labs.Com OS Lab Linux
Last update 2005/01/03
The Labs - Design & Functionality For The Net

Linux Resources & Hints

  1. Introduction
  2. Distributions
  3. Tuning
  4. Filesystems
  5. Virtual Domains
  6. Kernel
  7. Linux In Linux (Virtualizing)
  8. Live-System Install
  9. Resources
Linux
1. Introduction
RedHat and SuSE distribution brought Linux real mainstream exposure in 1998 and 1999, since then Linux-distribution got the acknowledgement in the server-market as well on the desktop-world, yet there it still has to catch up, specially in regards of devices drivers, which is unfortunatly a matter of device developing companies to also support Linux.

I personally ran it for servers and workstation but since May 2000 only on some dedicated machines where Linux is required such as

otherwise for servers and workstation I prefere nowadays FreeBSD, even for workstation purposes, it is just more convienent: install, upgrade apps or kernel, performance and overall system-integrity.

Linux
2. Distributions

Something many people aren't aware, Linux isn't a complete Operating System as such, it is just the kernel. Every distribution developed its own UNIX-like disk-layout arround the Linux-kernel. In this light, Linux "suffers" from this diversity:

RedHat
 RedHat is probably best known from all distributions, but this actually doesn't mean anything about quality necessarly, it is average.
RedHat.Com
RedHat's site

SuSE
 SuSE is very well known in Europe and provides the largest collection of compiled packages installable from the CD, which is very handy to save download time. Comperable with RedHat-distribution.
SuSE.Com
SuSE's site

Debian
 Debian is a non-profit undertake with support of packages. The installation isn't that user-friendly (as of version 2.2, and even 3.0) as no hardware is recognized automatically as SuSE or RedHat does, yet the collection of packages make this distribution very valuable over the commercial distributions mentioned above.
Debian.Org
Main site
DebianPlanet.Org
News site

Few things to know after install:

  1. use dselect to explore the available packages, or apt-cache search term; if you run X11 install gnome-apt.
  2. if you are used to *bsd-like port disk-layout, download debports which gives you a nice /usr/ports/ directory-structure, make install, deinstall and clean is supported. Also consider to check linuxports@sourceforge.
  3. if you fail to install .deb files (due missing dh_testdir as example), do apt-get install debhelper.
  4. /etc/apt/sources.list has the sources (cdrom, ftp) of the packages, use apt-get update to get up-to-date package list.
  5. server/client: to share the .deb files export from the server /var/chache/apt/archives/ and also /etc/apt/ to all clients, then at least the packages are shared in common.

Other distributions
 There are other distributions like Slackware and Mandrake (derived from RedHat), each one with its own flavour and features. See the full collection of Linux-distributions.

Download
 
LinuxISO.Org
ISO Images of common Linux distributions
Tiny Linux Dists
micro-dists

IMHO I think the Linux-distributions should unify and provide one or two main-stream distributions in order to become competetive in the entire OS-market. For now SuSE and RedHat are leading, but quality-wise they are far below any *BSD distribution (e.g. FreeBSD) in my eyes: there are no packages (rpm doesn't catch up), there is no comformity between the different dists (fall 2000):

LinuxBase.Org
Standardizing of LINUX
GoboLinux.Org
Completely UNIX directory layout

Linux
3. Tuning

Some fragments I found on the net and discovered by myself:

New Swap Space
 

 % dd if=/dev/zero of=/your/swapfile bs=1024 count=swap_size 
 % chmod 600 /your/swapfile 
 % mkswap /your/swapfile swap_size 
 % swapon /your/swapfile 

Maximum swap_size call man mkswap to read more

Also add an entry in /etc/fstab:

 /your/swapfile none swap sw 0 0  

Open Files
 Edit /usr/src/linux/include/linux/limits.h under Kernel-2.0

 #define OPEN_MAX  1024  /* # open files a process may have */ 

and recompile kernel.

With Kernel 2.2 you can

 echo 32768 > /proc/sys/fs/file-max  
 echo 65536 > /proc/sys/fs/inode-max  

More Files
 

 echo 8192 >/proc/sys/kernel/file-max 
 echo 32768 >/proc/sys/kernel/inode-max 

put it into /etc/rc.d/rc.local

Memory
 Server: Memory is cheap, upgrade it to the max, e.g. 128MB at least, more is better when you run a web-server so swapping is never required in the best case.

Workstation: I use GIMP and PicArt daily, which means huge RGBA images are handled, for that reason I upgraded my workstation to 768MB to have it running smoothly on the Athlon 1GHz (was using PPro 200 with 256MB before).

Mac Disks
 To read mac disks (floppy or zip) under Kernel-2.2 you may acquire:
HFS support
kernel module
compile it, and copy hfs.o into /lib/modules/2.0.xx/fs/ and then call insmod hfs and mount -t hfs /dev/sdb /mnt/zip (as example)

Memory Filesystem (RAM Disk)
 To speed up disk-performance you might copy disk-content on a memory-based filesystem called RAMFS (Kernel-2.4) or RAMDISK (Kernel-2.2), under *BSD system it's called MFS.

Kernel 2.4

You need to have RAMFS enabled in your kernel, and then:

 % mkdir /mnt/mfs 
 % mount -t ramfs ramfs /mnt/mfs 

With kernel 2.4 the memory-fs under Linux grows and shrinks as required like under FreeBSD

Kernel 2.2

You need to have RAMDISK enabled in your kernel, and then /dev/ram* should and then /dev/ram* should exist already, read man ram otherwise. To setup and enable a ramdisk:

 % mke2fs /dev/ram0 
 % mkdir /mnt/mfs 
 % mount /dev/ram0 /mnt/mfs 

The size of ramdisks are define via the kernel, or can be adjusted in the lilo.conf:

 : 
 image=/boot/vmlinuz 
     label=linux 
     root=/dev/hda2 
     ramdisk_size=10000 

Software RAID
 Software RAID is an easy way to connect two or more hard-disks together and improve read/write speed:
Linux 2.4: RAID
How to setup software RAID

Linux
4. Filesystems

Linux has been suffering a real state-of-the-art filesystem as ext2 fulfills the basic needs, but it's a pain to recover once your server crashed (can happen very rarely), but when it happens it just takes forever to bring an ext2-filesystem back into consistancy.

Ext3
 With ext3 you can change any ext2 to ext3 on-the-fly (without reformating the disk):
  • mounted disk: tune2fs -j /dev/hd... does the job, a .journal is created in the root directory of the mounted device
  • unmounted disk: change /etc/fstab the ext2 to ext3, the journal is not seen.
More infos see at Using ext2 fs in 2.4 kernels and Red Hat: ext3 information.

Misc
 
ReiserFS
ReiserFS
JFS by IBM
Journaling FS developed by IBM (opensource)
XFS by SGI
Another Journaling Filesystem (part of SGI's OSS-initiative
Interview With the People Behind JFS, ReiserFS & XFS
Article at OSnews
Realtime Data Mirroring
Linuxfocus article using IBM's FAM (file alteration monitor)

Linux
5. Virtual Domains

Have "IP Aliasing" in kernel enabled (and maybe need to recompile the kernel) then add in /etc/rc.d/rc.local:

 echo "adding virtual homes" 
 /sbin/ifconfig eth0:0 domain2.com 
 /sbin/ifconfig eth0:1 domain3.com 

You may have to add also:

 /sbin/route add -host domain2.com dev eth0:0 
 /sbin/route add -host domain3.com dev eth0:1 

Of course the DNS needs to be valid and resolveable so these additional virtual domains work, check dnstool.

Linux
6. Kernel

A typical linux procedure is to download the most recent kernel and compile it.
Kernel.Org
Archive of all kernels

Extract it in /usr/src/ (usually creates linux/ itself) and then use one of the three choices:

 % make config              # terminal based config (not recommended) 
 % make menuconfig          # terminal based config (recommended, needs ncurses) 
 % make xconfig             # x11 based config (recommended) 

and walk through all options. Then call

 % make dep 
 % make                     # make kernel 
 % make install             # install kernel (check /boot/* and /etc/lilo.conf) 
 % make modules             # make modules 
 % make modules_install     # install modules 

If you ever tried *BSD system, you realize how messy this Linux kernel/lilo thing truly is:

  1. deselect SYMTAB export (one of the first config questions in kernel config)
  2. pay close attention of your /vmlinuz which may point to /boot/vmlinuz or /boot/vmlinuz-x.x.x
  3. keep backup of your existing kernel (e.g. cp vmlinuz vmlinuz.old)
  4. edit /etc/lilo.conf, and run /sbin/lilo as root
Once again we recommend Debian/Linux as it behaves best with a clean UNIX system-layout.

Linux
7. Linux In Linux (Virtualizing)

UML (User Mode Linux) is truly a nice piece of software as it allows to run multiple Linux-kernels and filesystem (guest) within on a Linux-machine (host), a feature mainframes have:
UML (User Mode Linux)
Running Linux in user-mode(space) of Linux; check also UML-user list archive
  1. Download a root-filesystem e.g. root_fs_debian2.2_small
    and make a sym-link

     ln -s root_fs_debian2.2_small root_fs 

  2. Download the UML-kernel e.g. linux-2.4.0-test12
    and execute the kernel

     ./linux-2.4.0-test12 

    login as root (password 'root' too).

The advantage is obvious:

  • great test-bed for other Linux variants
  • fastest virtualization (faster than vmware or plex86)
  • advanced resource accounting: nice the guest-Linux appropriatly on the host
  • true virtualized web-hosting
and beside, it prooves the Linux design being consistant in itself. The file-system is a flat-file and easily be backed-up or moved arround on other machines.

More Infos
 
freeVSD
Virtual Server Deamon (VSD): not really virtualization but 'chroot'ed environments: ssh, httpd, sendmail - solution for ISPs
S_Context: Virtual Servers
Another approach
S/390 & Linux
Good article at LinuxWorld.Com
Linux/390
S/390 mainframe running Linux
Hercules S/390 Emulator
S/370 - ESA/390 emulator for Linux; running Linux/390 on the emulator itself.
LINE
Running linux-binaries under WinXX
FAUMachine
Open Source Virtual Machine
Ensim
Commercial package
Virtuozzo
Linux in Linux, commercial product

Linux
8. Live-System Install

Here the procedure step-by-step for a Debian/Linux-2.2 (for other distributions it may work, but the directory layout may look slightly different) install:
  1. assuming your 2nd disk is /dev/hdc, make two partitions (or more with different mounts) with fdisk /dev/hdc:

        hdc1 280MB type 83 
        hdc2  42MB type 82 (swap) 

    then call

     mke2fs /dev/hdc1 
     mkswap /dev/hdc2 

  2. then transfer Linux live-system to your 2nd disk:

     mkdir /mnt/newdisk 
     mount /dev/hdc1 /mnt/newdisk 
     cd /mnt/newdisk 
     cp -a /sbin . 
     cp -a /bin . 
     cp -a /lib . 
     cp -a /etc . 
     cp -a /var . 
     cp -a /dev . 
     cp -a /sbin . 
     cp -a /usr . 
     cp -a /root . 

  3. and then the special dirs

     mkdir proc tmp 
     chmod 1777 tmp 
     mkdir home 

  4. and the last copying:

     cp -a /boot . 
     ln -s boot/vmlinuz vmlinuz 

  5. as next LILO: edit /mnt/newdisk/etc/lilo.conf, again, my 2nd dist is /dev/hdc, these specs are important:

     boot=/dev/hdc 
     disk=/dev/hdc 
        bios=0x80      # make hdc be hda, useful for our case 
     root=/dev/hda1    # here again the hda referenced 

    this way you can install lilo on /dev/hdc, but it will treat it as hda (see LILO-HowTo), call lilo then like this:

     lilo -r /mnt/newdisk -C etc/lilo.conf 

  6. then edit /mnt/newdisk/etc/fstab:

     /dev/hda1   /          ext2    defaults,errors=remount-ro      0 1 
     /dev/hda2   none       swap    sw                              0 0 
     proc        /proc      proc    defaults                        0 0 

  7. other files to edit:
    • /mnt/newdisk/etc/hosts
    • /mnt/newdisk/etc/hostname
    • /mnt/newdisk/etc/network/interfaces
Then unplug the 2nd disk (hdc) and put it into your other system and look Linux booting.

This "Live-System Install" is particularly useful to install Linux medias like PCMCIA ATA disk, or other medias which aren't supported using the CD-Install (see Stylistic-1000 Linux install).
FAI (Fully Automatic Installation) for Debian GNU/Linux
Installing Linux on a cluster

Linux
9. Resources

NewsForge.Com
Very good tech-news site
SlashDot.Org
News site on open-source stuff mainly
Linux Mall
Buy stuff you need
Linux Gazzette
Online news-magazine
XFree86
Free X-server since Version 4.x becoming the standard
XIG
Reliable x-server only worth to buy when you have an odd graphic card

                                                                                                                                   

OS LabFreeBSD

Last update 2005/01/03

All Rights Reserved - (C) 1997 - 2008 by The Labs.Com

Top of Page

The Labs.Com