this post was submitted on 08 Aug 2024
29 points (100.0% liked)

Linux

8043 readers
81 users here now

Welcome to c/linux!

Welcome to our thriving Linux community! Whether you're a seasoned Linux enthusiast or just starting your journey, we're excited to have you here. Explore, learn, and collaborate with like-minded individuals who share a passion for open-source software and the endless possibilities it offers. Together, let's dive into the world of Linux and embrace the power of freedom, customization, and innovation. Enjoy your stay and feel free to join the vibrant discussions that await you!

Rules:

  1. Stay on topic: Posts and discussions should be related to Linux, open source software, and related technologies.

  2. Be respectful: Treat fellow community members with respect and courtesy.

  3. Quality over quantity: Share informative and thought-provoking content.

  4. No spam or self-promotion: Avoid excessive self-promotion or spamming.

  5. No NSFW adult content

  6. Follow general lemmy guidelines.

founded 1 year ago
MODERATORS
 

Hi all,

I'm having a bad day and did something colossally stupid, deleting everything from /boot/.

The system is still running. What do you think my best course of action is?

My current idea is to create a timeshift backup, reinstall debian from USB, then restore from backup in timeshift

If this won't work or you have a better idea I would really appreciate your advice.

Thanks in advance

top 27 comments
sorted by: hot top controversial new old
[–] pastermil@sh.itjust.works 29 points 2 months ago (2 children)

Your system would continue to work as long as you don't turn it off. So no matter what you do, keep it on until you restored your /boot

Recovering it should be straightforward, assuming you didn't put custom files directly to /boot.

Just reinstall the linux kernels using apt. Then manually run grub-install with appropriate parameters. Finally, run update-grub or grub-mkconfig to recreate the grub config.

If the system is turned off, you can use live USB and chroot to it to properly install the kernel packages.

[–] Negligent_Embassy@links.hackliberty.org 1 points 2 months ago (2 children)

Can you link me to the commands to reinstall the kernel? Thank you for very much your help[

[–] far_university190 10 points 2 months ago* (last edited 2 months ago)

probably something like apt reinstall linux-image-...

To find ..., run apt list --installed | grep linux-image and pick one

Edit: also if need current kernel, can see booted kernel name using uname -a

[–] pastermil@sh.itjust.works 5 points 2 months ago (1 children)

Can't find an article for it at the moment, but I can tell you real quick how I would've done it.

Use aptitude and look for linux-image-amd64 or something under Installed -> kernel. The exact name might be a bit different.

View the package and look under the Version and check out the one that's marked 'i' (for installed). Select that package and mark it to reinstall (shortcut 'L').

Then finally execute it (shortcut 'g' and then 'g' again).

[–] Negligent_Embassy@links.hackliberty.org 2 points 2 months ago* (last edited 2 months ago) (1 children)

Ok thanks again for all the help.

  1. I used aptitude to reinstall the kernel, L, g, g

  2. Ran Grub-install /dev/nvme1n1

  3. Ran update-grub

  4. I installed grub-emu to test and am greeted with this error

https://dump.li/image/get/16c4f87164d630a5.png

Brand new to this tool so apologies if I'm interpreting it wrong.

Still waiting on data to backup but I'm scared to reboot now. Any thoughts?

The boot drive has LUKS FDE if that could be what's confusing it

[–] pastermil@sh.itjust.works 3 points 2 months ago (1 children)

Not sure if this is a good way to test as it cannot seem to recognize even the most basic command like linux & initrd.

If I were you, I'd just restart, with a liveUSB ready in case it turns out to be unbootable.

Perhaps just a bit to make sure before rebooting:

  • you can see the linux kernel you just installed in the /boot directory
  • /boot/grub/ directory exist
  • you're using the correct grub-install command, depending on whether you're using legacy BIOS or UEFI
[–] Negligent_Embassy@links.hackliberty.org 2 points 2 months ago (1 children)

Just rebooted and it worked flawlessly!!

You are fucking awesome thank you again. Really made my weekend.

[–] pastermil@sh.itjust.works 2 points 2 months ago

Glad to hear that! You're welcome!

[–] masterofn001@lemmy.ca 1 points 2 months ago* (last edited 2 months ago) (1 children)

I've only ever used grub with bios/mbr or a BIOS/gpt (with grub bios partition).

No clue about efi/uefi.

This is the simplest method I can think of.

The arch wiki, however, is, as always, a great source of info:

https://wiki.archlinux.org/title/GRUB

**Linux is amazing in it's ability to keep working even when you accidentally all the things.

I once sudo apt removed mint-x-icons or something which, for whatever reason, also needed to remove cinnamon. As in cinnamon the entire DE.

I realised what I had done as I watched the terminal.
#%&@! panic.
...
reinstalled.
joy.

[–] dis_honestfamiliar@lemmy.world 5 points 2 months ago* (last edited 2 months ago) (2 children)

Linux is amazing in it's ability to keep working even when you accidentally all the things.

Annoyingly so. I once made a backup. Then to confirm it would restore the system, I deleted everything on root path. as in /

It did as told.

OK let's reboot and verify system.

Sudo reboot

Command not found

sudo shutdown

Command not found

But it sat there with a blinking cursor on the terminal

[–] Plopp@lemmy.world 5 points 2 months ago (2 children)

Then to confirm it would restore the system, I deleted everything on root path. as in /

I'm a noob, so forgive me if I'm being very ignorant here, but how on earth could that be a good idea? It sounds like "in order to see if I've installed these airbags correctly I shall now crash head first into this concrete bridge foundation at max speed"?

[–] SteveTech@programming.dev 4 points 2 months ago

I'm assuming it's a fresh install, so nothing of value was lost if the restore failed. But also I've heard attempting to delete things in /sys and /dev can brick your computer. So it's not a great idea.

[–] dis_honestfamiliar@lemmy.world 1 points 2 months ago (1 children)

I'm not so sure your analogy works. Unless you are testing to see how fast you can bring a new test dummy into production. Or you are testing to see how fast you can install new airbags with blemishes and all.

It gave me a reason to finally run the command that by recursively deleting everything.

[–] Plopp@lemmy.world 1 points 2 months ago

It sounded like you were testing the (one and only) backup in a live environment is all.

[–] nexussapphire@lemm.ee 1 points 2 months ago

Not to victim blame but you did put in --no-preserve-root. You had to read those instructions.😄

[–] Max_P@lemmy.max-p.me 8 points 2 months ago (2 children)

Live CD and reinstall kernel should do it. If it's only boot, it'll be as of nothing ever happened to it.

No need to reinstall or start over, that's wildly overkill. This is Linux, if your data is still there, it's recoverable.

[–] nexussapphire@lemm.ee 1 points 2 months ago

I'm not familiar with Debian. On arch you could just run the package manager to reinstall linux (kernel) and run grub-install with all the usual commands.

I use systemd-boot now so I might be rusty on that. I don't know if it's faster but it feels faster and I don't really care about dual booting.

Ok very happy to hear that, thank you.

[–] Mellow12@lemmy.world 7 points 2 months ago* (last edited 2 months ago) (1 children)

Assuming the boot partition is still there and mounted. Just empty. If it were me I would try to reinstall grub2 and kernel packages. I don’t know what errors I would encounter trying it, so that would be the next hurdle.

[–] Negligent_Embassy@links.hackliberty.org 2 points 2 months ago* (last edited 2 months ago)

Ok thank you. I will sleep on it while data copies. I don't like my odds but I may learn something in the process.

[–] HenchmanNumber3@lemm.ee 4 points 2 months ago (1 children)

Backup ASAP as thoroughly possible and accept you'll probably need to start over. Schedule backups more often in the future as a lesson learned.

[–] Negligent_Embassy@links.hackliberty.org 2 points 2 months ago (1 children)

Yes indeed.

I made the mistake of putting my timeshift backup on the same disk as the data and kept having it fill my drive to 0bt and crash plasma. Of course I do something this idiotic the one time it's disabled

[–] catloaf@lemm.ee 1 points 2 months ago (1 children)

If you have a backup, can you mount it and restore just /boot? It shouldn't change so frequently as to be incompatible.

[–] Negligent_Embassy@links.hackliberty.org 1 points 2 months ago* (last edited 2 months ago)

I don't, It's so dumb I almost don't want to admit it over tor lol

I deleted it the other day because I was playing with someone multiplayer in my vfio GPU passthrough VM (elden ring seamless coop) and got frustraed with timeshift filling up my drive every day mid session and causing me to stop the game and ctrl alt f7 root, delete the files, ctrl alt F2, killall plasmashell, kstart plasmashell, resume the VM, and then call them again on steam

I will be more diligent with backups in the future.

[–] blackstampede@sh.itjust.works 4 points 2 months ago (1 children)
[–] Negligent_Embassy@links.hackliberty.org 3 points 2 months ago* (last edited 2 months ago) (1 children)

I was able to keep the system online and follow pastermill's advice to get it working again!

Already rebooted sucessfully.

[–] blackstampede@sh.itjust.works 1 points 2 months ago

It was a lame joke. Glad you figured it out.