if you want to locationchangestart the start, from the discar

Advanced Boot Options
- Windows 7 Help Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive
section that covers a wide range of tips and tricks.
Show Tutorials
Show Posts
Windows 7: Advanced Boot Options
Published by
How to Boot to the Advanced Boot Options in Windows 7
Some options, such as safe mode, start Windows in a limited state, where only the bare essentials are started. If a problem does not reappear when you start in safe mode, you can eliminate the default settings and basic device
as possible causes. Other options start Windows with advanced features intended for use by system administrators and IT professionals.
Here's How:1. Turn on or restart the computer.
2. If you Multi Boot with more than One Operating System A) At the Windows Boot Manager screen, select the OS you want to use the Advanced Boot Options for, then press F8. (see screenshot below)
NOTE: On some systems, pressing F5 may also work.
3. If you Only Boot with One Operating System (ex: Windows 7)A) Press and keep tapping the F8 key about every second until you see the screenshot below.
NOTE: If the Windows startup logo appears, you will need to repeat steps 1 and 3 again. If you dual boot, then you will need to select the OS you want to use the Advanced Boot Option for and then press F8. On some systems, tapping F5 may also work.
4. Use the arrow keys to select an advanced option to start Windows 7 into and press Enter. (See screenshot above)
NOTE: See the table below for a description of each option. Repair Your Computer Shows a list of
that you can use to repair startup problems, run diagnostics, or restore your system. If Repair your computer isn't listed as an option, then your computer doesn't include preinstalled recovery options, or your network administrator has turned them off. You could also boot from a retail Windows 7 installation disc to see the System Recovery Options.
Safe Mode This starts Windows 7 with a minimal set of drivers and services.
Safe Mode with Networking This starts Windows 7 in safe mode and includes the network drivers and services needed to access the Internet or other computers on your network.
Safe Mode with Command PromptThis starts Windows 7 in safe mode with a
window instead of the usual Windows interface. To exit from here, press Ctrl+Alt+Delete or type Exit and press Enter. Enable Boot Logging Creates a file named ntbtlog.txt, that lists all the drivers that are installed during startup and that might be useful for advanced troubleshooting. Enable Low Resolution Video (640 X 480) Starts Windows 7 using your current video
and using low resolution and refresh rate settings. You can use this mode to reset your display settings, or to use a television monitor with your computer if needed. Last Know Good Configuration (advanced)
Starts Windows 7 with the most recent registry and driver configurations that worked successfully. Every time you turn your computer off and Windows 7 shuts down successfully, important system settings are saved in the registry. You can use those settings to start your computer if a problem occurs. For example, if a new driver for your video card is causing problems, or an incorrect registry setting is preventing Windows 7 from starting correctly, you can restart your computer using Last Known Good Configuration. Directory Services Restore Mode Starts Windows 7 domain controller running Active Directory so that the directory service can be restored. This option is intended for IT professionals and administrators. Debugging Mode Starts Windows 7 in an advanced troubleshooting mode intended for IT professionals and system administrators. Disable Automatic Restart on System Failure Prevents Windows 7 from automatically restarting if an error causes Windows 7 to fail. Choose this option only if Windows 7 is stuck in a loop where Windows 7 fails, attempts to restart, and fails again repeatedly. Disable Driver Signature Enforcement Allows drivers containing improper signatures to be temporarily installed. Start Windows Normally Starts Windows 7 in its normal mode to the logon screen or user desktop. This can be helpful after a improper shutdown.That's it,
Related Tutorials
Related Tutorials
Win 7 Pro 64-bit
I'm familiar with F8 option to get into Advanced Boot Options. My previous laptop was running XP Pro 32-bit and I used ABO often. Purchased new laptop running Win 7 Pro 32-bit but F8 option doesn't seem to work. When clicking F8 a black screen quickly flashes and comp continues to welcome screen. The black screen has nothing to do with ABOs. It seems to have info regarding kernels and other obscure (to me) system info. Unable to get screen shot or even take picture with digital camera. Screen flashes by much too fast. :-( Does this sound like an OS problem or a computer problem?
Hard Drives 640Gb 7200rpm
Antivirus MSE
Browser Opera (primary) with IE9 backup
64-bit Windows 10 Pro
Hello Marsmimar, and welcome to Seven Forums.
Not sure why you are not seeing it. According to the &STEP 3& section in the link below at Dell, you should be able to keep tapping F8 during boot to enter the ABO screen.
Keyboard Logitech Living-Room K830
Mouse Logitech MX Master
PSU OCZ Series Gold OCZZW
Case Thermaltake Level 10 GT Snow Edition
Cooling Corsair Hydro H100
Hard Drives 256GB OCZ Vector
2 x 1TB Samsung HDD HD154UI SATA
Internet Speed 100 Mb/s Download and 10 Mb/s Upload
Antivirus Malwarebyte Anti-Malware Premium
Browser IE11
Other Info Microsoft LifeCam Cinema
* Lite-On iHBS212 12x BD Writer
* Samsung CLX-3175FW Printer
* Netgear Nighthawk X6 R8000 Router
* Arris SB6183 Cable Modem
* APC Back-UPS XS 1500
* APC SMART-UPS RT 1000 XL
Win 7 Pro 64-bit
Thank you for the quick reply. I feel a little foolish.
Accessing the Advanced Boot Options in Windows 7 is slightly different than what I was used to in XP. On my old machine all I had to do was click F8 once and the ABO menu would eventually appear. The secret to accessing ABO with Win 7 (at least on my new machine) is to continue clicking F8 until the clicking produces a beeping sound. Each beep seems to equal about one second that the mysterious black screen will remain visible. When that black screen disappears the ABO menu appears.
I also found out through trial and error (mostly error) that clicking the F5 key during startup also allows access to the ABO as well as a couple of other options.
Thanks for all the great info on this site!
Hard Drives 640Gb 7200rpm
Antivirus MSE
Browser Opera (primary) with IE9 backup
64-bit Windows 10 Pro
You're welcome Marsmimar. I'm happy to hear that you got it sorted out. Thanks for the F5 tip.
Keyboard Logitech Living-Room K830
Mouse Logitech MX Master
PSU OCZ Series Gold OCZZW
Case Thermaltake Level 10 GT Snow Edition
Cooling Corsair Hydro H100
Hard Drives 256GB OCZ Vector
2 x 1TB Samsung HDD HD154UI SATA
Internet Speed 100 Mb/s Download and 10 Mb/s Upload
Antivirus Malwarebyte Anti-Malware Premium
Browser IE11
Other Info Microsoft LifeCam Cinema
* Lite-On iHBS212 12x BD Writer
* Samsung CLX-3175FW Printer
* Netgear Nighthawk X6 R8000 Router
* Arris SB6183 Cable Modem
* APC Back-UPS XS 1500
* APC SMART-UPS RT 1000 XL
Windows 7 Home Premium x64
How come this guide references Vista instead of 7 a lot
Try searching in your browser (ctrl+f) and type vista to see what Im talking about
Great Guide though!!
Hard Drives 223 GB HDD
64-bit Windows 10 Pro
Whatever do you mean?
Keyboard Logitech Living-Room K830
Mouse Logitech MX Master
PSU OCZ Series Gold OCZZW
Case Thermaltake Level 10 GT Snow Edition
Cooling Corsair Hydro H100
Hard Drives 256GB OCZ Vector
2 x 1TB Samsung HDD HD154UI SATA
Internet Speed 100 Mb/s Download and 10 Mb/s Upload
Antivirus Malwarebyte Anti-Malware Premium
Browser IE11
Other Info Microsoft LifeCam Cinema
* Lite-On iHBS212 12x BD Writer
* Samsung CLX-3175FW Printer
* Netgear Nighthawk X6 R8000 Router
* Arris SB6183 Cable Modem
* APC Back-UPS XS 1500
* APC SMART-UPS RT 1000 XL
Windows 7 Home Premium x64
I think I saw misprints. Maybe it was my brain thinking that vista should have these but here is one thats real
3. Use the arrow keys to select an advanced option to start Vista into and press Enter.
Hard Drives 223 GB HDD
64-bit Windows 10 Pro
LOL, no you weren't imaging things. It was copied over from our
and updated for Windows 7, but I missed a few Vistas in there. Thank you for letting me know about them.
Keyboard Logitech Living-Room K830
Mouse Logitech MX Master
PSU OCZ Series Gold OCZZW
Case Thermaltake Level 10 GT Snow Edition
Cooling Corsair Hydro H100
Hard Drives 256GB OCZ Vector
2 x 1TB Samsung HDD HD154UI SATA
Internet Speed 100 Mb/s Download and 10 Mb/s Upload
Antivirus Malwarebyte Anti-Malware Premium
Browser IE11
Other Info Microsoft LifeCam Cinema
* Lite-On iHBS212 12x BD Writer
* Samsung CLX-3175FW Printer
* Netgear Nighthawk X6 R8000 Router
* Arris SB6183 Cable Modem
* APC Back-UPS XS 1500
* APC SMART-UPS RT 1000 XL
Microsoft Windows
Hi no matter what option i choose, it will not boot or progress to anything, the 'repair your computer' goes to a blank screen and does nothing. safe mode starts loading files, stops then restarts, so i am now back to square 1. what can i possibly do to get it to boot. it is really new and i dont have any files on it so i wouldnt mind if i lost them. can i somehow re-install windows 7? it didnt come with the installation CD though and it was pre-installed.
&Advanced Boot Options
Similar help and support threads
Hi everyone ,
I am a new member of this forum and this is my 1st post so please bear with me on this one
i bought new desktop computer with windows 7 professional sp1 64bit
HP elite 8200 sff - i5- 2400 ghz
intel hd graphic
everything works oky except ( f8 advanced boot...
Installation & Setup
Hello forum. I am having some problems with my PC. First off, I'm having a problem with the new ATI catalyst drivers and games.
I get a lot of artifacts in the games such as MW3 and I've tried everything from uninstalling to searching the registry for entries about ATI and AMD.
Thats not why...
Installation & Setup
So does altering anything in the BOOT Advanced Options allow for quicker boot times? In terms of Porcessors used and RAM allocated? Just wondering.
Performance & Maintenance
After looking at this thread, I went to the options and noticed that the Number of Processes checkbox was unchecked and the drop down list was grayed out.
I have an E6750 CPU, so it's a Duo Core 2, thus has 2 processors.
What effect on my computer/booting would checking this box have and...
Performance & Maintenance
Hello everyone,
This is my first post on this forum, so forgive me if this is not the correct board or I do something incorrectly.
Now then, I have a computer that was on vista that I just upgraded to Windows 7 Ultimate 32 bit. When it was on vista and you went to the advance boot options...
Installation & Setup
Advanced Boot Options has been coming up on its own everytime I have started my computer up. It first started doing this when I was running Vista 32bit then
64bit and has followed me onto Windows 7 64bit. How do I go about disabling it? Thanks in advance.
General Discussion
Site Links
Windows 7 Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows 7" and related materials are trademarks of Microsoft Corp.
All times are GMT -5. The time now is .EXTRAVERSION = -rc3
So this git clone produced roughly the same result as getting
the tar file, except that the additional subdirectory .git
contains the entire metadata and history since git was started.
We can look at the history since
(Linux-2.6.12-rc2) by
% git log | less
and see that there were 74426 commits in less than 1000 days,
about 77 per day on average, with a maximum of 914 commits
on Tue Oct 16 2007.
A graphical version of the history is given by gitk.
More history:
% git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/old-2.6-bkcvs.git old-2.6-bkcvs
yields a repository with the history from
all data from the bitkeeper time.
One can browse a lot of git repositories at
Upgrading to current is done by
% cd git/linux-2.6
% git pull git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Looking at the changes for a file, say fs/autofs/inode.c is done by
% git-whatchanged fs/autofs/inode.c
(for the commit messages), or
% git-whatchanged -p fs/autofs/inode.c
(for the actual changes).
Compiling the kernel
Do a cd into the top source directory
(with arch, Documentation, etc.),
then do something like
make oldconfig
make depend
make bzImage
There is a number of configuration targets, like
xconfig, menuconfig, oldconfig.
Pick one and specify what kind of a kernel you want.
(What hardware must be supported, what filesystem types, etc.)
If you are greedy and make a big kernel, you cannot boot from floppy.
If you are very greedy, you may not be able to boot at all,
so asking for "everything" may be counterproductive.
The target oldconfig means "the same as last time",
and uses the file .config that you hopefully still have.
When starting from scratch it may take a number of attempts
before you have a kernel that boots and supports your hardware.
Recent kernels may require recent compiler or binutils to compile,
and recent utilities to use. See Documentation/Changes.
Booting a new kernel
Probably you use some boot loader, like lilo or grub.
Or perhaps you want to boot from a floppy.
After compilation you have a file arch/i386/boot/bzImage
(assuming that was on a PC). For a bootfloppy, dd this file to
an empty diskette. Otherwise, copy the file to /boot,
add it to /etc/lilo.conf or /boot/grub/grub.conf
or so, run lilo and lilo -R if you are a lilo user,
and reboot into your new kernel.
Grub allows you a menu with possible kernels to boot. That is nice.
Lilo has a much better feature: lilo -R allows you to
set the kernel to boot into for the next time only.
So, for kernel development lilo is easier than grub: make a new
kernel, try a boot, probably something will fail, and the next reboot
is into the good old solid kernel again.
On the other hand, lilo has a disadvantage: you must
rerun lilo after installing a new kernel, and very obscure
things will happen if you forget.
Never delete your old kernel. Maybe the new one doesn't work.
(And if you use Appletalk only once a month, and Appletalk
doesn't work in the new kernel, it'll take a month before you
Problems booting
What if the kernel doesn't boot?
There are many possible explanations.
If the boot crashes very early, say, after
Uncompressing Linux... Ok, booting the kernel.
then check that it was compiled for the right hardware.
If the processor type was chosen correctly, check whether
things go better with fewer options selected. A too big
kernel will crash.
If the crash comes later, then hopefully the boot messages give
some indication of what point in the boot process was reached
when things went wrong.
A common mistake is to want to have as many modules as possible.
If the driver needed to access disk (or partition, or filesystem)
for the root filesystem is a module, then it must be loaded
before it can be loaded from disk, and that is impossible.
The typical reaction is the panic
Kernel panic: VFS: Unable to mount root from 08:07
where the hex numbers indicate the device.
Examples of config files
Example of a grub.conf file:
# /boot/grub/grub.conf
timeout=10
splashimage=(hd0,1)/boot/grub/splash.xpm.gz
title 2.4.18-pre7-ac3a-unclip-scsi
root (hd0,1)
kernel /boot/bzImage-2.4.18-pre7-ac3a-unclip-scsi ro root=/dev/hda2
title 2.4.20pre4bs
root (hd0,1)
kernel /boot/bzImage-2.4.20pre4bs ro root=/dev/hda2
title Red Hat Linux (2.4.7-10)
root (hd0,1)
kernel /boot/vmlinuz-2.4.7-10 ro root=/dev/hda2
initrd /boot/initrd-2.4.7-10.img
title WINNT
rootnoverify (hd1,1)
chainloader +1
rootnoverify (hd0,0)
chainloader +1
Example of a lilo.conf file:
# /etc/lilo.conf
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
timeout=50
image=/boot/vmlinuz-2.0.34-0.6
label=linux
root=/dev/hda5
# 2.2.1 plus disk output
image=/boot/bzImage-test
label=test
root=/dev/hda5
other=/dev/hda1
table=/dev/hda
and another one:
# /etc/lilo.conf
= /dev/hda
= /dev/hda
= /dev/hdb
= /dev/hde
= /dev/hdf
change-rules
menu-scheme = Wg:kw:Wg:Wg
timeout = 80
message = /boot/message
image = /boot/bzImage-2.5.38a
label = 2.5.38a
= /dev/hdb6
append = "rootfstype=ext3 hdc=ide-scsi"
image = /boot/bzImage-2.4.19a
label = 2.4.19a
= /dev/hdb6
append = "rootfstype=ext3 hdc=ide-scsi"
# SuSE warning: eth0 and eth2 interchanged
= /boot/vmlinuz
= /dev/hdb6
initrd = /boot/initrd
append = " ide=nodma apm=off acpi=off hdc=ide-scsi"
= /boot/memtest.bin
= memtest86
Exercise Get, compile and boot 2.4.17. It is stable.
It is possible to load kernel code at run time without rebooting.
Most hardware and filesystem drivers exist as module, and the
commands lsmod, insmod, rmmod allow
you to manipulate them. Normally life is easier if you just
compile all you need into the kernel, but when developing a
new driver it is very useful to be able to insmod
the latest version, try it, rmmod again, edit and
compile the driver, and repeat.
There is a kernel module loader that, when enabled, will find and load
modules automatically when needed. Since modules come from disk,
the code required to find them (disk driver, filesystem driver)
cannot itself be a module.
During configuration there are the choices Y=yes, N=no, M=module.
The command make modules compiles the modules.
It is very easy to make modules oneself. An example:
* demo-module.c
* Compile with
gcc -I/path-to-linux-tree/include -D__KERNEL__ -DMODULE -O2 \
-Wall -Wstrict-prototypes -c -o demo-module.o demo-module.c
#include &linux/init.h>
#include &linux/module.h>
static int __init demo_init(void) {
printk("initializing..\n");
static void __exit demo_exit(void) {
printk("goodbye!\n");
module_init(demo_init);
module_exit(demo_exit);
MODULE_LICENSE("GPL");
Now after compilation an insmod demo-module.o will produce
the message initializing.., while rmmod demo-module
will say goodbye!. (Where are these messages? Wherever you
are sending kernel output. Maybe on some virtual console, or maybe
in a system log, like /var/log/messages. Recent messages
are also visible in the output of the dmesg command.)
Written like this, the module will work both when compiled into
the kernel, and when inserted as a separate module.
Later we'll make less trivial modules.
Why this MODULE_LICENSE? After getting many kernel bug reports caused by
the insertion of third party modules that were binary-only and hence
cannot be fixed, developers made the kernel keep track of any non-open
code encountered, so that bug reports involving non-open code could be
simply disregarded. One says that the kernel was tainted.
Some docs on kernel modules live on
. Note - this
is rather outdated material, written mostly for 2.0 and 2.2.
Many details are a bit different now.
Modules under Linux 2.5 and 2.6
The above was good enough for normal purposes under Linux 2.4.
Things have become more complicated under Linux 2.5, and
it is now easiest not to invoke gcc by hand but to let
the kernel make system do the job.
Instead of invoking gcc we make a 1-line
# cat Makefile
obj-m := demo-module.o
and then compile the module with
make -C /path-to-linux-tree SUBDIRS=$PWD modules
This time the module is called demo-module.ko with .ko
instead of .o. And everything works:
# insmod demo-module.ko
initializing..
# rmmod demo-module
Modules and copyright
we mentioned that the kernel is distributed
under GPL. What about modules?
Copyright law protects a work and derived works.
Remains the question how far "derived" reaches in case of the kernel.
Are user space programs "derived works"? The file COPYING
NOTE! This copyright does *not* cover user programs that use kernel
services by normal system calls - this is merely considered normal use
of the kernel, and does *not* fall under the heading of "derived work".
making clear that no copyright on user space programs is claimed. Good.
Are modules derived works? Generally the answer is claimed to be Yes.
Here some fragments of
Subsystems - layout of the tree
The kernel initialization code (after the architecture-specific part
has finished) is found in init.
The process handling (fork, signal, exit) lives in kernel.
The Unix filesystem interface (open, close, read, write, chdir, link, unlink,
stat, mount, umount) lives in the subdirectory fs.
SysV interprocess communication in ipc.
Next, the various filesystems. They live in subdirectories
below fs (like adfs, affs, autofs,
bfs, coda, cramfs, devfs, devpts,
driverfs, efs, ext2, ext3,
fat, hfs, hpfs, intermezzo,
isofs, jfs, minix, msdos,
ncpfs, nfs, ntfs, proc,
qnx4, ramfs, reiserfs, romfs,
smbfs, sysv, udf, ufs,
vfat, xfs).
And so does the partition table reading code (in fs/partitions).
Then the memory management, kmalloc(), swapping, etc.
is found in mm.
Then the network code (not the device drivers, but the various
protocols, such as TCP/IP), in net.
The device drivers, say for ethernet or so, live in
drivers/net.
Linux runs on lots of different architectures: Intel and non-Intel PC,
DEC Alpha, Apple MacIntosh, PPC, Atari, etc. etc.
All architecture-specific code is found under arch
(maybe with subdirectories alpha, arm, arm26,
cris, h8300, i386, ia64, m68k,
m68knommu, mips, mips64, parisc,
ppc, ppc64, s390, s390x, sh,
sparc, sparc64, um, v850, x86_64).
The I/O subsystem and device drivers live mostly under drivers.
It has subdirectories scsi, ide, usb etc.
The include files for the kernel source live under include
(and not under /usr/include). It is a very bad idea to
make a symlink /usr/include/linux pointing at some
development source tree.
Under lib some useful library routines.
Under scripts some scripts used for kernel compilation.
A random collection of docs lives under Documentation,
some parts nicely formatted with DocBook markup.
The commands make htmldocs and make psdocs
will take the specially formatted doc-comments from the kernel source,
producing kernel-api.html and kernel-api.ps,
describing the public interfaces to the various kernel subsystems.
The C code
The Linux kernel is written in C, and compiled by gcc.
Various gcc extensions are used, so it is not easy to use
a different compiler. A few architecture-specific fragments
are in assembler.
The code is self-contained, no library is linked in.
In particular, standard routines like printf()
are not available. (But there is printk() that does
more or less the same.) However, the kernel has its own library,
and things like strcpy() exist.
The desired style should be obvious from looking at the main
parts of the kernel. Some device drivers are painful to behold.
Linus commented on the desired coding style in the file
Documentation/CodingStyle. A quote:
First off, I'd suggest printing out a copy of the GNU coding standards,
and NOT read it.
Burn them, it's a great symbolic gesture.
Generally, Kernigham & Ritchie style layout is used, with 8-space tabs.
Try indent -kr -i8.
Note that goto's are not avoided. Instead of
err = allocate_foo();
if (!err) {
err = allocate_bar();
if (!err) {
err = allocate_baz();
if (!err) {
deallocate_bar();
deallocate_foo();
deallocate_foo();
err = allocate_foo();
err = allocate_bar();
if (err) {
deallocate_foo();
err = allocate_baz();
if (err) {
deallocate_bar();
deallocate_foo();
one writes the much clearer
err = allocate_foo();
err = allocate_bar();
goto out1;
err = allocate_baz();
goto out2;
deallocate_bar();
deallocate_foo();
Not only is this cleaner, it is also faster: the main path
of the code is not cluttered with error-handling code.
__user and sparse
Linus wrote a C parser meant to keep track of the distinction
between pointers to kernel and to user space. The latter are annotated
with __user. The parser is known as sparse,
and has a bitkeeper home. There is also a
After installing this parser, one may run a check by doing
make C=1 (check the source files that get recompiled)
or make C=2 (check all). This is very incomplete, work in progress.
A standard idiom found throughout the kernel are the list
handling primitives list_add, list_del,
list_entry, list_for_each, list_for_each_entry.
These primitives describe doubly linked circular lists, with nodes
struct list_head {
struct list_head *next, *
with the obvious
/* add new node after given node */
void list_add(struct list_head *new, struct list_head *before) {
struct list_head *after = before->
after->prev =
new->next =
new->prev =
before->next =
void list_del(struct list_head *entry) {
entry->prev->next = entry->
entry->next->prev = entry->
Now list_for_each runs over the list nodes different
from the starting node:
#define list_for_each(pos, head) \
for (pos = (head)-> pos != (head); pos = pos->next)
It is called with a local temp variable pos.
Usually a list_head is member of a larger structure.
For example, a struct inode contains
struct list_head i_hash, i_list, i_dentry, i_devices
four such structs, so that each inode is on four cyclic lists.
If we walk such a cyclic list, then we find for example the
address of the i_dentry in order
to get the address of the inode itself we have to subtract the
offset of the i_dentry field in a struct inode.
This is done by the macro container_of:
#define container_of(ptr, type, member) ({
const typeof( ((type *)0)->member ) *__mptr = (ptr);
(type *)( (char *)__mptr - offsetof(type,member) );})
Thus, container_of(x, struct inode, i_dentry)
returns the address of the inode that has an i_dentry
field with address x.
In this list handling context we have the alias list_entry
of container_of:
* list_entry - get the struct for this entry
the &struct list_head pointer.
the type of the struct this is embedded in.
* @member:
the name of the list_struct within the struct.
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)
Now we can iterate over all structs containing the nodes
of a given cyclic list using list_for_each_entry:
#define list_for_each_entry(pos, head, member)
for (pos = list_entry((head)->next, typeof(*pos), member);
&pos->member != (head);
pos = list_entry(pos->member.next, typeof(*pos), member))
Again, this visits all such structs except for the starting one.
Another idiom found all over the place is defined in err.h:
ERR_PTR casts a long to a pointer, PTR_ERR casts a pointer to a long,
and IS_ERR applied to a pointer checks whether the numerical value
lies between -999 and -1 (inclusive) and hence by convention is the
negative of an error number.
Logging kernel messages
The kernel prints messages using the printk() function.
We want to see them somewhere on a console, and also log
them to a file.
The function printk() (see kernel/printk.c)
is very similar to the well-known printf() in user space.
One difference is that texts printed start with a priority level
in the form of a string like "&4&".
#define KERN_EMERG
/* system is unusable
#define KERN_ALERT
/* action must be taken immediately
#define KERN_CRIT
/* critical conditions
#define KERN_ERR
/* error conditions
#define KERN_WARNING
/* warning conditions
#define KERN_NOTICE
/* normal but significant condition
#define KERN_INFO
/* informational
#define KERN_DEBUG
/* debug-level messages
In /proc/sys/kernel/printk we see four numbers:
console_loglevel (7),
default_message_loglevel (4),
minimum_console_loglevel (1),
default_console_loglevel (7).
Messages with priority larger than console_loglevel are printed
to the console. (Higher priority means smaller priority level.)
Lines without explicit priority indication are
printed with priority default_message_loglevel.
The smallest allowed value of console_loglevel is
minimum_console_loglevel. The default value of
console_loglevel is default_console_loglevel.
(Thus, by default, all is printed to the console, except for debug messages.
Distributions often set the console_loglevel to 1, suppressing
messages to the console that might disturb users.)
These values can be changed using the syslog() system call
(see below), or using the sysctl() system call, or by
echoing new values to /proc/sys/kernel/printk.
# cat /proc/sys/kernel/printk
# echo "2 4 3 7" > /proc/sys/kernel/printk
# cat /proc/sys/kernel/printk
The sysctl() version goes as follows:
% cat > printk_sysctl.c && EOF
#include &stdio.h>
#include &sys/sysctl.h>
#define SIZE(a) (sizeof(a)/sizeof((a)[0]))
int name[] = { CTL_KERN, KERN_PRINTK };
int printk_params[4];
int new_params[4];
int main(int argc, char **argv) {
int paramlth = sizeof(printk_params);
if (argc == 1) {
/* report */
if (sysctl(name, SIZE(name),
printk_params, &paramlth, 0, 0)) {
perror("sysctl");
printf("got %d bytes:\n", paramlth);
printf("console_loglevel: %d\n", printk_params[0]);
printf("default_message_loglevel: %d\n", printk_params[1]);
printf("minimum_console_loglevel: %d\n", printk_params[2]);
printf("default_console_loglevel: %d\n", printk_params[3]);
} else if (argc == 5) {
for (i=0; i&4; i++)
new_params[i] = atoi(argv[i+1]);
if (sysctl(name, SIZE(name),
0, 0, new_params, sizeof(new_params))) {
perror("sysctl");
printf("set new printk parameters\n");
fprintf(stderr, "Call: %s [N N N N]\n", argv[0]);
% cc -o printk_sysctl printk_sysctl.c
% ./printk_sysctl
got 16 bytes:
console_loglevel: 2
default_message_loglevel: 4
minimum_console_loglevel: 3
default_console_loglevel: 7
% ./printk_sysctl 1 4 1 7
sysctl: Operation not permitted
# ./printk_sysctl 1 4 1 7
set new printk parameters
Ringbuffer
Messages are printed to a ring buffer, so that later messages overwrite
earlier ones. The size of this buffer can be set at compile time.
Long ago it was 4096. Today 16384 is the default, on some architectures
up to 131072.
This ringbuffer is available for reading via /proc/kmsg.
However, this is a read-once interface: data disappears as soon as
it is read. There is also the dmesg command, that reads
nondestructively.
The console(s) printed to are determined at boot time (but see below).
A kernel boot parameter console= gives a virtual or serial
console to be printed to, and one may have several such lines.
The format is console=device,option, e.g.,
console=tty0: print to the foreground VT (this is the default), or
console=tty12: print to /dev/tty12, or
console=ttyS1,2400: print to the serial line /dev/ttyS1
at 2400 baud, or
console=lp0: print to the printer.
The option for a serial line is a number specifying baud rate,
followed by a letter (one of n,o,e)
specifying parity (none, odd, even),
followed by a number of bits. Default is 9600n8.
In order to use a serial console, serial port support (CONFIG_SERIAL_8250)
and console on serial port (CONFIG_SERIAL_8250_CONSOLE)
must be enabled in the kernel config.
The file /dev/console refers to the last console mentioned,
or to /dev/tty0 by default.
A 2400 baud serial console.
Instead of an old terminal, one may also use another PC as serial console.
Connect both machines with a null-modem cable. Run some communications program
on the Serial Console machine, for example kermit.
(SC) # kermit
C-kermit> set port /dev/ttyS1
C-kermit> set speed 38400
C-kermit> set carrier-watch off
C-kermit> connect
These commands can be put into .kermrc.
Kermit will become unhappy when programs on the other side fiddle with
the serial line. The typical result is "Communications disconnect".
Instead of convincing all programs that touch serial lines
(such as the setserial boot script, and the X server)
to leave the line used alone, one can simply rename the device:
# mv /dev/ttyS0 /dev/ttyS0-sc
Netconsole
When the kernel crashes during the boot, one can log the messages
via the netconsole to a different machine. On the other machine, run
% netcat -u -l 5555
(this listens to incoming UDP packets on the specified port
and prints the contents on stdout).
On the booting machine make sure the kernel was compiled with
CONFIG_NETCONSOLE=y and give kernel command line parameters
netconsole=.1.40/eth2,.1.50/01:23:45:67:89:AB
that is, the source port, source IP address, source ethernet device,
destination port, destination IP address, destination MAC address.
The port numbers are arbitrary.
Redirecting kernel VT output
If the console is a VT, then it is possible to redirect kernel
messages to a different, already existing, VT by use of the
TIOCLINUX ioctl:
/* Send kernel messages to a given console */
/* (Abbreviated version of setlogcons.c) */
#include &stdio.h>
#include &stdlib.h>
#include &sys/ioctl.h>
int main(int argc, char **argv){
struct { char fn, }
if (argc == 2)
cons = atoi(argv[1]);
/* current console */
arg.fn = 11;
/* redirect kernel messages */
arg.subarg =
/* to specified console */
if (ioctl(0, TIOCLINUX, &arg)) {
perror("TIOCLINUX");
Redirecting console output to a pseudotty
Using the TIOCCONS ioctl one can redirect
console output to a pseudotty. This is what xterm -C
and xconsole do.
A small demo:
* compile with
cc -o pseudocons pseudocons.c -lutil
#include &stdio.h>
#include &errno.h>
#include &fcntl.h>
#include &stdlib.h>
#include &unistd.h>
#include &string.h>
#include &termios.h>
#include &pty.h>
#include &sys/ioctl.h>
die(char *s) {
perror(s);
int main() {
int masterfd, slavefd,
if (openpty(&masterfd, &slavefd, NULL, NULL, NULL) & 0)
die("openpty");
printf("got master\n");
if (ioctl(slavefd, TIOCCONS, 0)) {
if (errno != EBUSY)
die("TIOCCONS");
printf("trying to steal console\n");
fd = open("/dev/tty0", O_WRONLY);
if (fd & 0)
die("open /dev/tty0 fails");
if (ioctl(fd, TIOCCONS, 0))
die("TIOCCONS tty0");
if (ioctl(slavefd, TIOCCONS, 0))
die("TIOCCONS");
printf("got slave console\n");
while (read(masterfd, &c, 1) == 1)
printf("%c\n", c);
with application:
% cc -Wall -o pseudocons pseudocons.c -lutil
% ./pseudocons
got master
trying to steal console
TIOCCONS tty0: Operation not permitted
# ./pseudocons
got master
trying to steal console
got slave console
where the output arose because of
# echo Hoera.. > /dev/console
done in another window.
syslog / klogctl
The syslog() system call (not to be confused with the
library function of the same name) serves to set logging parameters
and give access to the ringbuffer. The glibc interface is called
klogctl(). The prototype is
int klogctl(int type, char *bufp, int len);
The first parameter specifies one of 10 possible subfunctions:
* Commands to do_syslog:
0 -- Close the log.
Currently a NOP.
1 -- Open the log. Currently a NOP.
2 -- Read from the log.
3 -- Read all messages remaining in the ring buffer.
4 -- Read and clear all messages remaining in the ring buffer
5 -- Clear ring buffer.
6 -- Disable printk's to console
7 -- Enable printk's to console
8 -- Set level of messages printed to console
9 -- Return number of unread characters in the log buffer
For details, see syslog(2).
A common setup is to have a daemon klogd(8) read the kernel
ringbuffer, and feed the messages to syslogd(8).
What happens next depends on the syslogd configuration,
see syslog.conf(5). In the file /etc/syslog.conf
one can specify what mailboxes and consoles and files and internet
connections system log messages should be sent to. This is much more
than just kernel messages - many daemons report their things via
the syslog mechanism. For example, lines
kern.*.authpriv.none
/dev/tty10
*.*;mail.news.none
-/var/log/messages
cause messages in certain categories to be sent to /dev/tty10
and to the file /var/log/messages. The leading -
says that it is not necessary to sync() after every write.
Under X one can start xconsole.
It captures messages written to /dev/console (or some
other specified file) and displays them in an X window.
A similar effect may be achieved by xterm -C.
You may have to be root to get permission to open /dev/console.
(Or you can make some login script invoke GiveConsole.)
The mechanism is provided by the TIOCCONS ioctl discussed above.
Inserting calls to printk() is safe on most places
in the kernel. Of course one should not put such calls in the
code that handles printk() output, or an infinite amount
of output will be generated, or, in case such code acquires locks,
a deadlock will result. The variable oops_in_progress
can be set to 1 to break certain locks, and to make sure klogd
is not woken up.
Very early printk
If the kernel hangs or crashes early in the boot sequence,
before the console has been initialized, one can trace what is
happening by writing messages "by hand" to video memory.
Keyboard interface to the kernel
It is possible to directly ask kernel info from the keyboard
(when at a virtual console), also when no process is reading it.
Sometimes it is possible in this way to collect some information
when most of the kernel has crashed.
Show Registers
First of all Show_Registers (AltGr-ScrollLock), where AltGr
is the right Alt key. It produces a register dump.
Pid: 0, comm:
EIP: 0060:[&c01088f4>] CPU: 0
EIP is at default_idle+0x24/0x30
Not tainted
EBX: c01088d0 ECX:
EDX: c12bef50
ESI: c0532000 EDI: c01088d0 EBP:
DS: 007b ES: 007b
CR0: 8005003b CR2: 084b496c CR3: 0f913000 CR4:
Call Trace:
[&c0108972>] cpu_idle+0x32/0x50
[&c0105000>] _stext+0x0/0x20
This dump is written using printk hence also goes
to wherever printk output goes (e.g. to /var/log/messages).
Show State
Next is Show_State (Ctrl-ScrollLock). It produces a very long output,
listing for every process in the system some data and a stack trace.
Call Trace:
[&c032a883>] normal_poll+0x113/0x12b
[&c011db3f>] schedule_timeout+0x7f/0xa0
[&c011dab0>] process_timeout+0x0/0x10
[&c014e3cf>] do_select+0x1ef/0x230
[&c014e060>] __pollwait+0x0/0xa0
[&c014e759>] sys_select+0x319/0x470
[&c0109c85>] restore_sigcontext+0x115/0x140
[&c0119a13>] sys_gettimeofday+0x43/0xa0
[&c010a72b>] syscall_call+0x7/0xb
Since the result probably scrolls off the screen, one may have to use
the dmesg command, or inspect the syslog, in order to read the
Show Memory
Finally Show_Memory (Shift-ScrollLock). It shows the memory situation.
DMA per-cpu:
cpu 0 hot: low 2, high 6, batch 1
cpu 0 cold: low 0, high 2, batch 1
Normal per-cpu:
cpu 0 hot: low 28, high 84, batch 14
cpu 0 cold: low 0, high 28, batch 14
HighMem per-cpu: empty
Free pages:
15440kB (0kB HighMem)
Active:31177 inactive:22639 dirty:6 writeback:0 free:3860
DMA free:6000kB min:128kB low:256kB high:384kB active:2316kB inactive:3008kB
Normal free:9440kB min:1020kB low:2040kB high:3060kB active:122392kB inactive:87548kB
HighMem free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB
DMA: 134*4kB 71*8kB 40*16kB 27*32kB 17*64kB 2*128kB 0*256kB 0*512kB 0*1024kB 1*2048kB 0*4096kB = 6000kB
Normal: 0*4kB 2*8kB 1*16kB 0*32kB 51*64kB 26*128kB 5*256kB 1*512kB 1*1024kB 0*2048kB 0*4096kB = 9440kB
HighMem: empty
Swap cache: add 0, delete 0, find 0/0, race 0+0
Free swap:
65520 pages of RAM
0 pages of HIGHMEM
1891 reserved pages
31170 pages shared
0 pages swap cached
Other commands
Also a few virtual console housekeeping commands are implemented
via this same mechanism.
There are keys for scroll up (Shift-PgUp) and scroll down (Shift-PgDn).
Keys to change virtual console: Decr_Console (Alt-LArrow),
Incr_Console (Alt-RArrow), Last_Console (unbound).
Finally there are three commands: Boot (Ctrl-Alt-Del),
KeyboardSignal (Alt-UpArrow), SAK (unbound).
Key bindings can be changed using loadkeys.
Magic SysRequest
When so configured, there is one more keyboard mechanism.
Build the kernel with CONFIG_MAGIC_SYSRQ enabled.
In some kernel versions you then have an active
Magic SysRequest key, but in other kernels you first have
echo 1 > /proc/sys/kernel/sysrq
to activate this key.
A command is given by pressing three keys simultaneously:
Alt-SysRq-X, where X is the command letter.
(On a serial console one gives a Break, followed by the command letter.)
Since Linux 2.4.21/2.5.66 it is also possible to do
echo X > /proc/sysrq-trigger
with the same effect as the keystroke.
Command letters
Set kbd mode to XLATE (not RAW)
SAK (Secure Attention Key)
Immediate reboot, no umount, no sync
Shut Off system
Remount all filesystems read-only
Print registers on console, like Show_Registers above.
Print tasks on console, like Show_State above.
Print memory info on console, like Show_Memory above.
0-9 Set console loglevel
Send every process SIGTERM
Send every process SIGKILL
One should make sure that this facility is always switched off
in a production environment.
Profiling the kernel
There are several facilities to see where the kernel spends
its resources. A simple one is the profiling function, that
stores the current EIP (instruction pointer) at each clock tick.
Boot the kernel with command line option profile=2
(or some other number instead of 2). This will cause
a file /proc/profile to be created.
The number given after profile= is the number of positions
EIP is shifted right when profiling. So a large number gives a
coarse profile.
The counters are reset by writing to /proc/profile.
The utility readprofile will output statistics for you.
It does not sort - you have to invoke sort explicitly.
But given a memory map it will translate addresses to kernel symbols.
See kernel/profile.c and fs/proc/proc_misc.c
and readprofile(1).
For example:
# echo > /proc/profile
# readprofile -m System.map-2.5.59 | sort -nr | head -2
510502 total
508548 default_idle
The first column gives the number of timer ticks.
The last column gives the number of ticks divided by the
size of the function.
The command readprofile -r is equivalent to
echo > /proc/profile.
A more advanced mechanism is given by oprofile.
Prepare kernel
Build a kernel (2.5.43 or later) with CONFIG_PROFILING=y
and CONFIG_OPROFILE=y. Now the kernel knows about the
oprofilefs virtual filesystem. The utilities
mentioned below will mount it on /dev/oprofile.
It is a good idea to add idle=poll to the kernel
this will make sure time spent in the idle thread
is properly accounted for.
Install oprofile
Get the oprofile utility from
Configure with ./configure --with-kernel-support,
then make and (as root) make install.
This yields binaries and a man page:
% ls /usr/local/bin
op_session
op_to_source
oprof_start
% ls /usr/local/share/oprofile
% ls /usr/local/share/doc/oprofile
oprofile.html
% ls /usr/local/man/man1
opcontrol.1
oprofiled.1
op_merge.1
op_to_source.1
oprofile.1
All man pages are links to the oprofile man page.
Thus, there are two sources of information:
% man oprofile
% mozilla /usr/local/share/doc/oprofile/oprofile.html
Setup oprofile
Make sure you are root and your PATH contains /usr/local/bin.
The first action required is invoking opcontrol --setup ....
This will create a setup file /root/.oprofile/daemonrc.
You need the big kernel toplevel vmlinux file (not bzImage,
and not the smaller arch/i386/boot/compressed/vmlinux).
# opcontrol --setup --vmlinux=/foo/vmlinux
# cat /root/.oprofile/daemonrc
IGNORE_MYSELF=0
SEPARATE_LIB_SAMPLES=0
SEPARATE_KERNEL_SAMPLES=0
VMLINUX=/foo/vmlinux
BUF_SIZE=0
one_enabled=1
The precise setup call needed depends on your hardware.
The above example is for an old Pentium without hardware performance
counters. For a P3, use
opcontrol --setup --vmlinux=/foo/vmlinux --ctr0-event=CPU_CLK_UNHALTED --ctr0-count=100000
For a P4, use
opcontrol --setup --vmlinux=/foo/vmlinux --ctr0-event=GLOBAL_POWER_EVENTS --ctr0-unit-mask=1 --ctr0-count=100000
For an Athlon or x86-64, use
opcontrol --setup --vmlinux=/foo/vmlinux --ctr0-event=RETIRED_INSNS --ctr0-count=100000
There are many other possible setup options. The command op_help
will list them once you have done the setup :-).
(See also the sourceforge site for
The general idea is that one specifies a certain type of event
(such as CPU_CLK_UNHALTED, a CPU clock cycle), and a count
(like the 100000 above). Now once every count occurrences
of this event the value of EIP is recorded.
Pick the value of count suitably: with a 400 MHz machine a count
of 100000 for CPU_CLK_UNHALTED means 4000 interrupts/second.
Too small a count and the machine dies an interrupt death.
Too large a count and the profile will be very coarse.
Use of oprofile
First start the oprofile daemon.
# opcontrol --start-daemon
Using log file /var/lib/oprofile/oprofiled.log
Daemon started.
# ps ax | grep oprofile
... /usr/local/bin/oprofiled ...
Next clear out old profiling data.
# opcontrol --reset
Next start measuring, do whatever should be measured,
and stop measuring.
# opcontrol --start
Profiler running.
# do_something
# opcontrol --stop
Stopping profiling.
One now has profiling data below /var/lib/oprofile/.
See below for what to do with the data.
When no more profiling is needed, kill the daemon:
# opcontrol --shutdown
Stopping profiling.
Killing daemon.
To clean up all data generated by oprofile (after generating any
desired output):
# rm -r /var/lib/oprofile
A partial cleanup is done by the opcontrol --reset
mentioned above.
To get a printout of the data for /bin/foo, use, e.g.
oprofpp -l -i /bin/foo. The output will be boring,
unless /bin/foo was not stripped after compilation,
so that it contains symbol information.
The programs and libraries that were invoked (and hence are suitable
arguments for oprofpp -l -i ...) and the numbers of ticks spent
in each are given by the command op_time.
With the -l option the output will be split according to symbol.
# op_time | tail -3
9.0 /lib/i686/libc-2.2.4.so
13.0 /usr/bin/find
75.0 /foo/vmlinux
# op_time -l | tail -6
c012c7c0 703
kmem_cache_alloc
/foo/vmlinux
__copy_to_user_ll
/foo/vmlinux
ext3_readdir
/foo/vmlinux
link_path_walk
/foo/vmlinux
c016fcd0 1446
ext3_find_entry
/foo/vmlinux
(no symbol)
/usr/bin/find
To get statistics for the kernel only, use the vmlinux
name specified.
# oprofpp -l -i /foo/vmlinux | tail
c012ca30 488
kmem_cache_free
c010e280 496
mask_and_ack_8259A
c010a61a 506
restore_all
do_softirq
c012c7c0 703
kmem_cache_alloc
__copy_to_user_ll
ext3_readdir
link_path_walk
c016fcd0 1446
ext3_find_entry
One can get disassembly or annotated source with indication
on where the counts occurred.
# op_to_source -a -i /foo/vmlinux
/* 424 1.618% */
c0169ac0 &ext3_check_dir_entry>:
/* 6 0.02289% */
/* 56 0.2136% */
0x18(%esp,1),%esi
/* 43 0.164% */
0x14(%esp,1),%edi
movzwl 0x4(%esi),%ecx
/* 23 0.08775% */
c0169ae0 &ext3_check_dir_entry+0x20>
$0xc032b160,%ebx
# op_to_source --source-dir=. --output-dir=/tmp -i /path/binary
# diff -u ./source.c /tmp
int get_line(register FILE *f, int *length)
+/* get_line 24 54.55% */
/* 5 11.36% */
c = Getc (f);
This profile with annotated source is available only for binaries
compiled with -g2 (and not stripped) so that they still
contain source line numbers.
Debugging the kernel
There does exist a kernel debugger kdb, maintained
as a patch on the kernel source. It can be obtained by anonymous
. For an introduction, see
There are patches for Linux 2.2 and 2.4. I have not seen them for 2.5 yet.
Early stages
Specifying the boot parameter initcall_debug causes
the kernel to print the addresses of all initcalls it executes.
This may allow one to pinpoint the guilty part when the kernel
crashes at boot time. (Since 2.5.67.)
Submitting patches
Read Documentation/SubmittingPatches and perhaps
Documentation/SubmittingDrivers. See also
Talking about the kernel
The main forum is the mailing list known as lk or lkml or linux-kernel
with submission address linux-kernel@vger.kernel.org.
Subscribe to the mailing list by sending the message
subscribe linux-kernel
to Majordomo@vger.kernel.org. Archives exist. There are many more
specialized lists, such as linux-net or linux-fsdevel.
There is a "kernelnewbies" IRC channel, and mailing list, and
with a lot of useful information.
Lots of other places exist.
Brown paper bag bug - A bug one is deeply ashamed of.
Before the release of 2.2.0:
From: Linus Torvalds &>
Subject: (fwd) 2.2.0-final
In short, before you post a bug-report about 2.2.0-final, I'd like you to
have the following simple guidelines:
"Is this something Linus would be embarrassed enough about that he would
wear a brown paper bag over his head for a month?"
"Is this something that normal people would ever really care deeply
If the answer to either question is "probably not", then please consider
just politely discussing it as a curiosity on the kernel mailing lists
rather than even sending email about it to me
After the release of 2.2.0:
From: Linus Torvalds &>
Subject: Linux-2.2.1 - the Brown Paper Bag release
The subject says it all. We did have a few paper-bag-inducing bugs in
2.2.0, so there's a 2.2.1 out there now, just a few days after 2.2.0.
Oh, well. These things happen,

我要回帖

更多关于 change from to 的文章

 

随机推荐