LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-29-2016, 06:14 AM   #1
_peter
Member
 
Registered: Sep 2014
Location: paris
Distribution: slackware
Posts: 314

Rep: Reputation: Disabled
push button upgrade of a machine's kernel


alo,
upgrading the kernel by pushing a button is useful to me, maybe it is useful to others: ie moving from 4.4.14 to 4.4.28.

Deliberate limitations requires to stick to the kernel base shipped with 14.2.
No interest in diverging to something different than 4.4.x

The script below can be made better as I am not a software pal

Code:
#!/bin/sh

ZCATC=/usr/bin/zcat
MAKEC=/usr/bin/make
MKINITRDC=/sbin/mkinitrd
TARC=/usr/bin/tar
RSYNCC=/usr/bin/rsync
WGETC=/usr/bin/wget
LNC=/usr/bin/ln
CPC=/usr/bin/cp
AWKC=/usr/bin/awk
ECHOC=/usr/bin/echo
LILOC=/sbin/lilo
GPGC=/usr/bin/gpg
UNXZC=/usr/bin/unxz
F=https

if [ ! -z "$1" ]; then

	RELEASE=$1

	if [ ! -f "linux-$RELEASE.tar" ]; then
	
		if [ $F == rsync ]; then
		FETCH=rsync://rsync.kernel.org/pub/linux/kernel/v4.x/linux-$RELEASE.tar.xz
		FETCHS=rsync://rsync.kernel.org/pub/linux/kernel/v4.x/linux-$RELEASE.tar.sign
			$ECHOC "fetching kernel checksum w/ $RSYNCC -av $FETCHS"
			$RSYNCC -av $FETCHS ./
			$ECHOC "done fetching kernel checksum"
		
			$ECHOC "fetching kernel source w/ $RSYNCC -av $FETCH"
			$RSYNCC -av $FETCH ./
			$ECHOC "done fetching kernel source"
		fi
		
		
		if [ $F == https ]; then
		FETCH=https://www.kernel.org/pub/linux/kernel/v4.x/linux-$RELEASE.tar.xz
		FETCHS=https://www.kernel.org/pub/linux/kernel/v4.x/linux-$RELEASE.tar.sign
			$ECHOC "fetching kernel checksum w/ $WGETC -nv $FETCHS"
			$WGETC -nv $FETCHS
			$ECHOC "done fetching kernel checksum"
		
			$ECHOC "fetching kernel source w/ $WGETC -nv $FETCH"
			$WGETC -nv $FETCH
			$ECHOC "done fetching kernel source"
		fi

			$ECHOC "verifying kernel source integrity w/ $GPGC --verify linux-$RELEASE.tar.sign"
			$UNXZC linux-$RELEASE.tar.xz
			$GPGC --verify linux-$RELEASE.tar.sign
			$ECHOC "done verifying kernel source integrity"

			$ECHOC "extracting kernel source w/ $TARC -xf linux-$RELEASE.tar" 
			$TARC -xf linux-$RELEASE.tar 
			$ECHOC "done fetching kernel source"

	else
		$ECHOC "extracting kernel source w/ $TARC -xf linux-$RELEASE.tar" 
		$TARC -xf linux-$RELEASE.tar 
		$ECHOC "done fetching kernel source"
	fi		
	
	cd linux-$RELEASE

	$ECHOC "0) $ZCATC /proc/config.gz > ./.config"
	$ECHOC "1) $CPC /tmp/.config ./"

	read choice
	case $choice in
		0)
		$ZCATC /proc/config.gz > ./.config;;
		1)
		$CPC /tmp/.config ./;;	
		*)
		$ECHOC "you must choose between option 0 and 1"
		exit
		;;
	esac

	$ECHOC "$MAKEC oldconfig"
	$MAKEC oldconfig
	
	$ECHOC "$MAKEC bzImage modules"
	$MAKEC bzImage modules
	
	$ECHOC "$MAKEC modules_install"
	$MAKEC modules_install

	$ECHOC "$CPC arch/x86/boot/bzImage /boot/vmlinuz-$RELEASE"
	$CPC arch/x86/boot/bzImage /boot/vmlinuz-$RELEASE
	
	$ECHOC "$CPC System.map /boot/System.map-$RELEASE"
	$CPC System.map /boot/System.map-$RELEASE
	
	$ECHOC "$CPC .config /boot/config-$RELEASE"
	$CPC .config /boot/config-$RELEASE
	
	$ECHOC "$MKINITRDC -c -k $RELEASE-smp -m ext4"
	$MKINITRDC -c -k $RELEASE-smp -f ext4 -r /dev/sda1 -m xhci-pci:ohci-pci:ehci-pci:xhci-hcd:uhci-hcd:ehci-hcd:hid:usbhid:i2c-hid:hid_generic:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:jbd2:mbcache:ext4 -u -o /boot/initrd.gz.$RELEASE

	$ECHOC "append the file lilo.conf"
	$ECHOC "image = /boot/vmlinuz-$RELEASE
		initrd=/boot/initrd.gz.$RELEASE
		root = /dev/sda1
		label = s$RELEASE
		read-only" >> /etc/lilo.conf
	
	$ECHOC "$LILOC -v"
	$LILOC -v

else

$ECHOC "--"
$ECHOC "usage is $0 <version_of_the_kernel_archive>"
$ECHOC "example: is $0 4.4.14"
$ECHOC "--"

fi

Last edited by _peter; 10-30-2016 at 03:13 PM.
 
Old 10-29-2016, 04:20 PM   #2
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 2,482
Blog Entries: 2

Rep: Reputation: 988Reputation: 988Reputation: 988Reputation: 988Reputation: 988Reputation: 988Reputation: 988Reputation: 988
Arrow

I would put the initrid modules string in a var at the top?
As it varies among specific hosts...

Otherwise excellent "recipe"
 
Old 10-29-2016, 05:50 PM   #3
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,716
Blog Entries: 3

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
the /usr/share/mkintrid script is the real issue it reads the running kernel so this is not going to help me. Been here before.
I am sure you can figure it out like I did.
re read your script now. and sorry your running the sbin script like I do sorry I miss read your script.

Last edited by Drakeo; 10-29-2016 at 05:52 PM. Reason: oops
 
1 members found this post helpful.
Old 10-29-2016, 06:23 PM   #4
ttk
Senior Member
 
Registered: May 2012
Location: Sebastopol, CA
Distribution: Slackware64
Posts: 1,038
Blog Entries: 27

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Very cool! Thank you for sharing this script :-)

I noticed you have a minor typo here, $ZCAT should be $ZCATC
Code:
$ECHOC "0) $ZCAT /proc/config.gz > ./.config"
 
2 members found this post helpful.
Old 10-29-2016, 07:18 PM   #5
slackb0t
Member
 
Registered: Apr 2005
Location: Canada
Distribution: Slackware64-current on Thinkpad Carbon X1
Posts: 264

Rep: Reputation: 63
This is pretty cool. thx
 
Old 10-30-2016, 06:29 AM   #6
imjustkillingtime
LQ Newbie
 
Registered: May 2016
Distribution: Slackware
Posts: 27

Rep: Reputation: 4
Quote:
Originally Posted by _peter View Post
alo,
self automation of the kernel upgrade is useful to me, maybe it is useful to others: ie moving from 4.4.14 to 4.4.28.

Deliberate limitations requires to stick to the kernel base shipped with 14.2.
No interest in diverging to something different than 4.4.x

The script below can be made better as I am not a software pal
hi _peter, thank you very much for sharing. This will save me from building my own kernel, in the light of the dirty cow. I dont want to sound too demanding but an additional how-to-apply-this-script will help many newbies like me. Would it be something like saving it to a file, place it to /etc/rc.d/rc.local/, make it executable?
 
1 members found this post helpful.
Old 10-30-2016, 06:34 AM   #7
_peter
Member
 
Registered: Sep 2014
Location: paris
Distribution: slackware
Posts: 314

Original Poster
Rep: Reputation: Disabled
thanks SCerovec, yes handling the initrd options in variable(s) is probably best, not even using uuid yet
thanks ttk for the typo catch
imjustkillingtime, inside /usr/src I run the thing like this
Code:
./kernel.sh 4.4.28
purposely executing it on demand rather than within /etc/rc.d, well it's not so automated after all

All this mkinitrd modules -m are still cryptic to me depending on the machine hw
I have been lost on linux mint and ubuntu to reproduce this, grub is not complicated but lilo with slackware feels right.

Closing.

Last edited by _peter; 10-30-2016 at 06:42 AM.
 
3 members found this post helpful.
Old 10-30-2016, 07:42 AM   #8
slackb0t
Member
 
Registered: Apr 2005
Location: Canada
Distribution: Slackware64-current on Thinkpad Carbon X1
Posts: 264

Rep: Reputation: 63
What would be the best way to add the initrd options in variables?
 
Old 10-30-2016, 09:12 AM   #9
kazzan
LQ Newbie
 
Registered: Oct 2010
Distribution: Gentoo Linux, Slackware ARM
Posts: 27

Rep: Reputation: 41
I think you probably should put a disclaimer on your script and not present it as an "automated kernel upgrade" for "newbies".
I'm sure the script works fine on your own system, but it makes too many general assumptions.
To create the initial ramdisk (and the lilo section), why not rely on mkinitrd_command_generator.sh instead?

Props for verifying kernel signatures though, that's rarely ever mentioned and really useful (especially if you have the public key).
 
2 members found this post helpful.
Old 10-30-2016, 10:02 AM   #10
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Rep: Reputation: 55
@_peter Thank you very much for the script. Just my two cent: I would find this much more useful if it provided installable Slackware .txz packages (like Pat distributes them upon kernel update) rather than directly writing in system directories.
 
Old 10-30-2016, 10:25 AM   #11
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 2,482
Blog Entries: 2

Rep: Reputation: 988Reputation: 988Reputation: 988Reputation: 988Reputation: 988Reputation: 988Reputation: 988Reputation: 988
Arrow

Quote:
Originally Posted by slackb0t View Post
What would be the best way to add the initrd options in variables?
My bet is: edit the /etc/mkinitrd.conf and have it handle the automated initrd creation.

Further add the exact kernel version to the file - sed comes to mind?
 
Old 10-30-2016, 03:07 PM   #12
_peter
Member
 
Registered: Sep 2014
Location: paris
Distribution: slackware
Posts: 314

Original Poster
Rep: Reputation: Disabled
yes kazzan and SCerovec, using the unique mkinitrd_command_generator.sh and variables from /etc/mkinitrd.conf instead of hard-wiring them would be better, will try.

tramni1980, my intend is to push a button and get my kernel and lilo upgraded outside of the installpkg tools. Maybe i can wrap the script outputs to a txz file rather than individual files, will try.
I only want to run the stable official slackware release not the current one where Patrick already takes care of things: for instance not all kernels updates are needed or useful along the life of the stable release (14.2)
 
2 members found this post helpful.
Old 10-30-2016, 03:43 PM   #13
OldHolborn
Member
 
Registered: Jul 2012
Posts: 229

Rep: Reputation: 190Reputation: 190
If you intend on making this push-button simple please consider the bandwidth requirements on kernel.org and its mirrors.

If you use the patches you can simply

patch -R < current_patch
patch < new_patch
make mrproper

You'll then only be hitting kernel.org for a few hundred kilobytes each time instead of a hundred plus megabytes.
 
6 members found this post helpful.
Old 10-31-2016, 07:02 AM   #14
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 2,482
Blog Entries: 2

Rep: Reputation: 988Reputation: 988Reputation: 988Reputation: 988Reputation: 988Reputation: 988Reputation: 988Reputation: 988
Or, pull a kernel off an mirror picked by locality
put the
Code:
K_SRC_URI="ftp://<some.nearby.server.net/tarball.tar.gz"
in the front section...
Maybe even put more (well known) mirrors as #comments ?

also, make it a /usr/local/sbin/kernel_updater.sh self contained command?
(rename as found appropriate)

just my 2c
 
1 members found this post helpful.
Old 10-31-2016, 02:19 PM   #15
OldHolborn
Member
 
Registered: Jul 2012
Posts: 229

Rep: Reputation: 190Reputation: 190
Perhaps if you donated that 2c for each time someone used the script?

Bandwidth and server resources have to be paid for by someone at some point, just because you don't know who it is does not make it cost zero for them to provide the service.

As an example from this very forum, Alien Bob had to look at alternative hosting because of the bandwidth requirements of his server.

Be kind to the net, where there is a simple, easy, way to reduce your impact on services provided to you for free, to do anything else is, at best, inconsiderate.
 
  


Reply



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
Pulseaudio/Pavucontrol/Sound die after Upgrade/Kernel Upgrade mzsade Linux - Software 0 09-03-2015 02:44 PM
LXer: Linux Kernel 3.19 Has Reached To End With Last Release Kernel 3.19.8, Install/Upgrade Kernel 3 LXer Syndicated Linux News 0 05-15-2015 12:03 AM
How to upgrade kernel in rhel6/centos6 with internet. manually download and upgrade. Gil@LQ Linux - Kernel 3 03-12-2012 05:07 PM
LXer: Speaking Unix, Part 6: Automate, automate, automate! LXer Syndicated Linux News 0 01-04-2007 09:54 AM
automate software upgrade searches bobwall Linux - Software 11 06-18-2005 02:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:54 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
Open Source Consulting | Domain Registration