Archive for October, 2008

Implementing RAID-1

October 30, 2008

Here you will find the implementation of RAID level 1 (mirroring) with two different partition of same size on linux host.

First select 2 partition of equal size. If u have free space on your HDD u can create 2 new partition of same size using fdisk command, then run partprobe and create file system for newly created partition using mkfs.

Now install the mdadm package.
If you do not have md and raid1 module already loaded use modprobe to load it:
lsmod |grep raid1/md[to check whether they are loaded]

Load modules at boot time
No we need to make sure that raid kernel modules are loaded at the boot time.
echo raid1 >> /etc/modules
echo md >> /etc/modules
Load modules to the Kernel
modprobe raid1

modprobe md and again check with lsmod command.

N.B. The partition u just created need to be unmounted.

So your partitions are ready and raid1 and md modules also loaded on your kernel and make sure you have rsync installed on your system.

Then run the following command to create the raid device-

mdadm –create –verbose /dev/md0 –level=1 –raid-devices=2 /dev/sda10 /dev/sda11
Create a filesystem on RAID 1 Arrays
mkfs.xfs -f /dev/md0

Then mount the device
Edit mdadm.conf file
cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig
mdadm –detail –scan >> /etc/mdadm/mdadm.conf
Edit /etc/fstab

As we want to make our system to mount new RAID 1 arrays after reboot we need to edit /etc/fstab file.
/dev/md0 /disk-1 ext3 defaults 0 2
To see the current status of your RAID partition type the following command

mdadm –detail /dev/md0


Outpout formatting…

October 24, 2008

The following are the some basic utilities we use daily during Linux system administration and    manipulation.

sort -nr  [sort line of a file]

n-numeric, r-reverse

uniq -c  [print and count unique line on a file]

Efficient use of ‘find’ command

Find core files in this directory tree and remove them

find . -name “core” -exec rm -f {} \;

Find a pattern in a file using the recursive grep (ignore case)
find . -type f | xargs grep -i MYPATTERN
find . -name ‘*.sh’ -exec grep -li MYPATTERN {} \;

Find all my pipe files and change their permissions to all writable
find . -name “pipe*” -exec chmod 666 {} \;

Find files that were modified 7 days ago and archive
find . -type f -mtime 7 | xargs tar -cvf `date ‘+%d%m%Y’_archive.tar`

Find .txt files in this directory and move them as .xml
for i in `ls *.txt`; do mv $i ${i%%.txt}.xml; done

More on sed

Delete leading whitespace (spaces, tabs) from front of each line
aligns all text flush left
sed ‘s/^[ \t]*//’

Delete trailing whitespace (spaces, tabs) from end of each line
sed ‘s/[ \t]*$//’

Delete BOTH leading and trailing whitespace from each line
sed ‘s/^[ \t]*//;s/[ \t]*$//’

Count lines (emulates “wc -l”)
sed -n ‘$=’

To replace a pattern in the middle of a line
sed ‘s/.time/-/’ (will replace time with – where match from starting of the line)

To replace a range of matched pattern with a new one
sed ‘s/tty.*time=/-/’ (will replace the pattern tty-to-time with a -)

fixing issue with firefox3.0b5

October 9, 2008

Ubuntu Hardy 8.04 most things went well but today is the day I finally was able to use firefox 3 without constant crashes. The crashes were more like stalls and when starting from console there were no helpful messages displayed and it locked up in a way that the built in crash reporter never even displayed.

So, I just download the latest version 3.0.3 from mozilla’s site and then follow the steps below-

cp -R ~/.mozilla ~/.mozilla.backup
sudo tar -jxvf firefox-3*.tar.bz2 -C /opt
rm firefox-3*.tar.bz2
sudo mv /opt/firefox/plugins /opt/firefox/plugins.backup
sudo ln -s /usr/lib/firefox/plugins /opt/firefox/plugins
sudo dpkg-divert –divert /usr/bin/firefox.ubuntu –rename /usr/bin/firefox
sudo ln -s /opt/firefox/firefox /usr/bin/firefox