View previous topic :: View next topic |
Author |
Message |
davidbrooke Guru
Joined: 03 Jan 2015 Posts: 341
|
Posted: Sat Jan 17, 2015 4:14 pm Post subject: Upgrading the kernel |
|
|
First off I'm just learning and I wanted to say that I enjoy and get headaches during my journey so far.
During my update yesterday I saw that the kernel sources were updated to 3.18.3 and a notice on how to proceed. I followed the instructions here:
https://wiki.gentoo.org/wiki/Kernel/Upgrade
Here is a condensed version of what steps I took:
eselect kernel list
eselect kernel set 2 (3.18.3)
cp /boot/config-3.18.2-gentoo /usr/src/linux/.config
cd /usr/src/linux && make silentoldconfig && make oldconfig && make modules_prepare
emerge --ask @module-rebuild
make -j9 && make modules_install
make install && genkernel --install --no-ramdisk-modules --disklabel --firmware initramfs
I updated grub to reflect the new kernel and initramfs. Upon bootup with the new kernel, the screen freezes and the last bit of information states something to the effect that /dev/sda4 isn't the correct/proper root. /dev/sda4 is the correct root partition. I reboot ok using the previous kernel and initramfs. At this point I have no idea what is really wrong or what the possible fix is. Any help would be appreciated.
Thanks |
|
Back to top |
|
|
jonathan183 Guru
Joined: 13 Dec 2011 Posts: 318
|
Posted: Sat Jan 17, 2015 4:57 pm Post subject: |
|
|
I normally copy my old kernel .config
Code: | cp -p /usr/src/linux-3._whatever_version_old_kernel_is/.config /usr/src/linux-3_whatever_version_new_kernel_is/ |
I use to get all the information I need about the current running kernel.
Ed: I actually copy the current kernel .config to /usr/src/ and use the following script (as a separate user I call kernel_builder), that way if anything went wrong while building the kernel I could only trash /usr/src/* compared with building kernel as root which could potentially trash the entire system
Code: | ### Script to compile kernel - with the sequence
### ============================================
### check linux symlink information using eselect output
### change ownwership to kernel_builder_user (to allow regular user kernel compile)
### if new option used then
### run make mrproper to clear kernel compile information
### copy .config from previous kernels (stored in /usr/src/)
### then for new or recompile options continue with
### run make oldconfig prompts for new features settings
### run make menuconfig or make nconfig to configure kernel
### run make and make modules to compile kernel and modules
### run make modules_install to install modules
### copy kernel to become new kernel-current
### re-emerge xf86-input-evdev to ensure X mouse and keyboard input work
### Script requires:- kernel_builder user with entries to allow sudo of chown, make modules_install,
### and emerge. It also requires an existing /usr/src/.config and /boot/kernel-current
### owned by the kernel_build_user.
### sudoers entries can be specific for chown,make, and emerge to just combinations
### used in the script ... no need for chown any_thing_you_want ;-)
### definitions needed for script kernel_builder_user
kernel_builder_user=kernel_builder
### use ./kernel-compile.sh new to run mrproper and copy .config
### use ./kernel-compile.sh recompile to skip mrproper and copy .config steps
### use ./kernel-compile.sh with no option for help
if [ "$1" = "" ] || [ "$1" = "help" ] || [ "$1" = "h" ]
then
# hit Enter too early or forgot to add option
echo Script file $0 help information
echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
echo
echo This script allows compile of kernel by user $kernel_builder_user
echo
echo use $0 new ' when compiling a fresh kernel (which uses mrproper and copies an existing .config from /usr/src/)'
echo use $0 ' to display this help'
echo use $0 recompile ' to recompile kernel (skipping mrproper and copying .config from /usr/src/ steps)'
echo
elif [ "$1" = "new" ] || [ "$1" = "recompile" ]
then
# do for compile cases
echo The script allows compile of kernel by user $kernel_builder_user
echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
echo Check config file and kernel-current exist and are owned by $kernel_builder_user
echo
ls /usr/src/.config /boot/kernel-current -l
### check linux symlink
echo
eselect kernel list
echo
echo 'Also check output of eselect is correct for symlink - Press Enter to continue OR Ctrl-c to abandon'
read
echo 'Changing to kernel source folder ...'
cd /usr/src/linux
if [ "$1" = "new" ]
then
### clear source tree and chown to user kernel_builder_user
echo
echo 'Next clear old kernel compile info (erases .config in linux source directory) - Press Enter to continue OR Ctrl-c to abandon'
read
sudo chown $kernel_builder_user /usr/src/linux/* -R
sudo chown $kernel_builder_user /usr/src/linux
echo
echo Running make mrproper ...
make mrproper
# for debug of mrproper use ... make mrproper -d >> debug-info-mrproper
### copy config from /usr/src
echo
echo 'Copying kernel config to source folder from previous kernels ...'
sudo cp -p /usr/src/.config /usr/src/linux/
fi
### configure the kernel
echo 'Configure the kernel - running oldconfig and then menuconfig or nconfig'
echo
echo 'Running make oldconfig ...'
make oldconfig
echo
echo 'Running make menuconfig or make nconfig...'
# use either make menuconfig or make nconfig on the next line
make nconfig
# for debug of menuconfig use ... make menuconfig -d >> debug-info-menuconfig
# could probably use | tee have not played with this much. But could use
# tail -f /usr/src/linux/debug-info-menuconfig to check output in another console.
# for nconfig use ... make nconfig
# for gconfig (need to run in X) use ... make gconfig
# for xconfig (need to run in X) use ... make xconfig
### check ready to compile the kernel and modules
echo 'Next compile the kernel and modules (overwrites previous image in linux source directory) - Press Enter to continue OR Ctrl-c to abandon'
read
# dont think this step is needed ... sudo chown $kernel_builder_user /usr/src/linux/* -R
# compile the kernel and modules
echo 'Running make and make modules ...'
make && make modules
### check if ready then compile the kernel and copy it to kernel-current
echo 'Next install kernel modules and copy latest image to /boot/kernel-current - Press Enter OR Ctrl-c to abandon'
read
echo
echo 'Install kernel modules ...'
sudo make modules_install
echo
echo 'Copy kernel image to kernel-current ...'
cp arch/i386/boot/bzImage /boot/kernel-current
### check kernel image date is correct
echo
echo 'Check kernel image file date is correct - should have todays data and be a reasonable size file'
ls /boot -l
### if using nvidia drivers re-emerge them
#echo Next re-emerge nvidia drivers - Press Enter to continue OR Ctrl-c to abandon
#read
#sudo emerge -av nvidia-drivers
#echo
#echo 'Re-emerging xf86-input-evdev to make sure X mouse and keyboard inputs work correctly ...'
#sudo emerge -av xf86-input-evdev
fi
### end of kernel compile script |
... I'm just updating the kernel now as it happens, I have posted some info below so you get some idea how I have it setup and the prompts I get etc ...
Code: | kernel_builder@Desktop-PC ~ $ ls /usr/src/ -la
total 208
drwxr-xr-x 14 root root 4096 Jan 16 00:12 .
drwxr-xr-x 18 root root 4096 Dec 15 22:35 ..
-rw-r--r-- 1 kernel_builder kernel_builder 74594 Oct 5 22:48 .config
-rw-r--r-- 1 kernel_builder kernel_builder 74705 Feb 1 2014 .config_backup
-rw-r--r-- 1 root root 0 Oct 29 2013 .keep
lrwxrwxrwx 1 root root 19 Jan 16 00:12 linux -> linux-3.17.7-gentoo
drwxr-xr-x 24 root root 4096 Feb 23 2014 linux-3.10.17-ck
drwxr-xr-x 25 kernel_builder root 4096 Oct 12 01:04 linux-3.10.24-ck
drwxr-xr-x 24 kernel_builder root 4096 Feb 11 2014 linux-3.10.25-gentoo
drwxr-xr-x 24 root root 4096 Apr 2 2014 linux-3.10.32-ck
drwxr-xr-x 25 kernel_builder root 4096 Apr 22 2014 linux-3.10.32-gentoo
drwxr-xr-x 25 kernel_builder root 4096 Feb 2 2014 linux-3.10.7-gentoo
drwxr-xr-x 24 root root 4096 May 4 2014 linux-3.12.13-gentoo
drwxr-xr-x 25 kernel_builder root 4096 Nov 23 18:49 linux-3.14.16-gentoo
drwxr-xr-x 24 root root 4096 Dec 2 22:00 linux-3.16.5-gentoo
drwxr-xr-x 24 root root 4096 Dec 2 20:56 linux-3.17.4-ck
drwxr-xr-x 24 root root 4096 Jan 16 00:11 linux-3.17.7-gentoo
drwxr-xr-x 24 root root 4096 Dec 28 22:15 linux-3.18.0-ck
kernel_builder@Desktop-PC ~ $ uname -a
Linux Desktop-PC 3.14.16-gentoo-gnu #10 Sun Nov 23 18:48:42 GMT 2014 i686 AMD Athlon(TM) XP2000+ AuthenticAMD GNU/Linux
kernel_builder@Desktop-PC ~ $ cp -p /usr/src/linux-3.14.16-gentoo/.config /usr/src/
kernel_builder@Desktop-PC ~ $ /opt/user-scripts/kernel-builder/kernel-compile.sh
Script file /opt/user-scripts/kernel-builder/kernel-compile.sh help information
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This script allows compile of kernel by user kernel_builder
use /opt/user-scripts/kernel-builder/kernel-compile.sh new when compiling a fresh kernel (which uses mrproper and copies an existing .config from /usr/src/)
use /opt/user-scripts/kernel-builder/kernel-compile.sh to display this help
use /opt/user-scripts/kernel-builder/kernel-compile.sh recompile to recompile kernel (skipping mrproper and copying .config from /usr/src/ steps)
kernel_builder@Desktop-PC ~ $ /opt/user-scripts/kernel-builder/kernel-compile.sh new |
Ed: I ended up having to skip straight to kernel 3.18.3 due to a problem with the nouveau driver ... got things working again
Last edited by jonathan183 on Thu Jan 22, 2015 10:54 pm; edited 1 time in total |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 23076
|
Posted: Sat Jan 17, 2015 9:50 pm Post subject: |
|
|
Building the kernel as non-root is a good idea, but changing the permissions on /usr/src is not needed. If you set $KBUILD_OUTPUT, you can write all generated files to the specified directory, so no write access to /usr/src is required. This also allows Portage to fully delete the kernel source directory on unmerge, since the directory will not be polluted with build output files. |
|
Back to top |
|
|
jonathan183 Guru
Joined: 13 Dec 2011 Posts: 318
|
Posted: Sun Jan 18, 2015 1:16 pm Post subject: |
|
|
Hu wrote: | Building the kernel as non-root is a good idea, but changing the permissions on /usr/src is not needed. If you set $KBUILD_OUTPUT, you can write all generated files to the specified directory, so no write access to /usr/src is required. This also allows Portage to fully delete the kernel source directory on unmerge, since the directory will not be polluted with build output files. |
Thanks Hu ... that looks to do the same as O=... option, which for me would overwrite the .config and build for each kernel unless I started doing a bit more in the script to take account of version numbers. I have switched to silentoldconfig ... which I should really have done some time ago. |
|
Back to top |
|
|
|