+ -

Pages

Saturday, May 18, 2013

Compile a new kernel in Linux

I did this on OpenSuSE 12.3

Its very easy, if you get everything right - just remember two things:

1. You won't get everything  right the first time
2. The 'make rpm' part takes hours, so plan your day accordingly

Very important: 
You need to get these packages installed successfully before you do anything.
1. GCC (On SuSE - do this: zypper install gcc)
2. ncurses (do this: zypper install ncurses)
3. rpm-build (again do this: zypper install rpm-build)

On fedora/redhat(if you're on RHN) replace zypper with 'yum'

-> Download the kernel from www.kernel.org
Make sure you get a 'not-too-old' kernel, as very old kernel have problems with the latest version of gcc and you'll end up with a lot o errors.

-> copy the kernel to /usr/src amd untar the kernel here.

-> link the kernel symbolically to /usr/src/linux by doing this:

ln -s linux-3.0.1 linux

once you've done this - cd /usr/src/linux

-> run this cmd: make mrproper

-> run this cmd: cp /boot/config-`uname -r` ./.config

-> run this cmd: make menuconfig

A menu will pop-up at this point. In this menu, scroll down to 'Load an alternate config file' and press enter.

Here, '.config' would be highlighted - select this option and save.

Back on the main menu, select General Setup and press enter. Look for 'append to kernel release' here and enter. You can type whatever yo want here and that will be added to the kernel name once it's built.

Save and exit.

-> run this cmd: make rpm
-> go have lunch and dinner with friends and come back

-> hopefully, you should have 2 rpm file now:

one under /usr/src/packages/SRPMS - with the name that you gave it
(mine is /usr/src/packages/SRPMS/kernel-3.0.1_1.1_veenux-1.src.rpm

and another under /usr/src/packages/RPMS/x86_64
(mine is /usr/src/packages/RPMS/x86_64/kernel-3.0.3_1.1_veenux-1.x86_64.rpm

Also, you'll find the headers rpm here, dont worry too much about that at this time.

-> now we create a ramdisk by:
# mkinitrd

Now, we need to load this kernel into the BootLoader and we're set!

Fire up Yast by # yast
->  go to Boot Loader
My SuSE is on Grub2 so all you have to do is go into Boot Loader options and change the selection of default kernel to the one you've built (it should be there in the dropdown) and save and exit.

Restart the machine and it'll load your kernel.



5 RakshaTec: May 2013 I did this on OpenSuSE 12.3 Its very easy, if you get everything right - just remember two things: 1. You won't get everything  righ...

Friday, May 17, 2013

LPIC 1 Topic 101: System Architecture | 101.1

101.1 Determine and configure hardware settings

Enable and disable integrated peripherals

BIOS (Basic Input/Output System) can be used to enable or disable hardware/peripherals. Main hardware components that are managed by the BIOS are ATA HDD interfaces, I/O addresses, DMA addresses etc.

BIOS lives on Flash memory and is called upon as soon as the computer is turned on. BIOS works in this order after it is called in:
1. performs POST (Power On Self Test)
2. initializes Hardware
3. calls in the BootLoader
4. passes control to the BootLoader

IRQs (Interrupt Requests) are signals used to interrupt the current CPU activity as soon as an external event occurs (like mouse movement or keyboard input).
Some important IRQs that are good to know:

0 - System Timer
1 - Keyboard
9, 10 & 11 - Open interrupts
14 - Primary ATA controller
15 - Secondary ATA controller

To check IRQs on a running system:
# cat /proc/interrupts

I/O Addresses - unique locations in memory reserved for specific hardware


DMA Addresses - Direct memory addressing allows a device to directly transmit data to the memory, bypassing the CPU completely. This improves overall performance. 

To check DMA channels:
# cat /proc/dma

Configuring devices:

ISA and PCI
ISA devices are mostly onfigured today using the in-built functions in the kernel. These functions invoke the drivers from the kernel in order to configure most plug n play devices.
To retrieve the current configuration of the ISA PnP devices:
# pnpdump > isapnp.conf

This write the current configuration to the file isapnp.conf 
Once you've made changes to this file, you can load it back:
# isapnp /etc/isapnp.conf

PCI devices are configured automatically most of the times. 
setpci is a utility that can be used to change low-level configuration on hardware.

Modems
RS-232 serial port is what modems use 
#setserial /dev/ttyS0 - shows the basic info for the RS-232 port

setserial cmd can be used to set the speed of the modem etc.

USB devices
There are three types of controllers for USB in Linux:
UHCI - Universal Host Controller Interface (USB 1.x)
OHCI - Open Host Controller Interface (USB 1.x)
EHCI - Enhanced Host Controller Interface (USB 2)

USB is hot-pluggable technology - can be added while the computer is on.


Sound Cards

sndconfig (Red Hat) - program used to check sound-card related config files


5 RakshaTec: May 2013 101.1 Determine and configure hardware settings Enable and disable integrated peripherals BIOS (Basic Input/Output System) can be used t...

Tuesday, May 14, 2013

Linux Boot Process

Kernel is the main program in a Linux system. 
It has two components:
1. The Main Kernel file
2. Supplementary Kernel files or Kerner Modules

Kernel Modules provide extra functionality and drivers.

init is the main program that is run when a Linux system starts. This program is responsible for managing other startup processes.

In order to lookup Modules, run this cmd:
lsmod
This command lists all the current modules and what are they used by.

modinfo <module_name>
This command tells you about the actual module - its license, author etc.

insmod <module_filename>
This cmd loads a single module by inserting it into the kernel. Requires full file name.
eg. $ insmod /lib/modules/2.6.0/-/-/-/filename.ko

modprobe <module_name>
This cmd loads the specified module and all the other modules that this one depends on, automatically. Doesn't require full filename - just the module name works fine.
eg. $ modprobe cdrom

modprobe uses /etc/modprobe.conf

modprobe -l lists all availalbe modules

rmmod <module_name>
This cmd removes a loaded module

depmod - rebuilds the modules.dep file when run as root

Bootloaders:

LILO and GRUB

LILO - LInux LOader
GRUB - GRand Unified Bootloader

LILO:
/etc/lilo.conf
Let's you load up to three OS by default - two linux and one non-linux
default  option is the one that loads automatically
you need to reinstall LILO after changing the config file by using the cmd lilo 


GRUB:
/boot/grub/menu.lst or grub.conf


The Boot Process:

1. Power is turned on, CPU gets electrical power
2. CPU runs BIOS
3. BIOS runs BootLoader
4. BootLoader loads the kernel into the memory and executes it
5. Kernel runs the initial program - init (/sbin/init)
6. init loads and executes the startup programs as defined by /etc/inittab





5 RakshaTec: May 2013 Kernel is the main program in a Linux system.  It has two components: 1. The Main Kernel file 2. Supplementary Kernel files or Kerner Mod...

Monday, May 6, 2013

Address Allocation for Private Internets

This is a very good article on IP addressing:
http://www.faqs.org/rfcs/rfc1918.html#b
5 RakshaTec: May 2013 This is a very good article on IP addressing: http://www.faqs.org/rfcs/rfc1918.html#b
< >