killall shenanigans
So I was sitting around wondering what would happen if I typed:
sudo killall -u root
...aaaaaand now the OS will not load. How do I fix this without just doing a reinstall?
I'm not super worried about this or anything, it was a test box and I knew this would crash the system but I didn't realize it would prevent it from booting the OS. It would be nice to know how to fix this in the event that it's done maliciously one day.
EDIT: I'm using fsck after trying to use recovery mode, not sure if it will work. It says that it can't read a block resulting in a short read while getting the next inode from scan. It aborted the fsck when I told it not to ignore the error. I hit yes and forced a rewrite more times than I can count. Will update again if there's any progress or I get a suggestion that works.
EDIT: After ignoring and rewriting copious amounts of errors, the second pass started. Seems to be doing more of the same (checking inodes/sectors) - so many errors.
EDIT: Alright, so fsck in recovery mode (I used this before single user mode was suggested but it seems like they're kind of the same thing) fixed the problem after basically spamming the "y" button for a while. Thanks guys!
EDIT/UPDATE: This also messed up my package manager, it said to try "sudo apt-get updater" which failed. More info as I progress through this problem.
UPDATE: Well, I can't figure out how to get the package manager. Any time I try to reinstall it through the GUI or with apt-get it fails. I get:
Could not initialize the package information An unresolvable problem occurred while initializing the package information. Please report this bug against the 'update-manager' package and include the following error message:
'E:Could not open file /var/lib/dpkg/status - open (2 No such file or directory), E:The package lists or status file could not be parsed or opened.'
I'm lost, considering just giving up and wiping the whole thing. I really would like to know how to fix this without restarting though.
UPDATE: Tried to use dpkg to resolve this, that didn't work either. Firefox, a process that was running when I did this, will not load either but other programs will (tried running GIMP, which ran fine).
Solution 1:
next time, when you killed everything (and are sitting in front of the physical box), hold the Alt and SysRQ (PrintScreen) keys, and type U S B. That means, Unmount, Sync and reBoot. That will at least make sure that unflushed changes in the filesystem get onto your disks.
For now, boot your system in single user mode and try to run fsck manually (maybe with -f
option). Then examine your lost+found and delete anything you are sure you don't need any longer.
Solution 2:
I agree with the user mihi.
Sending kill to all processes owned by root wasn't the cause of your non-bootable state. The fact that you had to hard-reset the system (by pressing the reset button, or maybe holding the power button) caused a corruption on your filesystem.
Since your filesystem was corrupted, then...
- the system failed to boot
- fsck was required to fix the filesystem
- fsck "fixed" the file system structure, but many files/dirs were lost
- the lost files/dirs in /var/lib/dpkg/ caused the package manager (apt-get and dpkg) to stop working.
- maybe other files/dirs were lost, and thus other programs were broken (but you didn't notice yet)