Thursday, November 25, 2010

How to setup static IP address on Debian

Let check few pre-requirements we need to obtain from the network admin:
  1. Host name:
  2. Ip address:
  3. Network: 192.168.10/24
  4. Gateway:
  5. DNS Servers: and
  6. Local Domains: dev.local, corp.local
Here are few simple steps to give your Debian box static IP address:
  1. Configure hostname:
    echo "deby01" > /etc/hostname
  2. Ensure /etc/hosts file properly resolves localhost:       localhost
    # In some circumstance it is not recommended to
    # resolve machine name to local ip address
    #  deby01
  3. Here is content of /etc/network/interfaces
    # The primary network interface
    auto eth0
    iface eth0 inet static
  4. Resolver configuration file /etc/resolv.conf:
    domain dev.local
    search dev.local dev.local. corp.local.
If you need setup a dynamic ip address with DHCP, take a look here.

How to setup DHCP client on Debian

The Dynamic Host Configuration Protocol (DHCP) is an auto configuration protocol used on IP networks. Before we proceed let assume the hostname we are going to setup is
  1. Configure hostname:
    echo "deby01" > /etc/hostname
  2. Ensure hosts file properly resolves localhost:       localhost
    # In some circumstance it is not recommended to
    # resolve machine name to local ip address
    #  deby01
  3. Here is content of /etc/network/interfaces
    # The primary network interface
    allow-hotplug eth0
    iface eth0 inet dhcp
    # If you experience issues with obtaining
    # default gateway consider uncomment lines below.
    #       up route add default gw
    #       down route del default gw
  4. Let your dhcp client publish our name (so it can be resolved by name). Ensure the following in file /etc/dhcp/dhcpclient.conf:
    send host-name "deby01";
  5. If you experience issues with DNS you can set them manually (file /etc/dhcp/dhcpclient.conf)
    prepend domain-name-servers,;
  6. Reboot in order to changes take effect or issue the following commands:
    ifdown eth0 && ifup eth0
  7. Check your dynamically obtained ip address:
    deby01:~# ifconfig eth0 | grep inet
     inet addr: ...
If you need to setup a static ip address, take a look here.

Wednesday, November 24, 2010

How to Compile a Kernel in Debian

Here you will see how to build Debian deb package for linux kernel source.

Install Tools

First of all install few tools:
apt-get install kernel-package libncurses5-dev fakeroot bzip2 build-essential

Prepare Working Directory

  1. Add users to group src:
    usermod -a -G src user1
  2. Ensure group src is the owner of /usr/src:
    chgrp -R src /usr/src
    chmod g+s /usr/src
    chmod -R g+w /usr/src

Download Kernel Source

  1. Change your working directory to /usr/src/:
    cd /usr/src
  2. Download kernel source from
    wget -c
  3. Decompress kernel source and create a symbolic link:
    tar xjf linux-2.6.36.tar.bz2
    test -L linux && rm linux 
    ln -s linux-2.6.36 linux
    cd linux

Configure Kernel

  1. Let use existing kernel configuration as a start point:
    cp /boot/config-`uname -r` /usr/src/linux/.config
  2. Launch kernel configuration tool:
    make menuconfig
  3. Start kernel build (this may take from 20 mins to few hours depending on your hardware and number of CPUs):
    time fakeroot make-kpkg -j 2 --initrd --append-to-version=-custom kernel_image kernel_headers
  4. Once build finishes you should get two .deb files in parent directory:
    deby01:/usr/src$ ls -l *.deb

Install Kernel

  1. Install linux kernel and image deb packages by issuing the following command:
    dpkg -i *.deb
  2. Restart your computer:
    shutdown -r now
  3. Once it restarts check the kernel version you are using:
    deby01:~$ uname -r
Enjoy your custom kernel.

Tuesday, November 23, 2010

How to quickly reboot you Linux

Here is a quick way to reboot you Linux with kexec command. In debian first install kexec-tools package:
apt-get install kexec-tools
Once installed make your current kernel the one you want to quickly reboot into:
kexec -e
In case you would like disable fast reboot, open file located at /etc/default/kexec and set LOAD_KEXEC to false:

# Defaults for kexec initscript
# sourced by /etc/init.d/kexec and /etc/init.d/kexec-load

# Load a kexec kernel (true/false)

# Kernel and initrd image

# If empty, use current /proc/cmdline

How to get Linux partition UUID

Ext3 file system UUID

tune2fs -l /dev/sda11 | grep UUID
Here is an output:
Filesystem UUID: 0827dce3-d1c0-41b1-bc6f-0d4cfa0a1849

XFS file system UUID

xfs_admin -u /dev/sda13
Here is an output:
UUID = f128170a-1ee4-4b4f-abe7-0acf169bb8ae