tpylkko
Posts: 347
Joined: Tue Oct 14, 2014 5:21 pm

Manually place kernel.img on boot partition

Thu Mar 23, 2017 7:56 pm

I was updating a remote pi when it was powered down in the midst. After it was rebooted, it only gives 7 flashes which I think translates to "unable to find/load kernel.img". I took out the sd-card mounted it on a laptop running Debian and /boot has start.elf and boocode.bin but no kernel.img (also no kernel7.img). So, now I am thinking that perhaps I could attempt to boot a kernel placed there manually and then use apt and dpkg to finish try to salvage the broken install. However, I wonder where I could get a precompiled Raspbian kernel.img?

EDIT: it appears I found it.
https://github.com/raspberrypi/firmware

User avatar
DougieLawson
Posts: 33639
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Manually place kernel.img on boot partition

Thu Mar 23, 2017 8:30 pm

It's not that simple. But you can repair things on your RPi if you have (or can make) a second bootable SDCard.

Get your second SDCard with Jessie and boot your RPi from that. Get your "broken" SDCard in a USB reader, insert that in your RPi.

for i in /dev/sda*;do sudo umount $i; done
sudo mount /dev/sda2 /mnt
sudo mount /dev/sda1 /mnt/boot
sudo mount -o bind /dev /mnt/dev
sudo mount -o bind /sys /mnt/sys
sudo mount -t proc proc /mnt/proc
cd /mnt
sudo chroot .
sudo rpi-update
exit
cd /
for i in t/boot t/dev t/sys t/proc t; do umount /mn$i; done
poweroff


Swap cards and reboot. That will get you a 4.9.16 kernel on your broken SDCard.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

tpylkko
Posts: 347
Joined: Tue Oct 14, 2014 5:21 pm

Re: Manually place kernel.img on boot partition

Thu Mar 23, 2017 9:20 pm

Actually, the reason I was hoping this would work is so that I don't have to chroot into it. But if it doesn't work then that the next step, unless you can say for sure that there is a reason why this easier first step could not work...?

BTW. I just want to point out that I wasn't wanting to get a 4.9 kernel, this occured on a card that has not been updated in months (mainly because it is not online when under normal operation). So the apt upgrade was performing a 4.4 update on top of a 4.4. I definetely do not want to run a 4.9 kernel on this one untill that is in stable repo. The git I linked to above has a stable branch.

User avatar
DougieLawson
Posts: 33639
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Manually place kernel.img on boot partition

Thu Mar 23, 2017 9:41 pm

The problem is that you need bootcode, kernel and /lib/modules to all match. Running rpi-update in a chroot is the easiest thing to do. (I've used it a few times when an experiment doesn't work and a system is unbootable.)
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

tpylkko
Posts: 347
Joined: Tue Oct 14, 2014 5:21 pm

Re: Manually place kernel.img on boot partition

Sat Mar 25, 2017 8:48 pm

Well, I can tell you that copying the kernel images did not work. Nor did copying the entire contents of /boot... so I guess chroot now, if onlyI can find my usb-sd reader soon (just spent like 15 min looking for it). If not, it might be more efficient time/moneywise to buy a new one tomorrow... it was around 1€ IIRC...

ozwoz
Posts: 2
Joined: Wed Oct 25, 2017 8:23 am

Re: Manually place kernel.img on boot pahttps://www.raspberrypi.org/products/rtition

Wed Oct 25, 2017 8:29 am

I have the same problem. Just wanted to ask if I run the code suggested by Dougie on my 'broken' sd card will I lose all data from it or just change the bootcode, kernel and /lib/modules and leave the rest of the data ?

User avatar
DougieLawson
Posts: 33639
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Manually place kernel.img on boot partition

Thu Oct 26, 2017 11:33 pm

It's not really a beginner's thing, because if it goes wrong you'll get a jigsaw with no photo on the box.

But as long as you follow the instructions it should work for most folks.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 54 guests