LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-22-2013, 07:12 AM   #1
nitu09
LQ Newbie
 
Registered: Jan 2013
Posts: 4

Rep: Reputation: Disabled
Regarding the measurement of boot time of a system


I am using linux kernel 3.4.4.I would like to measure the boot time of my system i.e. time between selecting the kernel from GRUB till the login prompt.
I have got one utility i.e. bootchart but I am unable to find the exact boot time from it.However, I need some utility that will tell me that 'xx' seconds were taken for booting.

Thanks in advance
 
Old 01-22-2013, 05:27 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
You won't find such an utility...

There are three steps in booting the current Linux systems.

1) grub selects kernel + initrd.

This system runs from a filesystem in the initrd. There are no disks involved other than the copy of the kernel into memory, and the copy of the initrd into memory. Then the system decompresses the cpio file (the initrd) into a ramdisk; mounts it as root and starts running the startup from there The memory used for the initrd file is released.

2) the initrd disk has a startup procedure that scans the system and initializes/loads any drivers needed to access the local disks. This includes any raid disks, logical volumes (LVM), encrypted filesystems... Once it has identified the appropriate root filesystem it mounts it on /mnt (remember that it is still running from a ramdisk). It then uses a "pivot_root" procedure to exchange the mounted root (the ramdisk) with the mounted root (on /mnt).

3) Once step 2 is completed, the /mnt is dismounted (the ramdisk is released and returned to general memory) and then proceeds to execute the init program from the now mounted root.

Until step 3 is completed, no logs are really available, and the log you see from dmesg is all you will get.

The dmesg log time stamp is in seconds.nanoseconds (http://linuxaria.com/article/how-to-...adable?lang=en), so that is possibly the information you want. It doesn't include the time needed to load the kernel+initrd and decompress the initrd into the ramdisk.

The dmesg log is created in memory during the startup phase. It is copied to disk as one of the first things done to start (or append to) a /var/log/messages file.

The data in memory is in a ring buffer - and that means that it can wraparound (when the buffer is filled, it starts overwriting data at the beginning). For small systems with few devices, this shouldn't be a problem. Large systems with lots of disk drives/peripherals may generate enough log to cause a loss of data.

This is the default. There have been some hacking around done to bypass the initrd entirely. This depends on the kernel itself to have the appropriate drivers (and a filesystem) built into the kernel so that they don't need to be loaded. This can speed booting by eliminating the initrd load, decompression into a ramdisk, and the associated memory allocation/deallocation time (it may actually knock off about 3-5 seconds total, but I don't have any actual times).
 
Old 01-22-2013, 05:31 PM   #3
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
As a bit of an addendum - after the system has initialized syslog, the log timestamps are in a normal format. This is because until then the actual time of the system is still unknown (not read out of the clock, which doesn't have to exist). By this time, the system is nearly ready for use, and the more configurable sections of boot are available (system services are being started).

So you could look into the /var/log/messages file, find the boot, and subtract the the last [seconds.nanoseconds] entry from the first timestamp on the [ 0.000...] log entry.

Last edited by jpollard; 01-22-2013 at 05:36 PM. Reason: small correction
 
1 members found this post helpful.
Old 02-05-2013, 02:56 AM   #4
nitu09
LQ Newbie
 
Registered: Jan 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thank you for the suggestions.
Actually my BE project is on boot time optimization and I need to compare the boot time in case of both traditional shutdown and hibernation. I tried both the bootchart and /var/log/messages and it gives the boot time but this gets created only when the shutdown is performed. And so I am unable to measure the boot time after hibernation.
Is there some other way that can help measuring the boot time after hibernation ?
 
Old 02-05-2013, 05:07 AM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Not without changing the kernel.

The very intent of hibernation is to make the "reboot" invisible to all running applications.

You can detect that it happened(check time of day before and after in a loop.... a jump in interval tells you it happened), but that is about all.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick measurement of free system memory from within C program sgulf Programming 1 07-21-2010 05:30 AM
Total system power measurement piyush masrani Linux - General 2 07-10-2008 12:43 AM
Dual Boot System Fight over system Time TuxLives Mandriva 8 02-14-2008 10:51 AM
i want to increase system boot time adam_blackice Fedora 4 09-10-2006 05:22 PM
system hangs every *other* time I boot stephanie_k Fedora 4 05-23-2004 03:08 PM


All times are GMT -5. The time now is 08:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration