1

I read here, once, that installing a Debian 9 on a pendrive (well, in my case it's a SDCard adapter) directly would work, and it did. The problem came up, though, after i unplugged the adapter from the computer; when i wanted to boot into linux, all i had to do was to choose the boot device labelled 'UEFI: debian' on the bios setup, but as soon as i removed the adapter, that option disappeared.

I don't want to lose the debian installation, I want it working again. I need to get it booting again.

  • 1
    This might be implied but... are you saying that when you plug the USB back in, the UEFI: debian option doesn't reappear? – Philip Couling Mar 12 at 17:05
  • Yes, that's exactly what's happening; after removing the usb stick, when i try reinserting it, the option is gone. – Debianoid Mar 13 at 14:33
  • Okay this is basically a BIOS problem but see the end of my answer for a workaround. (copy the EFI entry onto your internal hard drive) – Philip Couling Mar 13 at 14:40
0

This smells like a BIOS problem. You've missed some information out of your question so I'm going to assume somethings:

  • UEFI: debian appears in a BIOS menu after install (not a grub menu)
  • When you unplug and re-plug the USB drive, the BIOS no-longer shows UEFI: debian even after reboot
  • Your main hard disk uses EFI to boot your other operating system (Windows?)

It would be very difficult to give a direct solution without knowing a lot more about your BIOS. However the problem might be something to do with you having two EFI partitions; one on your internal HDD and one on your USB disk.

It may be possible to manually remind your BIOS about the USB EFI entries when you plug back in, but I couldn't tell you how.

A possible work around might be to copy your EFI entry from your USB drive onto your internal hard drive. This will be easier from Debian (if you can get back into it) but it can be done on windows.

EFI entries are basically just a few files in a directory on your EFI partition. So all you would need to do is to mount your internal HDD's EFI partition and copy the one from your USB drive (usually mounted to /boot/efi/EFI/debian)

0

My guess is that the root file system (with the Debian operating system) is damaged.

This can happen

  • if the drive is unplugged before the operating system is fully shutdown or

  • if connected when another operating system is running, you unplugged it without unmounting all partitions on the drive.


You can connect the drive to a computer running linux and try to repair the file system(s).

  • Make sure that all partitions on the SD card are unmounted

  • Repair the root file system on the SD card (and other file systems, that belong to Debian, for example home, if there is a separate home partition.

  • Run the following command line for each of these file systems (I assume ext4 here, modify if you use another file system),

    sudo e2fsck -f /dev/sdxn
    

    where x is the device letter for the SD card and n is the partition number, so for example /dev/sdb2


It is also possible, that Windows damaged the boot system for the SD card via USB. This can happen, if the card was connected, when you booted Windows or when Windows was running some update/upgrade process.

If this is the case, you can find methods to 'repair grub' or 'repair boot' via the internet. I know methods for Ubuntu, and I think but am not sure that the same methods work for Debian.


Please notice that the first part about damaged file systems and the second part about Windows damaging the boot system are describing independent problems. I don't know enough about your particular problem to be able to tell which of the problems that is affecting your Debian system on the SD card.

  • 1
    EFI partitions are unlikely to corrupt through failing to unmount. If the OP successfully booted from the USB drive once then the EFI partition was successfully written once. Very few things touch data on EFI so its very unlikely to be in an unstable state even if yanked out. Note that EFI can't be fixed with e2fsck as it must be a FAT based file system. – Philip Couling Mar 12 at 17:22
  • @PhilipCouling, I can state more clearly that the part about corruption of file systems is independent of the part about Windows tampering with the boot system. – sudodus Mar 12 at 18:12
0

Well, i never managed to find exactly what went wrong with my setup, but it seems that using rEFInd (first read about it on https://wiki.debian.org/GrubEFIReinstall ) will fix the issue. BIOS can't find the pendrive kernel, but rEFInd has no trouble booting it.

I don't think this is a fix, but it works fine as a workaround.

0

Your Debian-installer basically treated your SDCard adapter as a fixed disk, and installed the UEFI bootloader on the ESP partition. And after that, it did one more thing: it used the efibootmgr command to register the bootloader into UEFI NVRAM boot variables.

Before unplugging the adapter, everything worked just fine: the SDCard disk and the bootloader on it was registered in UEFI boot order. But apparently your system's UEFI firmware has one feature: on boot, if it detects NVRAM boot variable entries referring to a disk that is not present, it assumes those entries are no longer needed and deletes them. Without the NVRAM boot variable, the UEFI firmware no longer knows to look for /EFI/debian/grubx64.efi on the ESP partition of your SDCard.

Others have suggested copying the UEFI bootloader to your hard disk. That would work, and would allow you to boot from your SDCard... but only on that specific system.

There is another solution: plug your SDCard to any system that can access FAT32 partitions on a GPT-partitioned disk. You should be able to use that system to access the ESP partition on the SDCard, find the EFI directory in the root of that partition, the debian subdirectory inside it, and the grubx64.efi file inside that.

Then create a new subdirectory within the EFI directory, named boot. Then copy the grubx64.efi from the debian subdirectory into the boot subdirectory. Within the boot subdirectory, change the name of grubx64.efi to bootx64.efi.

When a 64-bit UEFI PC is looking for a UEFI-style bootloader on a removable disk, this path - /EFI/boot/bootx64.efi on a FAT32 partition - is what it's looking for. When that file exists, the UEFI BIOS should detect the SDCard as bootable in the UEFI style. Since the OS name is part of the UEFI NVRAM registration, it won't appear as UEFI:debian any more, but it might appear as UEFI:<model of the SDcard> or something similar instead. And now your SDcard should be again bootable, not only in one specific computer, but in any computer that allows UEFI-style boot from removable media.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.