Wednesday, March 9, 2011

Speeding up Disk Performance

We can increase Hard Disk performance by ~40%, and decrease power consumption by Hard Disk, if we provide "noatime,nodiratime" options during partition mounting. Actually what happens is: whenever a file/directory is accessed, its atime "access time" is updated with epoch. These two options prevent these not-so-useful disk accesses. Hence
performance improvement.



The sample mount point (/home) entry in /etc/fstab may look like:


$ cat /etc/fstab | grep home
/dev/sda2 /home ext3 defaults,noatime,nodiratime 0 0

Thursday, February 24, 2011

Windows XP in Grub 2

When I installed Debian 6.0 (Squeeze) on my laptop, I found that Debian Installer had not added Windows XP entry in the GRUB 2. You might also face same issue, then you can add following lines in /boot/grub/grub.cfg



## (1) Windows XP in /dev/sda1
menuentry "Windows XP" {
set root=(hd0,1)
chainloader +1
}




Here are few tips how to set root in the grub.cfg



# DEVICE NAME CONVERSIONS
#
# Linux Grub
# -------------------------
# /dev/fd0 (fd0)
# /dev/sda (hd0)
# /dev/sdb2 (hd1,2)
# /dev/sda3 (hd0,3)
#


Tuesday, February 2, 2010

Cleaning of Temporary Install Files in Ubuntu/Debian

Cleaning of Temporary Install Files in Ubuntu/Debian can be done by giving
following commands:

$ sudo apt-get autoclean; sudo apt-get autoremove

Tuesday, December 15, 2009

How to change boot order in GRUB2?

With Ubuntu 9.10 (Karmic Koala), GRUB2 is the default boot loader.
How to change boot order in GRUB2?

1.
$ cat /etc/grub/grub.cfg
see the order of the wanted kernel. Starts from 0.

2.
$ vi /etc/default/grub
change GRUB_DEFAULT=0 value to wanted kernel

3. run
$ update-grub
to update

4. reboot and check with
$ uname -r
to see if correct kernel selected.

Monday, December 7, 2009

Find Biggest Files/Directories





Since ls does not give correct size on disk, better to
use du command.





$ du /path/to/dir | sort -nr




I hope above
command will give you the proper result you wanted.



Note: The above command may take large time, depending on

number of files in /path/to/dir . You can use depth(say 2) in
that dir.




$ du --max-depth=2 /path/to/dir | sort -nr






Tuesday, November 17, 2009

Newer Yahoo! Messenger Protocol on Pidgin on Debian Lenny 5.0

Yahoo! has changed authentication method of Yahoo! messenger protocol, which is not supported in Pidgin (Version <>= 2.5.7) supports newer Yahoo! Messenger Protocol. But Debian 5.0 Lenny repository has older pidgin (2.4.3). We can install newer pidgin, in the following steps:

## download latest pidgin from pidgin.im (at this time 2.6.3 is latest)
$ wget http://sourceforge.net/projects/pidgin/files/Pidgin/pidgin-2.6.3.tar.bz2

## extract files using tar
$ tar -zxvf pidgin-2.6.3.tar.bz2

$ cd pidgin-2.6.3

## Configure, Compile, and make
$ ./configure --disable-screensaver --disable-vv --disable-avahi --disable-tcl --disable-tk --prefix=/usr
$ make
$ sudo make install


Now you can use newer pidgin with newer Yahoo! Messenger. :)
Enjoy Yahoo!

Find Files Created Between 2 Times

In order to find files created between two times (start hour and end hour). The required hours are hours from current time. For example,

Current time = 2 PM = 14:00

If you want file created between 9 AM and 12 PM today, the start hour and end hour are:

Start Hour = (14 - 9) = 5
End Hour = (14 - 12) = 2

Hence required command is:


$ ./find_files_between_times.pl /path/to/dir 5 2



The Perl script which does this is given below:-


#!/usr/bin/perl -w
#===============================================================================
#
# FILE: find_files_between_times.pl
#
# USAGE: ./find_files_between_times.pl <dir> <start_hour> <end_hour>
#
# DESCRIPTION:
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Mitesh Singh Jat (mitesh), <mitesh[at]yahoo-inc[dot]com>
# COMPANY: Yahoo Inc, India
# VERSION: 1.0
# CREATED: 11/13/2009 10:00:02 PM IST
# REVISION: ---
#===============================================================================

use strict;
use warnings;

if (@ARGV != 3)
{
print STDERR "Usage: $0 <dir> <start_hour> <end_hour>\n";
exit(-1);
}

my $dir = $ARGV[0];
## Calculate current_hour - given_hour
#my $start_time = `/bin/date "+\%H"`;
my $start_time = $ARGV[1];
#chomp($start_time);
my $end_time = $ARGV[2];
$end_time = time - ($end_time * 60 * 60);
#$end_time = $start_time - $end_time;
#$start_time = $start_time - $ARGV[0];

if ($start_time > $end_time)
{
($start_time, $end_time) = ($end_time, $start_time);
}

my $cmd = "find $dir -ctime -$start_time";
print "Running $cmd\n";
my @files = `$cmd`;
foreach my $file (@files) # (`find $dir -ctime $start_time`)
{
chomp($file);
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($file);

if ($ctime > $end_time)
{
next;
}
print "$file\n";
}


exit(0);