Tuesday, February 26, 2013

How to set NOMODESET and other kernel boot options in grub2

SkyHi @ Tuesday, February 26, 2013
On some hardware configurations, you need to set some kernel parameters for ubuntu to boot or work properly. A common one is nomodeset, which is needed for some graphic cards that otherwise boot in to a black screen or corrupted splash, acpi_osi= to fix lcd backlight and other problems, and noapic and nolapic to work around various ACPI BIOS issues. In this how to I will explain briefly what this is and how to do it.

This how to applies to ubuntu 10.04 and 10.10. It may not apply to wubi, I dont know how to do it in wubi.
(update, see post #8 for the differences with wubi)

What are these options?


The newest kernels have moved the video mode setting into the kernel. So all the programming of the hardware specific clock rates and registers on the video card happen in the kernel rather than in the X driver when the X server starts.. This makes it possible to have high resolution nice looking splash (boot) screens and flicker free transitions from boot splash to login screen. Unfortunately, on some cards this doesnt work properly and you end up with a black screen. Adding the nomodeset parameter instructs the kernel to not load video drivers and use BIOS modes instead until X is loaded. 

Note that this option is sometimes needed for nVidia cards when using the default "nouveau" drivers. Installing proprietary nvidia drivers usually makes this option no longer necessary, so it may not be needed to make this option permanent, just for one boot until you installed the nvidia drivers.

This option frequently solves problems with LCD backlight, fan control problems and misreporting of thermal events. What I understand it does (but corrections are welcome), is prevent the kernel from reporting to the bios that its any windows version the bios asks for. By default, the kernel pretends to be all windows versions, that way we are certain the bios executes all the code needed to initialize the hardware. Unfortunately, some bioses contain fixes to fix problems with specific windows versions (notably vista) that arent needed or dont work for other OS's. Setting
(nothing behind the = sign) as boot option makes the kernel not respond to osi queries.

If the bios has provisions for Linux, you can also try
Or you can try 
acpi_osi="Windows 2006"
To make the kernel pretend its vista and make the bios execute routines on machines that require them.

This disables ACPI completely. 
Note: this may not work with all computers and will disable a lot of useful (or even needed) features. In some cases it may even disable some crucial features, like.. fans. Be careful with this option, it might cause your machine to overheat if the fans no longer turn. Think of this as a last resort. Also note some machines require acpi=ht instead.

Noapic and nolapic
noapic and nolapic kernel options instruct the kernel to not use certain programmable interrupt controllers. To understand what that means exactly requires a deep knowledge of PC hardware, I will not go in to that here, Ill limit myself to saying on some bioses, especially for older systems, there are problems in the implementation of this and it may be necessary to disable either or both to cure a wide range of obscure problems, often but not always related to keyboard and mouse and power management (standby/resume issues).

In some cases kernel drivers can not be loaded due to a lack of virtual addressing space on 32 bit systems. Logs will show errors like
allocation failed: out of vmalloc space - use vmalloc= to increase size.
Details can be found here:

This has been reported by extremejosh who's machine failed to load the restricted nvidia drivers on a geforce 7350 and appears more or less common if you have several tv tuners. Increasing the size of vmalloc to 196 or even more may help in such cases.

How to enable kernel options on the livecd (before install)

If you boot ubuntu from a livecd (or USB stick), right after the bios splash screen you will get a purple screen with a keyboard logo at the bottom:

Press any key at that moment to access a menu. Select your language with the arrow keys, press enter and you will see this menu:

If you press the F6 key, a menu at the bottom will open allowing you to set kernel options with the space bar or enter key. You can close the menu with escape key and resume booting by selecting the option “try ubuntu without installing” (please note that session does allow you to install ubuntu once you found the kernel options cured your problem).

If you need to add kernel options not provided by the F6 menu, you can just type them in at the end of the boot options line.

Important: if you select a kernel boot option from the F6 menu and proceed to boot and later install ubuntu, those boot options will NOT be applied to your installation. If you needed nomodeset to get the livecd to boot, you will almost certainly need it again once you reboot in to your fresh install. See below how to set those options on an installed ubuntu. And perhaps click the “affects me too” on this bug report where I request these settings be applied (semi) automatically.

How to temporarily set kernel boot options on an installed OS (not wubi)

To set kernel boot options, you must edit your grub configuration. You can do this temporarily for a single boot by entering the grub menu. If you do not get to see the grub boot menu after the bios automatically, you may have to press SHIFT key after the bios logo to get in to grub:

Select the default ubuntu kernel (usually the top one), and rather than pressing enter, press E to edit.

Press DOWN ARROW until you get to the line that starts with

linux /boot
and press END keys to position your cursor at the end of the that line usually ending with “quiet splash”. 

Now you can type in additional kernel options like nomodeset (please dont make the same typing error I made for this screenshot  ):

press control+X to boot the modified grub entry.

Important: setting boot options this way only applies to a single boot. If you reboot the machine, those settings will be lost, unless you make them permanent (see below)

How to permanently set kernel boot options on an installed OS (not wubi)

To permanently change the default kernel boot options, press ALT+F2 or open a terminal from system > accessories > terminal. Type in the following command:

gksudo gedit /etc/default/grub
a text editor will open with the grub configuration file. Near the top of that file you will see something very similar to this:
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
add your custom boot options to the GRUB_CMDLINE_LINUX_DEFAULT line, so for instance:

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"
Save the file and exit gedit. If you have to add kernel options that contain quotation marks, add them as such:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset acpi_osi=\"Linux\""
Now in the terminal, run the following command to update your grub configuration with the new default settings:
sudo update-grub
Thats all.