Wednesday, September 8, 2010


So what is the difference between RAID01 and RAID10?

>>>>When we are dealing with RAID01 we are actually implementing RAID0 first then RAID1 on it. Ok little bit confused?
Let me put it in this way RAID0 is nothing but stripeset writing of data and RAID1 is Mirring of data on to disks.For example lets take 8 disks, so first we are writing whole data on 4 disks then we are mirring it on to remaining disks.
Where as in RAID10 we are first mirring disk and then striping data on mirrered disks
In general RAID01 is "a mirrior of 2 strips" and RIAD10 is "a single strip on mirrered disks"

So here one more question arises... which one is good?
RAID10 is good, the difference is that the chance of system failure with two drive failures in a RAID 0+1 system with two sets of drives is (n/2)/(n - 1) where "n" is the total number of drives in the system. The chance of system failure in a RAID 1+0 system with two drives per mirror is 1/(n - 1). So, using the 8 drive systems shown in the diagrams, the chance that loosing a second drive would bring down the RAID system is 4/7 with a RAID 0+1 system and 1/7 with a RAID 1+0 system.

Implementing RAID10 in Linux

RAID10 can be implemented by first implement RAID1(ie mirring) then implementing RAID0(stripeset on different disks) on it.

Configuring RAID10
Step1:Get the info who many devices are participating, for example here we taken 4 disks(/dev/sda1,/dev/sdb1,/dev/sdc1,/dev/sdd1).
Step2:Implement RAID1 on four drives(taking 2 each)

#mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sd[ab]1
#mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sd[cd]1
Step3:Now implement RAID0 on two of RAID1 devices(/dev/md0,/dev/md1)

#mdadm --create /dev/md2 --chunk=64 --level=0 --raid-devices=2 /dev/md[01]
Step4:Format the RAID10 device with ext3 and mount the device
#mke2fs -j /dev/md2
#mkdir /store
#mount /dev/md2 /store
Unconfiguring RAID10
Step1:Unmount the RAID device /dev/md2
#umount /dev/md2 or #umount /store
Step2:Stop the RAID device
#mdadm --manage /dev/md2 --stop
#mdadm --manage /dev/md1 --stop
#mdadm --manage /dev/md0 --stop
Step3:Remove the Disks(/dev/sda1,/dev/sdb1,/dev/sdc1,/dev/sdd1) by using fdisk utility

Configuring and Installing YUM server in RHEL4

If you are looking for YUM server in RHEL5 you can clickhere other wise just read on..
Recently I came across a strange issue.. ie implementing YUM(Yellow dog Updater and Modifier) server in RHEL4 :(. By the time of RHEL4 released there is no YUM server implementation..
so I did some research and collected some documentation on net and implemented YUM server in RHEL4
configuring YUM server in RHEL4 as follows..
Stpe1:Download following packages
yum-utils-0.3.1-1.fc4.noarch.rpm ( we need for repository)
Stpe2: Install the above mention packages in the same sequence once you download them.
rpm -Uvh sqlite-2.8.16-1.2.el4.rf.i386.rpm
rpm -Uvh python-sqlite-0.5.0-1.2.elr4.rf.i386.rpm
rpm -Uvh python-urlgrabber-2.9.6-1.2.el4.rf.noaarch.rpm
rpm -Uvh pytyhon-elementtree-1.26-1.2.el4.rf.noarch.rpm
rpm -Uvh python-celementtree-1.0.2-1.2.el4.rf.i386.rpm
rpm -Uvh yum-2.4.2-1.noarch.rpm
rpm -Uvh yum-utils-0.3.1-1.fc4.noarch.rpm
rpm -Uvh createrepo-0.3.1-1.noarch.rpm
Step3:Now dump your rpms from your RHEL4 cds/dvd
cp -ar * /var/ftp/pub/Server/
Step4: Create repository
#createrepo -v /var/ftp/pub/Server/
Here yum server will create a repository and metadata once creation of metadata is done we can configure yum client on the same mechine.. as follows
Step5:Creating a repo file and updating with the repository details
#vi /etc/yum.repo.d/server.repo
name= Redhat repository
save the file and exit and start using yum to install packages in RHEL4.

Rsync Command ::: All Linux Admin Should Know

Recently I came accross rsync utility... Its an awesome command it is a sub service under xinetd along with some other services such as tftp, rcp, rsh, rlogin, telnet etc..

Let us list advantages of this command then we will know how to configure it.

Advantages of rsync :

  1. This tool will keep both the destination and source folder synced.
  2. rsync is fast, because it will not copy entire data every time it got synced, it just copes the date which got changed from previous copy.
  3. For security reasons, rsync will support ssh to transfer data between two machines.
  4. rsync is used to download RPM updated repository to local machine.
And lot more advantages are there.. please share your valuable experiences here.

Configuration : rsync

Some points to be remembered when dealing with rsync

  • This utility is the part of xinetd so there is no special package for this.
  • When we are doing rsync between two systems, both the systems should be configured to allow rsync connections.
  • rsync uses 873.
Step1 : Install xinetd package, if you want to configure yum server click here.
#yum install xinetd

Step2 : Configure rsync to allow connections, the configuration file for rsync is located in /etc/xinetd.d
#cd /etc/xinetd.d
#vi rsync

# default : off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
disable = yes
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
In this configuration file just change disable = yes to no, then save the file and exit. Here is the updated configured file.
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
disable = no

socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID

Step3 : Start the rsync service, so how to do it? As i mention earlier that rsync is a part of xinetd service so just restart the xinetd service.
#service xinetd restart

Step4 : Permanently on the service
#chkconfig rsync --levels 345 on

Creating Virtual File System in Linux

Can we create a file system (i.e. formatting a drive/partition) with in a file system?
Looks little bit strange is int it? So follow me I will show you how to create a virtual partition and file system within a partition.

Step1 : Create a empty file with /dev/zero with size equal to 50Mb.
#dd if=/dev/zero of=/temp/vf0 count=102400
Note :

1. By default "dd" command(dataset definition) uses block of 512bytes so the size will be 102400*512=52 428 800=~50MB
2. /dev/zero is a device files which will be used create a file which conations "0" i.e. an empty
file.Clipped output:[root@test6 ~]# dd if=/dev/zero of=/temp/vf0 count=102400
102400+0 records in
102400+0 records out
[root@test ~]# ls -lh /temp/vf0
-rw-r--r-- 1 root root 50M Nov 7 12:08 /temp/vf0

Step2 : Create ext3 file system for this virtual partition.
#mkfs -t ext3 /temp/vf0
Here it will ask "do you want to format the file or not"?, just say yes.

Step3 : Now we have to create a mount point (nothing but a directory) and mount the created partition.
# mkdir /virtdrive
# mount -o loop=/dev/loop0 /temp/vf0 /virtdrive


/dev/loop is special hardware device used to mount ISO files and virtual file systems. In Linux there are total 8 loop devices numbering from 0 to 7. So you can mount only 8 ISO files/virtual file systems by default.

Step4 : Edit /etc/fstab file to mount permanently, so that it be auto mounted at boot time too. Specify following entry in fstab file.
/temp/vf0 /virtdrive ext3 rw,loop=/dev/loop0 0 0
Step5 : Specify the fstab changes to kernel.
#mount -a
Step6 : Conform Weather mounting happen perfectly or not.
Way1 :#cat /etc/mtab
Way2 : Change the directory to mount point you have to see lost+found folder
[root@test ~]# cd /virtdrive/
[root@test virtdrive]# ls
[root@test virtdrive]#

Info Related MBR and Taking its Backup

1.How to take the backup and restore MBR? Why do you require to take the backup of your MBR?
Ans :
MBR (Master Boot Recorder) is a vital part of your hard disk which contains booting information, without it its difficult to boot the system. Suppose you have windows and Linux duel boot on your machine and as you know windows is more prone to virus attacks. So it’s always better to backup your MBR to be in safe place.

2. How to take backup of your MBR?
Ans :
Using dd command (dataset definition). Here are the steps to take backup of you MBR and keep it in safe place to restore your system if it get corrupted.
#dd if=/dev/hdx of=/safe/location bs=512 count=1

Let me explain the above command how it will work.
in the command is nothing but to specify Input File, here we are specifying our input file as hard disk(if the hard disk is /dev/hda it is primary master, so for general purpose I given 'x'). “of” in the command is nothing but to specify Output File, here we are specifying our output file as /safe/location. Then “bs” this is nothing but block size to write in to hard disk. And then “count” nothing but how many times you want to write date this many block sizes. Here in this example count=1 that means first 512 bytes of the hard disk is copied to the specified location.

3.How to restore the MBR?
#dd if=/safe/location of=/dev/hdx bs=512 count=1

Note : Please replace “hdx” with your hard disk name.
This is bit complex,
Is there any other way to restore MBR?
Yes, if you have Linux or Windows bootable CD, we can easily restore your MBR if you forgot to take backup(And this method is very much easy to do restoration of MBR when compared to previous method).

Method1 : With Redhat Linux bootable CD.
For this you have to boot your system to rescue mode, then mount your file system to rescue mode and execute below command to restore your MBR
#grub-install /dev/hdx

Note : Please replace hdx with your hard disk name. After that you just reboot your system. Your system will be live and working.

Method2 : With Windows XP bootable CD.
Step1 : Boot the system with XP bootable cd
Step2 : Press f8 to go to repair mode in Windows
Step3 : Once you got the c drive prompt just type below command
This command will fix the MBR record.

Some FAQ’s
1. What is the MBR size?
Ans :
MBR size is just 512 bytes.

2.What MBR conations?
Ans :
Mainly MBR can be divided in two parts
a.Boot loader information block(which is of 448 bytes)
b. Partition table information(which is of just 64 bytes)

3.How many partition we can create on a hard disk?
Ans :
Totally we can create four partitions as below
a.Four primary parathions.
b.Three primary and one extended partition.
c.Two primary and one extended parathion.
d.One primary and one extended parathion.

Note : In extended parathion we can create logical partitions up to 24 in number.

4.Why we cannot create more then 4 partition as mention above?
Ans :
In MBR, the partition table info is just stored in 64 bytes, and one parathion information to store in MBR requires 16 bytes of space. So at most you can create only 4 partitions as mention above.