Accidentally deleted usr or something in usr. Can't boot or chroot

Two days ago I stupidly deleted something in my usr directory on my laptop by accident. I panicked and then after a bit of googling I used testdisk to try and bring my files back (I’m not sure if this worked to be honest). Then I rebooted and found out I can’t boot into my file system. When I turn on my computer I just get the Lenovo boot menu but I can’t actually boot into anything unless I use my EOS live USB.

I tried to follow the “repair non-booting GRUB” tutorial on Discovery which led me to the arch chroot tutorial, but I can’t mount the ESP (“can’t read superblock on /dev/sda1”).

I Google this and run dosfsck and fsck. I get “Both FATs appear to be corrupt”. I haven’t done anything beyond this because I don’t exactly know what I’m doing and I’m scared of messing up my system. Anyone can help? I can provide screenshots etc. I don’t want to do a complete reinstall because I think the ext4 system is fine and don’t want to lose my files, but I don’t know what to do with my files if I can’t boot normally.

Since we don’t know what you did either, best advise is to reinstall and stop doing things as root :wink:
Obviously it’s not the best thing but see above (about not knowing what you did).

Edit: I did think of something…you could boot off alternate media, arch-chroot, and reinstall the base packages manually (someone else will have to provide the package names), at least the advantage of this approach wouldn’t end up losing your home directory files unless you fried them too.

This doesn’t sound good. Using testdisk? Is your install using grub or systemd? Can you boot on the live ISO and post

sudo fdisk -l

Edit: Maybe we can help you chroot but not sure you’ll be able to fix whatever you did?

Edit: Can i also see

sudo lsblk -f

I actually think this is my best course of action right now and was thinking about it last night. The issue is that I don’t know exactly how this works (how am I going to reinstall when the partition I’m going to install over is currently filled with the files I want to keep??)

I actually don’t know what the difference is. How can I tell which one I was using? Will edit this post soon with screenshots from my laptop.
Edit:

Sounds similar to this thread with some possible alternatives. Assuming you can chroot in and have a network connection, perhaps wired.

https://bbs.archlinux.org/viewtopic.php?id=34832

Could i also see this one. Post the url.

inxi -Faz | eos-sendlog

To arch-chroot you just need to be booted on the live ISO. You have to mount the / partition first and then mount the /efi partition. If any one of these commands fails please stop there and let me know.

sudo mount /dev/sda2 /mnt
sudo mount /dev/sda1 /mnt/boot/efi 
sudo arch-chroot /mnt

Edit: All commands work then check

ls /home

Edit: You didn’t answer my question is it installed with grub or systemd boot?

1 Like

I think it may be grub. But I’m not entirely sure how to check if it’s grub or systemd. I just did default EndeavourOS installation with i3wm.

Log: https://0x0.st/Hr9p.txt

I got this:

image

I might have the command wrong? Try this instead.

sudo mount /dev/sda1 /mnt /boot/efi

Edit: If that doesn’t work

sudo mount /dev/sda1 /mnt/efi

Edit2: Sorry i don’t arch-chroot often
If the command works without error then you still need to run the last command for arch-chroot and then check if it worked.

image

I got this for both

I’m pretty sure it should be these. Maybe unmount all the drives first

sudo umount -a

sudo mount /dev/sda2 /mnt

sudo mount /dev/sda1 /mnt/boot/efi

sudo arch-chroot /mnt

ls /home

image
I get the same thing :frowning:

Okay i booted up on mine and yes it is correct like this. So i suggest try one more time by rebooting on the live ISO again first.

Edit: Like this.

[liveuser@eos-2023.02.12 ~]$ sudo mount /dev/sda2 /mnt
[liveuser@eos-2023.02.12 ~]$ sudo mount /dev/sda1 /mnt/boot/efi
[liveuser@eos-2023.02.12 ~]$ sudo arch-chroot /mnt
[root@EndeavourOS /]# ls /home
ricklinux
[root@EndeavourOS /]# 

Edit: If this isn’t working for you then I don’t know? :thinking:

I’m still getting the same message. I know that /dev/sda1 is pretty corrupted according to the partition manager. arch-chroot works fine. If you don’t have any more suggestions then I may try to reinstall. Thanks for working with me :slight_smile:

arch-chroot doesn’t work unless the command ls /home shows you are in your home directory and you have actually chrooted showing [root@EndeavourOS /]#

Edit: If the /efi partition is pooched on /dev/sda1 then i think it’s not going to work to arch-chroot properly.

You can try to correct it with fsck. Read man fsck for instructions (for a fat32 FS).

About mounting, if it is only intended for updating packages, you can skip chroot. Only need root (/) mounted and use --root option with pacman command.

1 Like

maybe you can check and repair the sda1 partition by GParted ?

Maybe someone else with more knowledge can advise further.

By this you mean mount only the / partition and then any package reinstalls use this?

sudo pacman -S (pkg) --root

Yes.
From pacman -Sh :

-r, --root set an alternate installation root

Example:

sudo pacman -Syu -r /mnt