Upgraded Redhat Linux kernel gives kernel panic on boot - linux

I'm trying to use a new kernel (2.6.32) on RHEL 5.10 32bit (2.6.18 kernel). The .32 kernel is downloaded from kernel.org not patched by Redhat. I know this is silly, but upgrading to RHEL 6 is not an option to us.
I did make menuconfig; make; make modules; make modules_install; make install; reboot. Then I got a kernel panic. I built 2.6.18 kernel from source, either patched by redhat or not. Both worked fine.
My question is whether it's possible to use a 2.6.32 kernel with all the filesystem and libraries from a RHEL 5.10 installation (2.6.18). If it's possible then what's wrong with my process?
========
Mounting root filesystem.
mount: could not find filesystem '/dev/root'
Setting up other filesystems.
Setting up new root fs
setuproot: moving /dev failed: No such file or directory
no fstab.sys, mounting internal defaults
setuproot: error mounting /proc: Nosuch file or dirctory
Switching to new root and running init.
unmounting old /dev
unmounting old /proc
unmounting old /sys
switchroot: mount failed: No such file or directory
Kernel panic - not syncing: Attempted to kill init!
Pid: 1, comm: init Not tainted 2.6.32.63 #1
Call Trace:
[<c0xxxxxx>] ? panic
[<c0xxxxxx>] ? do_exit
[<c0xxxxxx>] ? do_group_exit
[<c0xxxxxx>] ? sys_exit_group
[<c0xxxxxx>] ? syscall_call
My /boot/grub/grub.conf has the following.
root (hd0,0)
kernel /boot/vmlinuz-2.6.32-63 ro root=LABEL=/ rhgb
initrd /boot/initrd-2.6.32-63.img

Thanks to all the help and comments I'm able to answer it myself.
This is what I tried but failed. Make a diff between the old and new initrd (gunzip | cpio). There are different modules installed, but they don't matter. I disabled loadable modules (everything build-in), the problem remains. I compiled busybox and put it in the initrd (edit /init), and I got a shell. From there I can manually mknod and mount the file system, but still have the kernel panic when switching root.
Finally I found this. It has a better description and solution to the problem. Enable "deprecated sysfs" and it's all fixed.

Related

Manually compiled kernel fails to boot: stuck in initramfs prompt

I am trying to compile a custom kernel for my old laptop (it's a Dell Inspiron 1525, with a Core 2 Duo processor, 2GB of memory and a HDD -- not SSD). In this computer I have 3 partitions, 2 small ones (10GB each) with the roots of distros that I use, and a large one for files. I'm using MX Linux (if that is relevant) and compiling the kernel in the large partition, which is mounted at /mnt/files. The first thing I did was to clone the v4.19 tag from Linus' repo at kernel.org, then I copied the configuration from the kernel that is currently running (from /boot/config-4.19.0-9-686-pae), run make menuconfig, just changed the string that goes after the version name to -copy, saved and exited. Then I compiled. This kernel, with the configuration just copied from the one that currently runs, works well. It is not custom, however, as it just uses the exact same configurations.
Then I started a new one, again by copying the current .config and using make menuconfig to disable a lot of things that I thought were not relevant for me. The compilation with make ARCH=i386 -j3 and then make INSTALL_MOD_STRIP=1 modules_install went well, apparently, but when I type make INSTALL_MOD_STRIP=1 install I get this:
$ sudo make INSTALL_MOD_STRIP=1 install
sh ./arch/x86/boot/install.sh 4.19.0-custom arch/x86/boot/bzImage \
System.map "/boot"
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.19.0-custom /boot/vmlinuz-4.19.0-custom
run-parts: executing /etc/kernel/postinst.d/dkms 4.19.0-custom /boot/vmlinuz-4.19.0-custom
Warning: Unable to find an initial ram disk that I know how to handle.
Will not try to make an initrd.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.19.0-custom /boot/vmlinuz-4.19.0-custom
update-initramfs: Generating /boot/initrd.img-4.19.0-custom
cryptsetup: WARNING: The initramfs image may not contain cryptsetup binaries
nor crypto modules. If that's on purpose, you may want to uninstall the
'cryptsetup-initramfs' package in order to disable the cryptsetup initramfs
integration and avoid this warning.
I: The initramfs will attempt to resume from /dev/sda1
I: (UUID=a1472f28-bb65-4a3a-a964-59b72d46b645)
I: Set the RESUME variable to override this.
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.19.0-custom /boot/vmlinuz-4.19.0-custom
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.19.0-custom /boot/vmlinuz-4.19.0-custom
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.19.0-custom /boot/vmlinuz-4.19.0-custom
Generating grub configuration file ...
Found theme: /boot/grub/themes/linen/theme.txt
Found linux image: /boot/vmlinuz-4.19.0-custom
Found initrd image: /boot/initrd.img-4.19.0-custom
Found linux image: /boot/vmlinuz-4.19.0-9-686-pae
Found initrd image: /boot/initrd.img-4.19.0-9-686-pae
Found linux image: /boot/vmlinuz-4.19.0-copy
Found initrd image: /boot/initrd.img-4.19.0-copy
Found memtest86+ image: /boot/memtest86+.bin
Found antiX 19.2 (19.2) on /dev/sda2
done
The first kernel (-copy) also gave these warnings, however (and it is working). This new kernel (-custom) starts booting but then gets stuck in a busybox (initramfs) prompt. I can issue some commands there, and I can see that there is a file system with some basic programs (I suppose from busybox). But it doesn't finish the boot process.
When I execute the exit command in this (initramfs) prompt I get something along these lines:
Gave up waiting for root file system device. Common problems:
- Boot args (cat /proc/cmdline)
- Check rootdelay= (did the system wait long enough?)
- Missing modules (cat /proc/modules; ls /dev)
ALERT! UUID=efdafcea-bdab-4c13-b2a7-caa77e4330ca does not exist. Dropping to a shell!
I tried to type the suggestions from the message above, but I don't know what to make out of them. If I type cat proc/cmdline in this same initramfs environment, I get something like:
BOOT_IMAGE=/boot/vmlinuz-4.19.0-custom root=UUID=efdafcea-bdab-4c13-b2a7-caa77e4330ca ro video=SVIDEO-1:d quiet splash
If I type cat proc/modules I get this output and if I type ls dev I get this. (Sorry for the bad image quality).
I am quite sure something that I removed during the configuration in menuconfig is what caused the problem, and if I understand anything from these messages I would guess that the kernel is not being able to mount the root filesystem, perhaps it is not finding the partition to mount?
My question here is, given this situation, is there any obvious candidates to be the problem among the settings in .config? This is my .config file.

single partition & no initramfs linux boot gets kernel panic

compiled a kernel using gentoo specifications for Thinkpad T430
mounted empty ext4 hard drive and created boot/ directory on it, moved bzImage and System.map inside
Installed extlinux to it with "extlinux --install [mounted directory]/boot"
placed syslinux.cfg inside with the following config:
DEFAULT linux
SAY Now booting the kernel from EXTLINUX...
LABEL linux
KERNEL /boot/bzImage
APPEND root=/dev/sdb rw init=/bin/bash
Created bin/ folder in mounted hard drive, placed bash binary inside
At this point i'm able to boot the kernel to the point where it has to run init, however it panics:
---[ Kernel Panic - not syncing: Requested init /bin/bash failed (error -2). ]---
4chan solved my question in 10 minutes, i didn't have the libc.so libraries

Failed to execute /init

I am trying to build a basic root filesystem using Buildroot, for an embedded system (the Banana PI D1).
I am using a kernel from an SDK supplied by the SoC vendor. From this repo I am using only the kernel, found in src/kernel.
There's nothing remarkable about the Buildroot configuration. It builds with no errors and the resulting root filesystem looks like it contains everything I would expect.
I have configured it to build the filesystem as an initramfs embedded within the zImage.
The kernel appears to start up correctly, but cannot load init and then panics:
Booting Linux on physical CPU 0
Linux version 3.4.35 (harmic#penski.harmic.moo.org) (gcc version 4.8.4 (Buildroot 2015.02) ) #7 Sat Mar 21 22:59:18 AEDT 2015
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
...
Kernel command line: root=/dev/mtdblock1 ro init=/sbin/init mem=64M console=ttySAK0,115200
...
Freeing init memory: 4632K
Failed to execute /init
Failed to execute /sbin/init. Attempting defaults...
mmc0: host does not support reading read-only switch. assuming write-enable.
mmc0: new SDHC card at address 0007
mmcblk0: mmc0:0007 SD08G 7.42 GiB
mmcblk0: p1
Kernel panic - not syncing: No init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
I have tried a number of troubleshooting steps:
I've built a root filesystem using this miniroot project (took some doing, as it is quite out of date). It booted OK, using the same kernel as I am trying to use with the buildroot root fs.
I've tried using both uClibc and eglibc
I've tried using Buildroot's own cross-tools as well as the cross tools supplied by the SoC vendor
I've confirmed that the built rootfs does include an /init (it does!)
There is a gist here containing the buildroot configuration, a copy of the kernel boot log, and a listing of the contents of the generated filesystem.
What steps can I take to troubleshoot this further?
Update:
The generated rootfs.cpio.gz weighs in at 2139200 bytes. I have read that there is a maximum size of initramfs you can use, but I have not been able to find where the hard limit is documented.
I have attached a listing of the generated root filesystem to the gist linked above.
I have unpacked the rootfs on the host and inspected it. /init contains this:
#!/bin/sh
# devtmpfs does not get automounted for initramfs
/bin/mount -t devtmpfs devtmpfs /dev
exec 0</dev/console
exec 1>/dev/console
exec 2>/dev/console
exec /sbin/init $*
/sbin/init is a symlink to /bin/busybox.
/bin/busybox is dynamically linked:
$ file busybox
busybox: setuid ELF 32-bit MSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, stripped
$ ../../../host/usr/bin/armeb-buildroot-linux-gnueabi-readelf -a busybox | grep "Shared library:"
0x00000001 (NEEDED) Shared library: [libc.so.6]
libc.so.6 is present in /lib. /lib32 is a symlink to /lib for good measure.
The device has 64M RAM.
Both the vendor's cross tools and the buildroot cross tools are set up for eabi
As suggested by #sawdust, the problem was that the CPU was not supposed to be run in big endian mode.
After changing the target to 'ARM (Little Endian)', cleaning and re-building, it now boots correctly.
In retrospect this should have been obvious - inspecting the vendor's kernel image:
$ file zImage
zImage: Linux kernel ARM boot executable zImage (little-endian)

Linux Kernel Code Coverage - GCOV

I'm trying to use some test scenarios from Linux test Project and get the Kernel source code coverage.
I'm using GCOV/LCOV to do so.
here are the things I have so far:
GCOV flags in the build config
GCOV-based kernel profiling
CONFIG_GCOV_KERNEL=y
CONFIG_GCOV_PROFILE_ALL=y
On Linux kernel version: 2.6.32.60+drm33.26
After building the kernel I have all the .gcov files in the source folder
GCOV/LCOV works when I use a source file as the input
Things that I should have but I don't
/Proc/GCOV folder
GCOV Kernel Module (gcov.o?)
Now what I want is to run the test scenarios and with LCOV get which portion of Linux Kernel Code has been used so far. but when I call LCOV -c this is what I get even though all the build flags are ok.
Loading required gcov kernel module.
lcov: ERROR: cannot load required gcov kernel module!
There is a kernel patch for < 2.6.30 and afterwards it is built in.
please read this document
http://www.mjmwired.net/kernel/Documentation/gcov.txt
Here is answer to your questions:
There is no proc fs for kernel coverage. After booting from the new kenrel, you had to mount the debug-fs via command: "mount -t debugfs none /sys/kernel/debug" and read coverage log of kernel from this file
Kernel coverage can not be built as module. As you see, the CONFIG option is 'Y', not 'M'
below is my try on the ubuntu 12.04 default kernel.
thought the gcov is not enabled, but the debug fs is mounted and some kvm debug inforation can be found in it.
ubuntu:/sys/kernel# mount -t debugfs none /sys/kernel/debug
mount: none already mounted or /sys/kernel/debug busy
mount: according to mtab, none is already mounted on /sys/kernel/debug
ubuntu:/sys/kernel# umount /sys/kernel/debug
ubuntu:/sys/kernel# mount -t debugfs none /sys/kernel/debug
ubuntu:/sys/kernel# ls debug
acpi bdi bluetooth extfrag gpio hid kprobes kvm mce regmap regulator sched_features suspend_stats tracing usb wakeup_sources x86
ubuntu:/sys/kernel# cat debug/kvm/
efer_reload host_state_reload io_exits mmio_exits mmu_pte_write nmi_window signal_exits
exits hypercalls irq_exits mmu_cache_miss mmu_recycled pf_fixed tlb_flush
fpu_reload insn_emulation irq_injections mmu_flooded mmu_shadow_zapped pf_guest
halt_exits insn_emulation_fail irq_window mmu_pde_zapped mmu_unsync remote_tlb_flush
halt_wakeup invlpg largepages mmu_pte_updated nmi_injections request_irq
ubuntu:/sys/kernel# cat debug/kvm/io_exits
467789515
ubuntu:/sys/kernel#

Recompile Linux kernel (with Xen) config flags not being used

I am trying to compile the linux kernel (3.0.0-13) with the Xen dom0 config flags which are not exposed via menuconfig. (Yes, I know that ubuntu provides a 'virtual' flavoured kernel that supports Xen paravirtualization, but that kernel does not seem to boot on my hardware. So, I am trying to compile the 'generic' flavoured ubuntu kernel with the extra Xen config flags since I know that the 'generic' flavour runs on my hardware). Every time that I try to compile my config flags are ignored based on the .config file that is generated and packaged with my kernel binary.
I have tried the following the following:
Downloaded the kernel source using apt-get source linux-image
I have then followed all of the steps from this guide: How to compile a new Ubuntu 11.10 (Oneiric) kernel and performed the following extra steps:
put my own config flags in the config.flavour.xxx file then compiled the linux-image package
Paused the 'debian/rules editconfigs' command immediately after the it runs 'menuconfig' and replaced the build/.config file with my custom .config file then compiled the linux-image package
I have also used the following howto How To Compile A Kernel - The Ubuntu Way and run the following commands on kernel source code that I already had:
edit the .config file to have my config flags
run 'make oldconfig'
run 'make-kpkg clean && fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers'
After every time I have compiled the kernel I have installed the newly compiled linux-image package and have discovered that my config flags are not in the /boot/config-xxx file as I expect.
What am I doing wrong to cause my config flags to be ignored?
What can I do to make sure that my kernel config flags are used when compiling?
Is there some other option than recompiling the kernel to get a Xen dom0 kernel that work for my hardware?
For question 3: Is there another way to get a xen dom0 kernel for my hardware?
Yes.
Although all of the xen documentation says that all stock kernel support xen dom0, what they mean is that the source for all stock kernels now support xen dom0 but that support is turned off in their precompiled binaries.
On debian there is the following package which is a prebuilt linux kernel with the xen dom0 support turned on. Package: linux-image-xen-686
For anyone else who is really looking to compile their own xen dom0 kernel the following site has a good guide: Compiling a Xen Dom0 Kernel for Ubuntu Jaunty
What am I doing wrong to cause my config flags to be ignored?
The root of the issue lies in the first portion of your problem; the Xen dom0 config flags are not exposed via menuconfig
Simply setting them in the .config doesn't mean they'll be activated. You have to consider the dependencies for the config options.
From the linux 3.0 tag at github: https://github.com/torvalds/linux/blob/02f8c6aee8df3cdc935e9bdd4f2d020306035dbe/arch/x86/xen/Kconfig
config XEN_DOM0
def_bool y
depends on XEN && PCI_XEN && SWIOTLB_XEN
depends on X86_LOCAL_APIC && X86_IO_APIC && ACPI && PCI
Are all these depends flags met?
What can I do to make sure that my kernel config flags are used when compiling?
In the beginning stages of the kernel compile process, the .config file is re-written if there are any discrepancies. A good test to make sure your edits will persist is checking if they still exist in your .config file after doing a make menuconfig and saving changes. If after that your flags are still there, you can be sure that your flags are being used.
Is there some other option than recompiling the kernel to get a Xen dom0 kernel that work for my hardware?
Not unless another distribution ships with XEN_DOM0 enabled.

Resources