Tag Archives: experiments

Step by Step: CentOS – Network Configuration

After installing CentOS 5, the network interface must be configured manually. This step is unlike Debian installation which prompt to us on installation screen for configuring network settings.
To manually set the network interface, some script must be altered. Unfortunately, standard installation of CentOS doesn’t install nano as a default. So, we are using vi to edit the script. Consider it’s a quick course to vi.
Edit /etc/sysconfig/network

vi /etc/sysconfig/network

Press “INSERT” or “i” key to enter INSERT mode of vi. Add or edit GATEWAY line. In this example, we use 192.168.1.1 for gateway IP address.

GATEWAY=192.168.1.1

Press “ESCAPE” key to return to vi command, type “:”, “w”, and “q” to save and exit. (“w” means write to disk, while “q” means quit)

Edit /etc/sysconfig/network-scripts/ifcfg-ethXX, where XX means eth index of ethernet card you want to configure. Usually it’s on 0, so the complete syntax would be:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

You need to add ONBOOT, IPADDR, and NETMASK.

ONBOOT="yes"
IPADDR="192.168.1.10"
NETMASK="255.255.255.0"

Save and exit vi.

Restart network daemon.

/etc/init.d/network reload

Sample output:

Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]

Assign nameserver for your computer.

vi /etc/resolv.conf

Sample nameserver

nameserver 175.103.49.42
nameserver 8.8.8.8
nameserver 8.8.4.4

Save and exit vi.

Try to ping Google, if you had reply, it means you had the work done.

ping google.com

Sample output:

PING google.com (173.194.38.135) 56(84) bytes of data.
64 bytes from sin04s01-in-f7.1e100.net (173.194.38.135): icmp_seq=1 ttl=57 time=14.4 ms
64 bytes from sin04s01-in-f7.1e100.net (173.194.38.135): icmp_seq=2 ttl=57 time=13.9 ms
64 bytes from sin04s01-in-f7.1e100.net (173.194.38.135): icmp_seq=3 ttl=57 time=23.5 ms
64 bytes from sin04s01-in-f7.1e100.net (173.194.38.135): icmp_seq=4 ttl=57 time=20.0 ms
64 bytes from sin04s01-in-f7.1e100.net (173.194.38.135): icmp_seq=5 ttl=57 time=15.1 ms

Step by Step: CentOS – RAID 0

Get a list of available hard drive


ls -lh /dev/sd* or ls -lh /dev/hd*

Example Output:

[root@sKy-Centos ~]# ls -lh /dev/sd*
brw-rw----. 1 root disk 8, 0 Jun 13 22:53 /dev/sda
brw-rw----. 1 root disk 8, 1 Jun 13 22:53 /dev/sda1
brw-rw----. 1 root disk 8, 2 Jun 13 22:53 /dev/sda2
brw-rw----. 1 root disk 8, 16 Jun 13 22:53 /dev/sdb
brw-rw----. 1 root disk 8, 17 Jun 13 22:55 /dev/sdb1
brw-rw----. 1 root disk 8, 32 Jun 13 22:53 /dev/sdc
brw-rw----. 1 root disk 8, 33 Jun 13 22:55 /dev/sdc1
[root@sKy-Centos ~]#

Suppose we want to create RAID 0 from /dev/sdb and /dev/sdc and delete all partition inside (fresh RAID installation).


fdisk /dev/sdb

On fdisk interface, use “p” to print partition table to screen, “d” to delete partition, “n” to create new partition, and “w” to write changes to disk. Do the same thing to /dev/sdc
Next, we need to create RAID partition, in this example, we use /dev/md0 as a new name for RAID partition

mdadm -C /dev/md0 --level=raid0 --raid-devices=2 /dev/sdb1 /dev/sdc1

If the system complaints about cannot continue because device is busy, try to reboot and run the command again or check if RAID is already running with this command

cat /proc/mdstat

Example Output:

[root@sKy-Centos ~]# cat /proc/mdstat
Personalities : [raid0]
md0 : active raid0 sdc1[1] sdb1[0]
10471424 blocks super 1.2 512k chunks

unused devices:

and stop it with

mdadm --stop /dev/md0

Create mount point for our new RAID 0 Partition, for example, we will use /widi as mount point.

mkdir /widi

Edit /etc/fstab and add that partition

/dev/md0 /widi /ext3 defaults 1 1

Format /dev/md0 before actual mounting

mkfs.ext3 /dev/md0

Finally, mount /widi

mount /widi

Some notes on mdadm. It is not necessary to had the same size for the RAID 0. mdadm will adjust so extra space on larger drive won’t be used for stripping.