Posts Tagged Linux

Linux Networking

Posted by on Tuesday, 7 April, 2009

OK Quick and dirty here.
If unsure of your network card you need to do

lspci

This will spit a lot of crap that looks like

0000:00:00.0 Host bridge: ATI Technologies Inc RS200/RS200M AGP Bridge [IGP 340M] (rev 02)
0000:00:01.0 PCI bridge: ATI Technologies Inc PCI Bridge [IGP 340M]
0000:00:02.0 USB Controller: ALi Corporation USB 1.1 Controller (rev 03)
0000:00:06.0 Multimedia audio controller: ALi Corporation M5451 PCI AC-Link Controller Audio Device (rev 02)
0000:00:07.0 ISA bridge: ALi Corporation M1533 PCI to ISA Bridge [Aladdin IV]
0000:00:08.0 Modem: ALi Corporation M5457 AC'97 Modem Controller
0000:00:0a.0 CardBus bridge: O2 Micro, Inc. OZ6912 Cardbus Controller
0000:00:0c.0 FireWire (IEEE 1394): Texas Instruments TSB43AB21 IEEE-1394a-2000 Controller (PHY/Link)
0000:00:10.0 IDE interface: ALi Corporation M5229 IDE (rev c4)
0000:00:11.0 Bridge: ALi Corporation M7101 Power Management Controller [PMU]
0000:00:12.0 Ethernet controller: National Semiconductor Corporation DP83815 (MacPhyter) Ethernet Controller
0000:01:05.0 VGA compatible controller: ATI Technologies Inc Radeon IGP 340M

Most of this isnt really needed, just look for the line that refers to Ethernet or network controller like this

0000:00:12.0 Ethernet controller: National Semiconductor Corporation DP83815 (MacPhyter) Ethernet Controller

Now you need to find the module for that network card driver, a list of available modules are found like this

ls /lib/modules/`uname -r`/kernel/drivers/net/

When you probe a module/driver you need to leave off the .ko or .o at the end so it looks like this

modprobe natsemi

natsemi is the driver i need for my national semiconductor network card. If its sucessful then it will either exit cleanly or give you a message, if it errors then try another one.
to find out system messages you can run

dmesg

This is verbose but you only really need to pay attention to the last few lines really to see if it found your network card.
Once this is sucessful you need to give that network card an IP

ifconfig eth0 10.40.1.7

This will set the ip of the interface eth0 to 10.40.1.7. Feel free to use another ip 🙂
You can view the network status with

ifconfig eth0
inet addr will hold the magical IP number.
Now to add a default route to use the gateway.

route add default gw 10.40.1.254

This adds the ip 10.40.1.254 as my default route/gateway.
You can view the default routes by typing

route -n

Now to set up DNS resolving.
Find your favourite editor (probably nano,pico,joe.mcedit for newbies) and edit /etc/resolv.conf
Note: its resolv.conf NOT resolve.conf (that e can leave you in a world of pain if you add it in 🙂 )

It should look something like this

nameserver 219.88.241.110
nameserver 210.55.12.1

Now feel free to use my nameserver (the first) and im fairly sure Orcon (the second IP) dont mind you using theirs, however its probably a good idea to call your ISP and ask the ip of their nameservers and use theirs.

You should have working internet access at this point in time.
Now as soon as you reboot your settings will be gone (except for resolv.conf)
Most distros of Linux have a place to keep these, and each distro its a different one.
Debian based systems:
edit /etc/modules and at the bottom add in a single name of the module you used that work
ie
natsemi
This will now load on boot.
for network you would edit /etc/network/interfaces
it should look something like this

auto lo eth0
iface lo inet loopback
iface eth0 inet static
address 10.40.1.7
netmask 255.255.255.0
broadcast 10.40.1.255
gateway 10.40.1.254

The auto means that its loaded automaticly on boot, lo is localhost/loopback.
Use your own ips and network settings.

Redhat based systems generally have network in /etc/sysconfig/ somewhere (been a while since i used them)

Other systems use other methods but generally all keep the config settings in /etc somewhere.

Last-Modified: 2007-03-07 19:38:50


Kernel

Posted by on Tuesday, 7 April, 2009

To make a new kernel you will need to know a few basic commands.

Firstly go to your local kernel.org with an ftp client and grab a kernel.
There are a lot of choices so heres a simple run down of them.

2.2.xx is the 2.2 series and stable and usually gets the job done
2.3.xx is the development one and probably if this is your first time best to leave
2.4.xx is stable again and good for obscure hardware or other drivers you may need.
2.5.xx is unstable/testing/development (as are all the odd ones – even numbers are stable) 2.6.xx is stable again, and generally is the more used one currently.

I use 2.4 so I will use this as a demonstration.

Once you have saved your kernel put it in /usr/src .
This doesnt have to be the set directory this is just the USUAL place one would use.

So now apon ls you will see something like this

wishes@chary:/usr/src$ ls
linux-2.4.20.tar.bz2
wishes@chary:/usr/src$

(You may have the suffix .tar.gz which is fine)
Now you need to decompress this use tar jvxf linux-2.4.20.tar.bz This varies system to system – I use debian. If j doesnt work try I.
If you have a .tar.gz use tar zvxf linux-2.4.20.tar.gz .

Now you should have a directory called either linux or linux-2.xx.xx (x meaning some number version of your kernel)
If it is linux use mv linux linux-2.xx.xx so you know which kernel is which later on should you change.
then link ‘linux’ to linux-2.xx.xx with the command

ln -s linux-2.4.20 linux

Okay now you have decompressed your kernel. Follow these commands.


cd linux
make menuconfig

(Often debian comes without libncurses so you will need to ‘apt-get install libncurses5-dev’)
If you are not sure what to do here just leave it as default as possible as most of the defaults are good.
Use the space key for an [M] or [*]
[M] Means its built in as a module so you can load it on the fly once running the new kernel
[*] Means its built into the kernel.

Each person does their own thing. If I’m using it all the time like a network card i build it in. If i only use it sometimes I will load it as needed as a module.

Use the arrow keys to move your away around and if not sure click on the Help.

Once you have configured your kernel you need to exit and save your config.

There are numerous ways of compiling the kernel I find this is the fastest and easier to recall than running them all at once.

make dep clean modules modules_install bzImage
(for 2.6.x kernels you can drop the ‘dep’ off it)

Some people prefer

make dep && make clean && make modules && make modules_install && make bzImage
(for 2.6.x kernels you can drop the ‘dep’ off it again)

If this errors out check the error message properly and see if you can work out what caused it and perhaps change that in the kernel config.

If this finishes cleanly then do a

make install

This should install the kernel to /boot

What Should be in boot?

Check that /boot/vmlinuz is a link to vmlinuz-2.4.20 (or whatever kernel name you have)
and /boot/vmlinuz.old is a link to vmlinuz-2.xx.xx (some older version that worked as a backup)

Double check your /etc/lilo.conf to make sure that this points to the correct place. If using grub check the /boot/grub/menu.lst
If running Lilo, just rerun it (typing lilo at the prompt)

Happy Compiling!

Liz


Boot messages Explained Kernel Messages

Posted by on Tuesday, 7 April, 2009

Most users when inserting a new Linux CD can be somewhat paniced by the verbose text that the kernel spits out. Some distros have a flash screen which hide this and others just let loose.
Dont fret! its only debug so you know whats happening!
After a while using Linux you will be able to understand a bit about what it means or is saying.

The Linux kernel is the central interface between the user and the hardware. As such, it has to incorporate support for hardware if you are to use it. Often, though, cryptic device names are used by the system, making it difficult at first inspection to determine if some particular hardware is supported. The command ‘dmesg’, which is used to print kernel messages, is very useful in determining if a piece of hardware has been found, and if so, what the system is referring to it as.

Kernel output on an i386 system

Shown below is a dmesg from an x86 system immediately after boot. The output is indented by several space, and comments and descriptions are left justified.

    Linux version 2.2.14-5.0 (root@porky.devel.redhat.com) (gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)) #1 Tue Mar 7 20:53:41 EST 2000

First up is the kernel version (2.2.14) and build (5), along with who built it, with what compile it was built, and when it wass built. This can be some inportant information, as some kernel versions and the GCC project don’t interact correctly.

    Detected 300683434 Hz processor.

My K6/2-300 processor running at 300 MHz.

    Console: colour VGA+ 80x25

A standard PC console screen (15 inch monitor).

    Calibrating delay loop... 599.65 BogoMIPS

The useless benchmark of BogoMIPS. They’re bogus (hence the name), but are often used as a relative processor speed indicator.

    Memory: 63008k/65536k available (1084k kernel code, 412k reserved, 968k data, 64k init, 0k bigmem)

My memory statistics. My machine has 64MB of real memory.

    Dentry hash table entries: 262144 (order 9, 2048k)

The dentry cache (dcache) represents the kernel’s view of the namespace of mounted filesystems. There’s pretty good documentation of it in Documentation/filesystems/vfs.txt in the kernel source tree.

    Buffer cache hash table entries: 65536 (order 6, 256k)

In 2.2, the buffer cache is used for caching and aggregating data for writes to block devices. After 2.3.6, it is used for caching fs metadata, such as inode information.

    Page cache hash table entries: 16384 (order 4, 64k)

In 2.2, the page (VM) cache is used for caching swap, read and mmap data (which was bad, because shared writable mappings were ugly). After 2.3.6, it also is used for write data (i.e., the buffer and page caches are mostly unified), and all became happiness and light (sorta like BSD).

    VFS: Diskquotas version dquot_6.4.0 initialized

My kernel support quotas (though I’m not using them).

    CPU: AMD AMD-K6(tm) 3D processor stepping 00

A quick identification of the processor.

    Checking 386/387 coupling... OK, FPU using exception 16 error reporting.
    Checking 'hlt' instruction... OK.

I seem to recall there being some Intel processor issues, which the kernel has to know about if it’s to invoke corrections.

    POSIX conformance testing by UNIFIX
    PCI: PCI BIOS revision 2.10 entry at 0xfb490

And we start the probing of the PCI bus for peripherals.

    PCI: Using configuration type 1
    PCI: Probing PCI hardware
    PCI: 00:38 [1106/0586]: Work around ISA DMA hangs (00)
    Activating ISA DMA hang workarounds.
    Linux NET4.0 for Linux 2.2

This kernel supports the Net4 networking codebase, which has a lot of features yet to be fully utilized.

    Based upon Swansea University Computer Society NET3.039
    NET4: Unix domain sockets 1.0 for Linux NET4.0.
    NET4: Linux TCP/IP 1.0 for NET4.0
    IP Protocols: ICMP, UDP, TCP, IGMP

My core IP protocols supported. While not needed, IGMP can be fun. Note that some networks do not support muticasting.

    TCP: Hash tables configured (ehash 65536 bhash 65536)
    Initializing RT netlink socket
    Starting kswapd v 1.5
    Detected PS/2 Mouse Port.

Should be quite obvious…

    Serial driver version 4.27 with MANY_PORTS MULTIPORT SHARE_IRQ enabled
    ttyS00 at 0x03f8 (irq = 4) is a 16550A
    ttyS01 at 0x02f8 (irq = 3) is a 16550A

The information about my serial ports.

    pty: 256 Unix98 ptys configured
    apm: BIOS version 1.2 Flags 0x07 (Driver version 1.9)

My motherboard supports the APM standard for sleeping.

    Real Time Clock Driver v1.09
    RAM disk driver initialized: 16 RAM disks of 4096K size

My kernel supports RAM disks. While I’m not using any most days, sometimes I do use them; if you have the memory, they make a real fast filesystem (like /tmp or, for a webserver, the main pages loaded).

    VP_IDE: IDE controller on PCI bus 00 dev 39
    VP_IDE: not 100% native mode: will probe irqs later
    ide0: BM-DMA at 0xe000-0xe007, BIOS settings: hda:DMA, hdb:DMA
    ide1: BM-DMA at 0xe008-0xe00f, BIOS settings: hdc:DMA, hdd:DMA

My IDE controllers.

    hda: Maxtor 51369U3, ATA DISK drive

My hard drive in the machine.

    hdb: IDE/ATAPI CD-ROM 32X, ATAPI CDROM drive

My CDROM drive.

    ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
    hda: Maxtor 51369U3, 12949MB w/2048kB Cache, CHS=6577/64/63
    hdb: ATAPI 16X CD-ROM drive, 128kB Cache

Disk information.

    Uniform CDROM driver Revision: 2.56
    Floppy drive(s): fd0 is 1.44M
    FDC 0 is a post-1991 82077

Floppy drive information.

    md driver 0.90.0 MAX_MD_DEVS=256, MAX_REAL=12
    raid5: measuring checksumming speed
    raid5: MMX detected, trying high-speed MMX checksum routines
    pII_mmx : 761.238 MB/sec
    p5_mmx : 726.567 MB/sec
    8regs : 447.675 MB/sec
    32regs : 308.610 MB/sec
    using fastest function: pII_mmx (761.238 MB/sec)

A bunch of RAID and MD (used in multiple device devices, like disk arrays) information, again not used.

    scsi : 0 hosts.
    scsi : detected total.

While the kernel supports SCSI, I’m not using any on this host.

    md.c: sizeof(mdp_super_t) = 4096
    Partition check:
    hda: hda1 hda2 < hda5 hda6 >

My disk partition information. The brackets indicate extended partitions.

    autodetecting RAID arrays
    autorun ...
    ... autorun DONE.

Like I said above, I’m using not using any RAID arrays.

    VFS: Mounted root (ext2 filesystem) readonly.

At this point we’re almost done with the kernel and ready to start the system.

    Freeing unused kernel memory: 64k freed
    Adding Swap: 66488k swap-space (priority -1)
    ne2k-pci.c:vpre-1.00e 5/27/99 D. Becker/P. Gortmaker http://cesdis.gsfc.nasa.gov/linux/drivers/ne2k-pci.html
    ne2k-pci.c: PCI NE2000 clone 'RealTek RTL-8029' at I/O 0xe800, IRQ 11.
    eth0: RealTek RTL-8029 found at 0xe800, IRQ 11, 00:80:AD:41:22:10.

My ethernet device is a PCI NE2000 based device. (A real cheap NIC, but almost every OS supports it.)

    VFS: Disk change detected on device fd(2,0)

At this point, the kernel is done booting and we’re ready to start /sbin/init (unless we supplied some information about init upon boot). The system then starts rc.sysinit and begins normal boot operations. The kernel has finished booting.

Last-Modified: 2007-03-07 19:38:50