Looking for a faster system boot? Try blacklisting kernel modules

Linux systems today support a wide variety of devices out of the box. For a general system use it is of course a good thing to have a good device support out of the box but if you are using an older computer or just want to have a faster system boot then loading a wide variety of kernel modules might be something you would want to avoid.

The most simplest way to make your system rmore robust is to omit kernel modules from loading during the system boot. Omitting modules or in other words blacklisting them can be achieved with the following simple trick

1.Open your terminal and become a root or a sudo su user

2. Navigate to a folder called /etc/modprobe.d/ :

cd /etc/modprobe.d

3. Open a new terminal window and execute a command called lsmod

With lsmod command you can get the list of kernel modules currently loaded on your system. For example you might see something like this:

Module                  Size  Used by
snd_usb_audio          92167  0
snd_usbmidi_lib        15503  1 snd_usb_audio
snd_hwdep               4746  1 snd_usb_audio
snd_rawmidi            14828  1 snd_usbmidi_lib
snd_seq_device          4252  1 snd_rawmidi
snd_pcm                63876  1 snd_usb_audio
snd_page_alloc          5974  1 snd_pcm
nouveau               850541  2
snd_timer              14942  1 snd_pcm

In the above example you can see the the module and the size it uses. The value “used by” when having a zero means that the module is currently not being actively used.

Note: Being currently not actively used does not mean that the module will not be loaded in any occasion when you are running your system. The loading of a module depends on the ways by which you use your system and programs in it.

Once you have decided what modules you want to blacklist create a new conf file inside /etc/modprobe.d. As a root or a sudo:

nano /etc/modprobe.d/blacklist.conf    Note: nano is a text editor which you can replace by your prefered choice

Once you are iniside the a file which we named as blacklist.conf, in the above, you can blacklist modules as follows:

blacklist snd_usb_audio
blacklist ath9k_common
blacklist ath9k_hw
blacklist usm_realtek
blacklist serio_raw
blacklist psmouse

…….

Remember to be careful when blacklisting modules so that you do not accidentally blacklist something essential. It is always a good plan to have a live cd or some sort of failsafe boot media if you accidentally blacklist some kernel modules which are essential. For a failsafe boot medium I recommend, for example, Linux mint live dvd which gives you easy access to your hard drives, and blacklist.conf file, if something goes wrong.  You can get Linux mint from: http://linuxmint.com/

Aiming for bare minimum? EXTREME CAUTION ADVICED

If you are aiming for bare minimum you can try to get a list of bare essential modules which your system needs. This means that the modules that are listed are only the pure basic ones by which your system can even boot. The previous means that the command shown below will not list something like usb device support modules, keyboard support or mouse support, to give just a few example.  Use the command below with an extreme caution because it may render you system to a state where you cannot log in because your keyboard or mouse or something else does not work.

lspci -mvk | awk '/^Module/ {print $2}' | sort -u

Good luck with blacklisting kernel modules. It can be quite a difference maker if you seek to free some RAM and speed up your system. As said before: be cautious when blacklisting modules as it might go wrong if hasty decisions are made.