Thursday, July 31, 2008

clone hard disk in linux

Install all software for development machine is tedious job. Just think of a team of 5 or above. Linux offer DD command to reduce this job as much as easier.
What we could do with the help of DD command is, just install all the software in one machine and clone that hard disk to other hard disks. Here the constraints is hard disks[source and destination] should be same size.

Step 1:
Install all softwares you want.
Step 2:
Connect the second hard disk to machine where in all software has been installed.
Stop 3:
Mount command list all the media connected in that machine.
Stop 4:
Now you have find out in which hard disk you have already installed all software.
Now two hard disk connected to your machine.
but you can view only one hard disk unless you mount another one. To confirm which media is source and which media is destination, You have to mount.
While run DD command we have to give the name of the media namely sda or sdb etc... So we have to confirm the media name.
To mount
i) Make a directory in /media. For ex /media/hd
ii) run a follwoing command to mount media to a directory.
mount /dev/sda7 /media/hd
/dev directory will contains all media details.
iii) after confirmation of which media is source[for ex sdb] and which media is destination[for ex sda] have to unmount the device using the following command.
umount /media/hd
step 5:
finally you have to run the following command to clone the hard disk from one to another with root user.
dd if=/dev/sdb of=/dev/sda

dd => disk to disk command
if => input file
of => output file

This will take an hour to copy. You could do the same stuff for any number of machines within an hour per machine.
Enjoy maadi.

Tuesday, July 8, 2008

Sort process by memory

The following command help to sort list of process running in linux machine.
ps -eo pmem,pid,args | sort -k 1 -n -r | less

pmem -> list the memory occupied by the process
pid -> process ID
args -> process