which one do u think is the best OS now!

Wednesday, June 8, 2011

ReadyBoost on Linux

In my previous post on readyboost I tried to explain out the basic ideology of the technique called readyboost and also some performance statistics to support the theory. Well that was for Microsoft operating systems [dedicatedly available in Vista or newer and have to be manually configured in older OSs].

 The idea of readyboost is simple. For machines with low RAM, whenever the data access requirements over-flood the RAM, the OS starts to pass the least probably-important data to the page files on the hard disk and loads currently required/most important/high priority data on to the RAM from the hard disk/page files. This is where the machine slows down. Activating the readyboost adds another layer in between the page files and the RAM in the data access hierarchy. Thus whenever the ram over-floods, the new data is loaded from the flash drive and the old data is passed to the flash drive. In the flash drive also data is collected and maintained in the same manner as the RAM.

Now, Linux also uses something similar to the paging file systems called the swap partition. Swap partitions do the almost the same job that is done by the page files in the windows environment. So it is possible to create swap partition on a flash drive. As because flash drives give a higher access speed, the swap partition will be faster on the flash drive. And if we assign priority to the flash drive swap compared to the dedicated hard disk swap, the flash drive enters in to the hierarchy scheme and performs almost the same way as the readyboost concept.

Now the most important thing….. HOW TO DO IT…. [the code is for ubuntu]
Open the terminal.
i>                   Plug-in the flash drive.
ii>                 Linux shall automount the drive. Then you have to unmounts it 
Sudo  unmounts /media/”usbdisk”
iii>                Now find the usb device in the terminal using the command
Sudo df –h    [it will be something like /ev/sda1 or /dev/sdb2 etc. I am considering /dev/sda1 here]
iv>               Sudo mkswap /dev/sda1 [creating the swap at the /dev/sda1 flash drive]
v>                 Sudo swapon –p 32767 /dev/sda1 [-p is to activate a partition and not a file. Anf the number 32767 is the priority number. Linux processes support a priority range of 0-32767. 0 being the min priority and 32767 being the highest]
Ok. The flash drive is now working as a swap partition. It’s better to format the flash drive in exfat file system [specially ext4]  as the swap partition works best on that file system.
To verify the swap partition being operational type the following code on terminal
                Cat /proc/swaps
If the swap partition is active, then it will be shown on the output list along with the dedicated hard drive swap partition(s).
To turn the “ReadyBoost” off on the linux [Ubuntu] type this code on terminal
                Sudo swapoff /dev/sda1 [/dev/sda1 here is the flashdrive as detected in step 3]

Now I did mention that the swap technique will work almost the same way as readyboost. Well, Almost. In windows we were creating a page file which is comparable to a swap file, not a swap partition. Swap files are very flexible but vulnerable. If deleted accidentally, data could be lost or even the OS can get corrupted. Swap partitions can’t be modulated while being used. Thus the data cannot be affected. And in some cases the access speed in swap files is better than swap partitions. In linux, we are creating a swap partition on the flash drive. We shouldn’t create a swap file as because linux will not prevent us from deleting the file due to its high flexibility. So the speed advancement in linux may not be as promising as in windows. But, yeah it still works..