I’m not 100% sure what I did, but when I tried to purge some generic-kernel-headers or raspberry-pi-kernel headers my USB devices stopped working completely.
Now I cannot control the pi anymore via a mouse/keyboard. How can I fix this ?
I tried enabling SSH by placing an empty “ssh” file on the root of a sd card using another PC but it didn’t seem to work.
I need to somehow re-install the kernel-headers to get my USB devices working again - but HOW ?
@SFromley Hi, yes I can put the SD card into a another Linux machine.
I’m not an expert on this so could you please explain the steps on how exactly I can enable SSH using the other Linux machine including the chroot part ?
I am not 100% sure if the headers are the issue. I was also fiddling around with the /lib/modules/ folder and I may have deleted modules.order and modules.built files which I think may be the real issue here since it seems that no modules are being loaded on boot. Do you know how I can fix this ?
Also, is it possible to re-install the headers or the modules directly onto the SD card using the other Linux machine without the need for SSH ?
I really need to get this sorted since I am unable to do anything on the Pi until I can get the modules loaded again. I’m pretty sure this is an issue with the modules not being loaded on boot.
I’d be more inclined to fix the problem on the pi itself because of different architectures. You just need to be able to ssh onto it then the world is your oyster.
depmod and initram will be your friends in fixing the kernel module loading, I think; and you’d want to run those on the machine itself rather than in a chrooted environment from another.
It’s been a while since I’ve had to fix stuff (usually grub) this way, so I’m running on shaky memory here, but I think you
sudo chroot /path/to/mounted/sd /bin/bash
then enable sshd on startup by
sudo systemctl enable ssh
Then type ‘exit’ to leave the chroot, unmount and put the sd into the pi, boot it up and ssh onto it. Assuming it still has a working network interface.
@SFromley Thanks, I’ll give it a go and see if I can get ssh to work. In terms of the /path/to/mounted/sd would I just mount the whole device or a specific partition. I’ll have to check again what’s the command for finding the path for the SD. I assume the SD mounts automatically when I plug it in using a USB SD card adaptor.
Then I got the error: chroot: failed to run command ‘/bin/bash’: Exec format error
I very stupidly followed another guide which said to do this: sudo cp -r /bin /lib /mnt/RPI
Now my Pi will not even boot into the OS since I have messed up my /bin and /lib folders. Is there anyway that I can restore them ? I don’t know why on Earth I did that.