Search

Copying the Evolution Data From one system to another

Here are the steps you would need to follow to make sure all your can recover and save all the mails in your evolution if you decide to migrate to another system or format your system.

In case you plan to format your system, copy the evolution folder as follows

1. gconftool-2 --shutdown
2. evolution ---force-shutdown
3. cp  -rf ~/.evolution   "backup_media"/evolution_backup
4. cp -rf ~/.gconf/evolution  "backup_media"/evolution_gconf_backup

Now after you have your new system up do the following steps to launch restore the evolution

1. gconftool-2 --shutdown
2. evolution ---force-shutdown 
3. cp -rf  "backup_media"/evolution_backup ~/.evolution
4.  cp -rf "backup_media"/evolution_gconf_backup  ~/.gconf/evolution

Now launch your evolution and set the server settings, you should be able to see all your previous mails and folders.

Formatting using the Linux Command Line.

If you do not have a format option in your Linux GUI don't worry. The command line is always there to help you.

 The command that you can use to format a pendrive or any other drive is "mkfs" .
The syntax is

mkfs [-V]  [-t fstype] [fs-options] filesys [blocks]

Where the -V option will produce a verbose output on your terminal.

The important part is the "-t" options with which you can specify what kind of filse system do you want to create using the command.
For e.g.  the windows follows filesystems "FAT" and "NTFS". Linux follows the filesystme "EXT3", "EXT4".
In case you want your drive to be recognized both in windows and Linux, it would be a good idea to use create a FAT filesystem. To create a FAT filesystem use the option VFAT with -t.

The "filesys" specifies the actual drive or the partition that you want to format. To get to know this you can use the command "sudo fdisk -l".  or "df -h"


Note: sudo option is not required if you have logged in as root.


From either of the command find out the /dev/sd The will differ from one system to another depending on what you wan to format.


For eg: This is the output of df -h



Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5              48G   33G   14G  71% /
none                  986M  340K  986M   1% /dev
none                  990M  480K  990M   1% /dev/shm
none                  990M   84K  990M   1% /var/run
none                  990M     0  990M   0% /var/lock
none                  990M     0  990M   0% /lib/init/rw
/dev/sdb1             1.9G  4.0K  1.9G   1% /media/New Volume

If you want to format a pendrive it will be mounted in /media. So in the above output what we want is format is /dev/sdb1. 

Thus the mkfs command would be 

mkfs -V -t vfat /dev/sdb1 


Cache Memory



In this article we will look into what a cache is, the need and understand the working.

In the memory hierarchy the cache memory comes next to the processor registers. 

Look at the following figure, assume it takes 10 time units for data to travel from the memory (RAM or the physical memory) to the processor, i.e if the processor requests for some data it will take 10 time units for it to reach the processor.

Note: The time units are just for explanation and do not reflect the actual time the Memory takes to produce the data



Let us assume that the processor requests for “Data1” from the memory which will reach the processor after 10 time units. Once the processor has finished working on “Data1” in the above setup it will have to send it back to the memory as processors need their registers to be free for further processing.
After a few instructions if the processor needs “Data1” again, the same time has to be spent all over again to fetch the data.

According to studies on various programs, it has been proven that often a data accessed once by the processor is required again very soon. This concept is termed as temporal locality.
That is if “Data1” is needed once, it will again be needed very soon.

Another observation made is that if one data is accessed soon the data around it is also required.
That is if “Data1” is accessed, soon “Data2”, “Data3” etc that is the data in memory location around “Data1” will also be accessed. This concept is called as spatial locality.

Over past few years the processor speeds have increased tremendously, but the speed at which the memory works has not kept up in the pace, as a result even though the processor is capable of working faster it ends up waiting for the data to arrive from the memory.
The cache is one way of making the memory work a little faster.


RAM being a slower memory will always take a lot of time in processing the data. Thus cache was introduced

  1. To take care of the slow memory access time of the RAM
  2. To take advantage of temporal and spatial locality.





As shown in the figure above , the processor comes in between the RAM and the processor. The technology with which the cache is built makes the cache work faster than the RAM, thus it takes lesser amount of time for the data to reach processor from the cache than from the RAM.
Lets say it takes 5 time units for the data to reach the processor from the cache. Thus if  “Data1” is stored temporarily in the cache, the processor would be able to access it faster as compared to when the data was in the RAM.

But the same technology which makes the cache work faster also makes cache very expensive thus we can not use as much cache as we want in our systems.

The processor first checks for data in the cache, if the requested data is available in the cache then it need not go to the RAM.

The cache is turn acts as a temporary storage for the data present in the RAM. Whenever data is fetched from the RAM it gets stored in the cache. The processor will make use of this data as long as it is available. Thus reducing the time it takes for the processor to get the data to work on and hence making the processor work faster.

But that also brings with it a new problem, the processor accesses the data from the memory based on the addresses, i.e if the processor wants to get “Data1”, it will send the address of “Data1”. So if we move the “Data1” to cache how would the processor know the data stored in cache comes from which memory location ?
This brings us to the next topic “Addressing In cache”

What is inside the Intird

If you want to have a loo into your initrd image, see what is there in it then you can do the following.

Create a folder called inirrd in your home folder,   Copy your present initrd to the home folder

$ cp  /boot/initrd.img-2.6.28-15-generic ~/initrd

  (your initrd version might be different).

The initrd image by default is a gzip image, thus it has to unzipped first.
To determine the file format you can use the command "file".

~/initrd$ mv initrd.img-2.6.28-15-generic initrd.img-2.6.28-15-generic.gz
~/initrd$ cpio -i < initrd.img-2.6.28-15-generic


If every ting goes fine, the contents of initrd will be present in your folder,initrd now, check it by running "ls" 

Setting up the Bash Prompt

The usual prompt on any terminal in the Linux systems is
user@computer-name:directory$


But if you don't like it you are actually free to change it and it is really simple to change it. The prompt is saved in a variable "PS1". To change the prompt you just have to change this prompt.

Open a terminal and save your current prompt in a temporary variable.
original=PS1

Now you can go ahead and change it to what ever you like
for eg
PS1="Hello \u $" 


This will change the prompt to
Hello username $
if the username is test then it would be
Hello test $

The "\u" is an escape sequence offered by bash, which returns the username of the current user.
There are a number of such escape sequence offered by bash.


\a     an ASCII bell character (07)
              \d     the date  in  "Weekday  Month  Date"  format
                     (e.g., "Tue May 26")
              \e     an ASCII escape character (033)
              \h     the hostname up to the first `.'
              \H     the hostname
              \j     the  number of jobs currently managed by the
                     shell
              \l     the basename of the shell's terminal  device
                     name
              \n     newline
              \r     carriage return
              \s     the  name  of  the shell, the basename of $0
                     (the portion following the final slash)
              \t     the current time in 24-hour HH:MM:SS format
              \T     the current time in 12-hour HH:MM:SS format
              \@     the current time in 12-hour am/pm format
              \u     the username of the current user
              \v     the version of bash (e.g., 2.00)
              \V     the release of bash,  version  +  patchlevel
                     (e.g., 2.00.0)
              \w     the current working directory
              \W     the  basename  of the current working direc­
                     tory
              \!     the history number of this command
              \#     the command number of this command
              \$     if the effective UID is 0, a #, otherwise  a
                     $
              \nnn   the  character  corresponding  to  the octal
                     number nnn
              \\     a backslash
              \[     begin a sequence of non-printing characters,
                     which could be used to embed a terminal con­
                     trol sequence into the prompt
              \]     end a sequence of non-printing characters



Any of the above can be used to change the prompt.

To set the prompt to what is was before
PS1=$original 


The above method will change the prompt temporarily, only for that session, to make this change permanent we need to set the value of PS1 in the file ~/.bashrc so that every time the bash is launched its displays the same prompt.

User Space File System

All the while I read about file systems I had a notion that it was some thing that was built into the kernel always.
But when I read about FUSE,  I was pleasantly surprised that it was not the case.
We can implement file systems in the user-space too.
FUSE-- Filesystem in UserSpace. allows you to achieve this, i.e implement filesystem in the user-sapce.

FUSE provides you with a set of API's that let you build your own file system and does not even need you to be the super user.
What is even better is the number of languages it supports.

So you are free to use what ever that you like, no restrictions what so ever. 

The complete details of the FUSE installation and usage can be found at http://fuse.sourceforge.net/

Putting system to hibernate from the command line

Ever wanted a script to put your system into hibernation, well yes its available.

/etc/acpi/hibernate.sh  (if you are using acpi).

You would need to have root privileges to run the script. If you run the following from your command line

sudo /etc/acpi/hibernate.sh 


It will put your system into hibernation.

The script basically checks whether your system has 'acpi" support.


test -f /usr/share/acpi-support/state-funcs || exit 0

Then its runs a few scripts that will set various environment variables




. /etc/default/acpi-support
. /usr/share/acpi-support/power-funcs
. /usr/share/acpi-support/policy-funcs




Then it will check if these variables are set properly and use the command "s2disk " if it is available


if [ -x /sbin/s2disk ]


 or use

echo  -n "disk"  >/sys/power/state. 

which means that the state of your machine is being written on to the disk, and the power to the cpu will be cut off. Once the power is restored this state will be read back from the disk and the system will be restored to the exact same state as before.

You can use this script with the crontab to put your system to hibernate automatically after a few hours, or at a specific time in the night.

Continue to run program after terminal is closed

If you are running some thing in your terminal, say compiling a kernel, which might take a long time. It is a little dangerous to use th normal terminal that you get from the "GUI" because even if you close the terminal by mistake all your work will be lost and you would have to start from the beginning again. 
So a work around is to use the GNU screens. 

GNU screen basically lets you run multiple terminals with in the terminals and also allows you to detach your terminal from the current terminal. But the process continues to run even after the terminal is detached, but the process can again be controlled once the terminal is reattached. 

The command that is used to achieve this is "screen". 

Will provide more details soon. 


Follow by Email