The officially official Devuan Forum!

You are not logged in.

#1 2017-04-23 07:27:48

batmore
Member
Registered: 2017-04-23
Posts: 4

HOWTO: upgrade Devuan (stable) to the latest Linux kernel

This is a tutorial to upgrade the existing kernel to the latest version, or a version you select

Getting and compiling a Linux kernel need not be hard or complex.  The following tutorial is long, but not difficult. 

This tutorial assumes -

  • you've installed ( or upgraded to) Devuan 

  • you are compiling the kernel on the machine that will use it. Other configurations are do-able, just not part of this tutorial

  • you are compiling a i386 or amd64 system. This tutorial doesn't cover other architectures

  • you have a userid installed on the base system, if you are going to use userid 'root' then skip the 'setup sudo' part   

  • you know the 'root' password

  • you are ok with Grub. Grub update is completed by the 'make' install step. Tutorial uses only this method

Task list -

  • Setup 'sudo' so that you can do Administrator level work without being 'root'

  • Edit  apt-get  'sources.list'  to comment out the CD-ROM source, or move the cdrom definition to last place in the file 

  • Use apt-get to install the several prerequisites

  • Make a directory for the linux source files

  • Use   git   to clone the Linux branch (all of it to start)... roughly 3 GiB

  • Check latest linux version

  • Checkout the latest linux kernel version, or checkout a specific version

  • Get a copy of the kernel config from your current linux install

  • Use 'menuconfig' to prep the kernel .config file

  • Use 'make' to compile the kernel

  • Use 'make' to compile the various modules and to install everything

  • Reboot   to effect the new kernel

  • Check to see that your machine is using the new kernel version

  • Party !!


Detail task steps -

Switch User (su) to root to add your userid to "Sudo"  so that you can do Admin work without being administrator
  Open a Terminal window/screen, at prompt type

    su       

   and press [return/enter key], then provide root password  (default devuan pswd is:  toor )

Add  'Sudo' to your userid

    visudo        then press [return/enter key]

 
   Add your userid (ie:  bkm )  just below the entry for "root"  with same priviliges, etc..

     root    ALL=(ALL:ALL) ALL
     bkm     ALL=(ALL:ALL) ALL

   Press control-x to exit, select  "Y"  when prompted to save changes, then [enter]  key to exit
 
Back at root prompt, type in

     exit      

Edit  sources.list  to comment out the CD-ROM source, or move the line with the definition to last place in file

     sudo nano /etc/apt/sources.list  

     
     Comment out (place a hash symbol  #  at beginning of line) "deb cdrom:..."
     Ctrl-x, then "Y" to save and exit

Use apt-get to install these several software prerequisites.

  
    sudo apt-get update          
    sudo apt-get install  libncurses5-dev build-essential  libssl-dev git  bison flex 

   
      press "Y" at  "Do you want to continue? [Y/n]"  prompt

Make a directory for the linux source files, then change directory into your new source directory.

    mkdir ~/src     
    cd ~/src       

Use   git   to clone the Linux branch (all of it to start)

    git clone [url]https://github.com/torvalds/linux.git[/url]      

Check latest linux version, cd into the git linux directory

    cd ~/src/linux   
    git tag -l              (that"s a lower case "L"  for list )

   

  check the listing for the highest level version, remember that 4.11 comes after 4.1

Checkout the latest linux kernel version after reviewing the git tag list (above)

    git checkout -f        

   OR if you want/know of a specific version then ie:

    git checkout v4.11-rc6   

Get a copy of the kernel config... from our current linux install

     cp /boot/conf*  ~/src/linux/.config      (note the  .config )

Validate the .config  using  'menuconfig'

    make menuconfig

  once in 'menuconfig'   (text based kernel config menu) then use arrow-keys to select <Exit>
   select <Yes> at the save .config prompt

Kick off the kernel compile, use 6 job threads to do the compile

    make -j 6

Kick off the kernel modules prepare, then install the modules

    make modules_prepare
    sudo make modules_install install

After the kernel is compiled, the large number of modules is installed, and GRUB2 is updated, then reboot to move to the new kernel version.

  
    sudo reboot

Once the reboot occurs you"ll see the GRUB boot menu,
  and if you do nothing (for the 5 seconds you"re allowed) then the latest kernel version will be used to boot the machine

Check to see if the machine is using the new kernel version
  Open a terminal session and at terminal prompt, type in:

  uname -a

  you should see something like...

     "Linux devuan 4.11.0-rc4+ #1 SMP Thu Mar 30.. x86_64 GNU/Linux"

Party!!



-------------------------------------------------------------------------------------------------------
Appendix
  - maintaining your Linux kernel, housekeeping... 
         - assumes you start where you left off (above)

To go a bit further, you might want to customize your kernel a bit, or to recycle and compile another kernel.  Some helpful tips.

Gather information about your machine, helps when you want to customize your kernel.  The more you know about your machine, the finer you can tune it.

List and capture machine specific information. Run these commands, then store/print the output for reference.
  List PCI information

   lspci   >  myMachine.info

  or   lspci -v              for more verbose information

  List USB information

   lsusb   >>  myMachine.info

   or    lsusb -v          for more info

   List CPU info

   lscpu   >>  myMachine.info

List Modules loaded and running on your machine

   lsmod  >>  myMachine.info

Print out the    myMachine.info       file and keep for reference.


Clean or Reset your kernel build environment.

Change to your Linux source directory, list the current kernel version, then save your existing .config file to something meaningful... ie: your kernel version!

   cd ~/src/linux
   uname -a 
   cp .config .config-4.11-rc2

Clean up and reset the kernel build env.

    make clean
    make mrproper

Copy your saved kernel configuration to  .config     

    cd ~/src/linux
    cp .config-4.11-rc2  .config

OR list the current /boot/configs and copy the one you want.  ie: latest

    cd ~/src/linux
    ls -la /boot/config
    cp /boot/config-4.11-rc2 .config  

Get the latest kernel updates from https://github.com/torvalds/linux.git

   git fetch

List out the kernel versions.... remember 4.1, 4.11, 4.2...

   git tag -l 

Checkout the latest kernel version  (reset the master head) or select a specific kernel version (see way above).

   git checkout -f

Use steps below to  'make menuconfig' to validate the kernel .config

Now compile your kernel... and reboot.

 
Tune your kernel   .config   
Should you want to start tuning your kernel (shrinking it to the smallest possible size with the most flexibility) then you must modify the kernel .config   file by using the  'make menuconfig'  utility.  This is where your earlier inventory of machine hardware (above) is important. 

Ensure you've saved off your build environment .config or use the instructions above to make a copy of the exiting /boot/configxxx file.

An easy way to make a succinct kernel configuration, based on the currently loaded kernel modules

    cd ~/src/linux
    make localmodconfig

   check the listed modules against your machine inventory list (the myMachine.info listing). 

   Firmware for USB, networking cards, or wifi things are where most problems occur. 
   If it's ok with you then update your '/etc/apt/sources.list' for  contrib and non-free  repositories.
   firmware-linux-free comes with the standard install, but other firmware installs such as: firmware-linux, firmware-linux-nonfree,     firmware-iwlwifi, firmware-ralink, firmware-realtek, and many others, are in the 'contrib' and 'non-free' repositories.
 

The 'make'  wizard will ask you to decide on the fate of new/updated modules. 

For new or modified modules you'll be prompted to decide [Yes/No/Module/New] (New):  or similar.  Typically the default is in parens ie: '(New)', and that is probably a safe selection...select [enter] key for default option.
ie:

* PCI GPIO expanders
*
AMD 8111 GPIO driver (GPIO_AMD8111) [N/m/y/?] n
BT8XX GPIO abuser (GPIO_BT8XX) [N/m/y/?] (NEW) 

   go thru each module prompt till you're at the shell prompt again, then use   'make menuconfig'   (way above) to validate it.


Explore your kernel .config file
Explore your kernel .config via the 'make menuconfig'  menu.
Remember to refer to your previously printed/saved machine info and make intelligent decisions on what to remove, what to leave in.

cd ~/src/linux
cp .config-4.11-rc2 .config
make menuconfig

<exit> and <save>  to effect the .config changes, then use 'make' to compile your new, tuned kernel.  Reboot to enact it.


If your new, tuned, kernel doesn't boot
  Don't panic... we have the previous kernel remember? 

Reboot again, and at the restart Kernel Selection menu then use the arrow keys to select the 'Advanced...' options and select a previous kernel.

Last edited by batmore (2018-03-20 20:18:44)

Offline

#2 2017-05-01 15:20:33

joril
Member
From: Italy
Registered: 2017-04-15
Posts: 14

Re: HOWTO: upgrade Devuan (stable) to the latest Linux kernel

Thanks for your guide! I have a question though: does Devuan/Debian ship with vanilla kernel? No custom patches?

Offline

#3 2017-05-01 20:07:54

batmore
Member
Registered: 2017-04-23
Posts: 4

Re: HOWTO: upgrade Devuan (stable) to the latest Linux kernel

Devuan RC currently ships with standard kernel.  On my machine...
  Linux devuan 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) x86_64 GNU/Linux

Kernel as provided by Debian. So no "custom" patches that Devuan put in (that I'm aware of...).

Last edited by batmore (2017-05-01 20:09:06)

Offline

#4 2017-05-02 08:53:25

joril
Member
From: Italy
Registered: 2017-04-15
Posts: 14

Re: HOWTO: upgrade Devuan (stable) to the latest Linux kernel

I see... I think the original package is this one. The page mentions "linux_3.16.39-1+deb8u2.debian.tar.xz" which seems to contain patches collected by Debian against the vanilla kernel. I think this answer my question, thanks smile

Offline

#5 2017-05-06 14:53:16

angus71
Member
Registered: 2017-04-27
Posts: 2

Re: HOWTO: upgrade Devuan (stable) to the latest Linux kernel

Hi batmore!
This was my first "selfmade" kernel...  smile
Thanks to you it was relatively easy. I'm now running on kernel version 4.9; until now no
problems occured.
Very nice HOWTO!
Cheers
EDIT:
I forgot to mention, but

make menuconfig

did not work for me, so I tried

make nconfig

that way I could configue my kernel.
I did some searching, for menuconfig I obviously need the packages "ncurses-devel" or "libncurses5-dev";
those I did not find in the repositories. sad
Now I get on systemstart a failure-message on screen like "cpu freq kernel modules could not be loaded".
Otherwise everything seems to work well.
When I got time, I will start a new post!
Greetings

Last edited by angus71 (2017-05-06 17:30:40)

Offline

#6 2018-03-20 20:21:48

batmore
Member
Registered: 2017-04-23
Posts: 4

Re: HOWTO: upgrade Devuan (stable) to the latest Linux kernel

I've updated the list of resources/prerequisits to install for make:  removed  module-init-tools, and added   bison and flex

Offline

Board footer