Installing CentOS over the network

Introduction

CentOS is a 100%-compatible, service-free distribution of Red Hat Enterprise Linux. If you like the OS but don't need the service, CentOS is the thing for you.

Setup

CentOS 5

By default, CentOS 5 comes as a single DVD or a set of six CD's. If you don't have a DVD burner and don't want to burn that many CD's, here's how to burn a small, bootable CD just to boot up, and fetch the actual install files from a remote server (FTP or HTTP):

  1. Download the 7MB os/i386/images/boot.iso (a.k.a. netinstall.iso), and burn this to a CDR(W)
  2. Write down a list of different FTP or HTTP servers from which to fetch files. It's good to have more than one, since that server might be busy or off-line while you're installing.

    For instance, to download CentOS 5 from French ISP Free: FTP = ftp.free.fr, Directory = /mirrors/ftp.centos.org/5.3/os/i386/ , DNS = 212.27.54.252 and 208.67.220.220

    List of mirrors from which to install CentOS
     
  3. At the boot prompt, type "linux askmethod"
  4. Once installed, update the system with "yum update". In case a new kernel was installed, type "reboot" to boot up with that new kernel

Centos 6

The 7MB boot.iso is now netinstall.ISO and ballooned to 194MB.

Choose the default install option ("???"). When prompted with "What type of media contains the installation disk?", cChoose "URL", and type the full URL including http://.

It's a pain that the netinstall.iso image doesn't contain a list of well-know, stable servers that the user could pick :-/

Since we're booting with a USB keydrive, make sure CentOS installs the system and the MBR on the hard drive instead of the USB keydrive.

Post-install setup

Removing packages

yum list installed

yum remove exim

Stopping and removing IP(6)Tables

  1. /etc/init.d/iptables stop
  2. /etc/init.d/ip6tables stop
  3. yum remove iptables

NTP

  1. yum install ntp
  2. chkconfig ntpd on
  3. ntpdate 0.fr.pool.ntp.org
  4. vim /etc/ntpd.conf

    server 0.fr.pool.ntp.org
    server 1.fr.pool.ntp.org
    server 2.fr.pool.ntp.org
    server 3.fr.pool.ntp.org
     
  5. /etc/init.d/ntpd start

Once NTPd is up and running, you might need to set the BIOS clock to match the system clock:

  1. date
  2. hwclock

If the BIOS ("hardware") clock is in the wrong time zone, run the following and check again:

  1. hwclock --systohc
  2. hwclock

Vim

yum install vim

vim ~/.vimrc

set tabstop=4

set autoindent

syntax enable

Installing Apache

From How to Enable EPEL Repository on CentOS for Yum Package Management

Enable the EPL Repository

cd /tmp

wget https://fedoraproject.org/static/0608B895.txt

mv 0608B895.txt /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

rpm -qa gpg*

Download and this RPM:

http://download.fedoraproject.org/pub/epel/6/i386/repoview/epel-release.html

 

  1. yum install httpd mod_wsgi
  2. Edit /etc/sysconfig/httpd to uncomment this line to get Apache to run as worker MPM:

    #HTTPD=/usr/sbin/httpd.worker
     
  3. Edit mod_wsgi
  4. Build a test WSGI Python script
  5. Start Apache, and launch a browser

 

 

 

yum install httpd mod_ssl

/usr/sbin/apachectl start

vi /etc/httpd/conf/httpd.conf (#ServerName www.example.com:80)

/usr/sbin/apachectl restart

Check that iptables isn't running or configure it to allow incoming connections

/sbin/chkconfig httpd on

/sbin/chkconfig --list httpd

To run Apache as worker MPM: edit /etc/sysconfig/httpd, and uncomment the line "#HTTPD=/usr/sbin/httpd.worker"

 

Checking CPU information

dmidecode processor

Monitoring temperature

  1. (Motherboard-dependent) yum install kmod-it87
  2. yum install lm_sensors
  3. sensors-detect
  4. sensors

If "sensors" fails, reboot, and give it another shot. Alternatively, try loading the required drivers manually, eg.

# modprobe coretemp

# modprobe i2c-i801 (check which driver you need by checking data writtent to /etc/sysconfig/lm_sensors)

Man pages

yum install man

yum install man-pages

DHCP to Static IP

To go from DHCP to static IP, either run system-config-network, or do this:

  1. vim /etc/sysconfig/networking/devices/ifcfg-eth0
    BOOTPROTO=none
    NETMASK=255.255.255.0
    IPADDR=192.168.0.100
    GATEWAY=192.168.0.1
  2. vim /etc/resolv.conf
    search your-dns-search-path
    nameserver dns1-ip-address
    nameserver dns2-ip-address
  3. service network restart
  4. ifconfig

Samba

Here's how to share the whole root filesystem:

  1. Edit /etc/samba/smb.conf:
    workgroup is set to 'Workgroup'
    turn on encrypted passwords
    set up a share with '/' as the directory path, read+write access and proper user/group control
  2. user alias for root in /etc/samba/smbusers that looks like this: root=administrator
  3. set root's samba password with smbpasswd to the same as the 'administrator' on your windows computer.
  4. restart samba
  5. log in as administrator on the windows machine and test your config - you should just be able to log in without entering a password or username in this config. If you're a different user, it should ask for a username and password.

Tips & Tricks

Using Netstat to display open TCP and UDP ports

netstat -tua

Editing the PATH environment variable

  1. Create a new text file in the /etc/profile.d/ directory
  2. Add this line:

    export PATH=$PATH:/my/new/path
     
  3. Change access rights to this file: chmod 755
  4. Log off and log back on
  5. echo $PATH

Capturing a whole session

"script" starts a new shell and everything you do will be captured to a file named typescript. Type "exit" to close this shell, and the whole session is found in a file named "typescript".

Nano

Support for keys Home, End and Del (Del!=Backspace) ?

Compiling a new kernel

I needed to build a kernel for a Pentium CPU, ie. that uses the i586 command set instead of the default kernel that uses the i686: How To Compile A Kernel - The CentOS Way :

http://wiki.centos.org/HowTos/I_need_the_Kernel_Source

  1. yum groupinstall "Development Tools" (installs kernel source + devel + headers, and rpm-build?)
  2. wget http://mirror.centos.org/centos/5.1/os/SRPMS/kernel-2.6.18-53.el5.src.rpm
  3. rpm -Uvh kernel-2.6.18-53.el5.src.rpm
  4. cd /usr/src/redhat/SPECS
  5. # rpmbuild -bp --target=i586 kernel-2.6.spec
    error: Architecture is not included: i586
  6. cp /boot/config-2.6.18-53.1.4.el5 /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386/.config
  7. cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386/
  8. make menuconfig
    HOSTCC  scripts/kconfig/lxdialog/checklist.o
    In file included from scripts/kconfig/lxdialog/checklist.c:24:
    scripts/kconfig/lxdialog/dialog.h:31:20: error: curses.h: No such file or directory
    In file included from scripts/kconfig/lxdialog/checklist.c:24: scripts/kconfig/lxdialog/dialog.h:128: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘use_colors’
    scripts/kconfig/lxdialog/dialog.h:129: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘use_shadow’
    scripts/kconfig/lxdialog/dialog.h:131: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘attributes’
    scripts/kconfig/lxdialog/dialog.h:143: error: expected ‘)’ before ‘*’ token

 

  1. cd /usr/src/redhat/SPECS
  2. rpmbuild -bp --target=i386 kernel-2.6.spec
  3. cp /boot/config-2.6.18-53.1.4.el5 /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386/.config
  4. cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386/
  5. make menuconfig

    HOSTCC  scripts/kconfig/lxdialog/checklist.o
    In file included from scripts/kconfig/lxdialog/checklist.c:24: scripts/kconfig/lxdialog/dialog.h:31:20: error: curses.h: No such file or directory
    In file included from scripts/kconfig/lxdialog/checklist.c:24: scripts/kconfig/lxdialog/dialog.h:128: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âuse_colorsâ

 

  1. yum install rpm-build kernel-devel.i686
  2. yum install redhat-rpm-config.noarch ncurses-devel
  3. cd /usr/src/redhat/SPECS
  4. rpmbuild -bp --target i386 kernel-2.6.spec
  5. cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386
  6. ln -s /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386 /usr/src/linux
  7. make mrproper
  8. cp /boot/config-2.6.18-53.1.4.el5 .config
  9. make menuconfig
  10. make bzImage

    arch/i386/kernel/cpu/cpufreq/powernow-k8.c: In function âpowernowk8_initâ: arch/i386/kernel/cpu/cpufreq/powernow-k8.c:1435: error: âstruct cpuinfo_x86â has no member named âbooted_coresâ
    make[3]: *** [arch/i386/kernel/cpu/cpufreq/powernow-k8.o] Error 1

Installing a DHCP + TFTP servers

  1. yum install dhcp
  2. edit /etc/dhcpd.conf
  3. if not installed by the package, "touch /var/lib/dhcpd/dhcpd.leases"
  4. yum install xinetd
  5. wget http://dag.wieers.com/rpm/packages/tftp/tftp-server-0.34-0.2.el5.rf.i386.rpm
  6. rpm -Uvh tftp-server-0.34-0.2.el5.rf.i386.rpm
  7. vim /etc/xinetd.d/tftp : disable = no
  8. service xinetd start
  9. mkdir -p /tftpboot/pxelinux.cfg
  10. vim /tftpboot/pxelinux.cfg/default:

    prompt 1
    default linux
    timeout 100

    label linux
    kernel vmlinuz
    append initrd=initrd.img ramdisk_size=9216 noapic acpi=off
  11. To test:

    touch /tftpboot/dummy.txt
    yum install tftp
    tftp tftpserver.test.net
    tftp > get dummy.txt
    tftp > quit
  12. chkconfig --level 2345 dhcpd on
  13. cd /tftpboot
  14. wget ftp://ftp.free.fr/mirrors/ftp.centos.org/5.1/os/i386/images/pxeboot/vmlinuz
  15. mv vmlinuz pxelinux.0
  16. wget ftp://ftp.free.fr/mirrors/ftp.centos.org/5.1/os/i386/images/pxeboot/initrd.img
  17. Launch in console mode: /usr/sbin/dhcpd -d -f

A client can't connect to CentOS

By default, CentOS runs SELinux and the firewall iptables. Make sure those don't keep the clients from connecting to the server.

Using yum/rpm to manage packages

http://mirror.centos.org/centos/4/docs/html/yum/

How do I change my server's name

Kernel panic - not syncing: IO-APIC + timer doesn't work

If you get this message when rebooting, add "noapic" to the kernel options when booting, and add it to Grub's kernel line (/boot/grub/grub.conf to make it permanent for this kernel).

Alternatively : "I got a ASUS M2N-MX just installed and also got the same error when begin installation. I change the ACPI support to 2.0 in BIOS (also put the correct frequency and delays in memmories), and since too many trestarts and power off and power on to test I didn't get the "Kernel Panic - not syncing: IO-APIC + timer doesn't work!" anymore! If this option is not present in the mother you buy, just update the BIOS (I have not to do it). I also disabled in BIOS Chipset-> SouthBridge-> MCP61 ACPI HPET TABLE : If you enable it you will get again the IO-APIC error..."

"running with noapic is for the replacement for the old PIC chip that used to come on motherboards that allowed you to setup nterrupts. sometimes motherboards come with small defects ( called bugs ) and loading the kernel without the this apic is the only way to load you're system. my PC at home would not run CentOS 5 smp kernel or Fedora 5,6,7,8 without setting noapic.the way to test it is to edit the grub menulist while booting and adding noapic at the end"

In case you're interested, APIC is "an Advanced Programmable Interrupt Controller (APIC), a more intricate Programmable Interrupt Controller (PIC) containing a magnitude more outputs and much more complex priority schemas. Advanced IRQ management."

Lots of ACPI errors

Looks like Linux doesn't like the way this host supports ACPI:

ACPI Error (psargs-0355): [HPTF] Namespace lookup failure, AE_NOT_FOUND
ACPI Error (psparse-0537): Method parse/execution failed [\_SB_.PCI0.HPET._STA] (Node ffff81003bfb17f0), AE_NOT_FOUND
ACPI: PCI Interrupt Link [LNK1] (IRQs 5 7 9 10 11 14 15) *0, disabled.

What kernel and CentOS am I running?

rm -y

By default, CentOS comes with the alias "rm -i" to rm, which is a pain if you want to delete several files. An easy alternative is keep this protection, but type "rm -f" when you don't want to be prompted.

Resources