Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Reduce login time in Ubuntu/Linux

It has been well-documented that Ubuntu’s readahead system during boot significantly cuts down on boot time by reducing hard disk seeking via precaching commonly-used files during bootup. This feature, however, only lasts up to the GDM screen.

Recently I found out that this use of readahead can be further extended to improve the login time - the time it takes to reach the desktop after the GDM login screen.

!!! You probably shouldn’t try this unless you have more than 512MB RAM.!!!

Part 1 : Monitor login sequence

First, we need to ask readahead to monitor a login sequence and make note of all the files read during this period. The idea obviously is to begin reading these files as soon as you reach the GDM screen.

Let's store the readahead list somewhere.
Code:
mkdir ~/.readahead

Now, log out(CTRL+ALT+BACKSPACE), and press CTRL+ALT+F1 to log into a terminal.(Do not login from the GDM screen) Start the profiler now.

Code:
sudo readahead-watch -o ~/.readahead/gnome.root /

This will grind the disk for a while (up to a few minutes, so have patience and dont think you are screwed and try to abort it :) then it will return you to a command prompt. The profiler is now in the background watching all actions. Now, without logging out, go to your GDM prompt (CTRL+ALT+F7 ) and log in normally.

after you are fully logged in, press CTRL+ALT+F1 to go back to your terminal, then run:

Code:
sudo killall readahead-watch
sudo chown neo:neo ~/.readahead -R

Replace neo:neo with your user and group name. Now, we need to go prune this list a bit. Especially if you have large files on your desktop (like a 1GB AVI), the login sequence may touch it, causing readahead to think it should load the whole thing into memory! In a terminal, run:

Code:
cat ~/.readahead/gnome.root | xargs -i ls -lk {} | sort -rn -k +5 | less > readahead_list

This will output all the files readahead wants to cache, sorted by largest file first into the readahead_list file. Open the readahead_list file using your favorite editor. The 5th column (before date) is the size of the file in KB. Make sure there’s nothing glaringly large. If it’s bigger than 10,000KB or so, it’s probably not worth preloading. Remove such unwanted files from the preload list by opening ~/.readahead/gnome.root and deleting its line.

Code:
gedit ~/.readahead/gnome.root

Part 2 : Hooking this into the login sequence

Next, we need to tell Ubuntu to do this readahead on every login. There are many ways one can do this. Let's use /etc/X11/Xsession.d.

Create a file called /etc/X11/Xsession.d/00readahead.

Code:
sudo gedit /etc/X11/Xsession.d/00readahead

Put the following in the file :

for list in ~/.readahead/*; do
readahead-list $list &
done

wait

Save the file. Now you can reboot to test if this works.

Part 3 : Hook into boot sequence

Often times, we don’t log in immediately when the prompt comes up. It makes sense to cache a login as a part of bootup. Open up /etc/rc.local in your favorite text editor, and before the exit 0
statement, add:

Note : Replace neo in the first line by your username.

for list in /home/neo/.readahead/*; do
readahead-list $list
done

Now, reboot, and wait for all disk activity to stop before logging in. You should feel really nice :)

Undoing This :

Not much to do! Just delete ~./readahead directory, /etc/X11/Xsession.d/00readahead and remove the added lines from /etc/rc.local.

This improved my login time drastically. Hopefully it will improve your's as well.

How to edit Grub boot order

     Phewwww!!! Finally, some relief from tests and tuts... It's been a long time since my last post. Life has been just too busy all this time ... painfully busy.
     A lot of people have recently asked me about changing the GRUB boot order, having installed linux quite enthusiastically. So here's a HOW-TO for the same :

sudo gedit /boot/grub/menu.lst

      Now you can customize and configure your GRUB boot loader from here. The first option you will find is 'default'. The default value for this option is 0.

default 0

      You just need to change this 0 to 3/4/5 according to the OS you want to boot by default. Generally, 0 will be for the linux kernel, 1 for recovery mode and 2 for the memory testing mode. Changing this default value is all you have to do. You can also enable colored GRUB menu by uncommenting the 'color' option. For newbies, uncommenting means deleting the '#' from the line

#color cyan/blue white/blue

      I hope that helps you BD !!! :)

Axel : Download accelerator for linux

Hi guys, the title must have got you really excited if you have been accustomed to downloading in windows using IDM or DAP or any other accelerator. I myself had been searching for such a tool for quite some time now and I was relieved to find Axel. It's a command line downloading tool. And it works!!!
The steps involved are pretty simple. Just another run-of-the-mill installation using yum/apt-get.

Installation : For Fedora users

sudo yum install axel

For Ubuntu users
sudo apt-get install axel

That's it! The installation is done.

Configuring : 1. sudo gedit /etc/axelrc
2. In this file, look out for 'http_proxy='. To set the proxy first uncomment the line by deleting the '#' before http_proxy. Then set the proxy as
http_proxy=http://host.domain.com:port/
eg. http_proxy=http://172.24.2.1:8080/

To download any file, use the command
axel 'fileURL' (without the '' :)
eg. axel http://ubuntuguide.org/wiki/Ubuntu:Feisty
(I had been trying to download this file but everytime I could download only around 40 kb of the total size. Axel downloaded the whole 704 kb just about a couple of minutes using only one connection as the server does not support multiple connections I suppose.)

You can manually set the number of connections to open :
axel -n 16 'fileURL'
Randomly increasing the number of connections wont help. There's a limit upto which the speed can increase, depending on the internet connection you are using.

The file is downloaded in the directory from which you enter the command.

I hope you wont come across any problem while installing and using Axel.
There's another little ultility which integrates apt-get with axel. Keep checking the blog to know more about it.