Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running Debian... And, I accidentally ran "rm /*" as root (hurray!) - luckily I didn't use -r, so the dirs are still intact. However, when trying to boot, I get...

run-init: /sbin/init: No such file or directory
Kernel panic - not syncing: Attempted to kill init!

...however, after checking the drive from another machine, I can confirm that /sbin/init exists. The only things missing were the files in the root, and I've replaced the sym links (initrd.img and vmzlinuz)...

Perhaps there's some more links I need to replace?

share|improve this question
3  
That's what backups are for. You're asking, so I assume you don't have them. Bummer :( –  Bill Weiss Oct 22 '09 at 18:06
    
I have backup only for my storage drive and config files, but rather than reinstalling I figured it'd be best to try and fix first. –  nbolton Oct 22 '09 at 18:28
1  
echo "alias rm='rm --preserve-root'" >>/root/.bashrc –  amphetamachine Mar 3 '11 at 6:35
1  
@amphetamachine "Be careful what you type as root" is probably better advice -- you'll find if you are on pretty much anything that isn't Linux with the GNU rm that option doesn't exist (and you'll find yourself in serious trouble when you work on a Linux machine that doesn't have that safety net set up...) –  voretaq7 Mar 4 '13 at 16:27
add comment

4 Answers

Did you really run

# rm /

or

# rm /*

Because if you ran the former, you shouldn't have deleted any files, because rm won't delete a directory unless you add -r.

I would suggest running:

# update-initramfs -c -k all
# update-grub

but I don't think this will fix your problem. You probably also want to check your /boot/grub/menu.lst to make sure it is referring to the right kernel and initramfs images.

share|improve this answer
    
Updated answer, it was actually FOOBAR=/path/to/foobar; rm $FOOBA/* (notice the typo). –  nbolton Oct 22 '09 at 18:27
5  
Ah, that would explain it. Always run scripts with "set -u" as this will prevent this problem. –  David Pashley Oct 22 '09 at 18:31
    
Aha, excellent advice. –  nbolton Oct 22 '09 at 18:35
add comment

I once wanted to type in rm folder/* but accidentally typed rm folder /* on a running system, either SCO Xenix or SCO UNIX. Since UNIX does not actually delete files which are open, until they are closed, the system continued functioning normally.

I knew that if I put all the missing files back, that a reboot would succeed normally, and nothing bad would happen. Fortunately I had another server with the same OS installed, and I went over to it, copied all the files from the filesystem root onto a floppy, and put them back on the castrated system. Later, that evening after everyone had logged off, I rebooted and there was never a problem.

So you should be able to do similar to fix this. If you don't have a matching running system, but you have a workstation with Virtualbox or XEN, then you could just do a VM install in order to get the matching system.

Of course, I don't suggest using floppy in this day and age when we have SCP and FTP to move files around.

share|improve this answer
    
Yeah I'll give that a try, thanks. I was hoping Ubuntu would share the same root files, but apparently it doesn't (damn!). –  nbolton Oct 22 '09 at 19:00
add comment
up vote 2 down vote accepted

Turns out I was missing lib64...

ln -s /lib lib64

...the server now boots! :)

share|improve this answer
2  
Now that it's running again you may want to reconsider your backup strategy. –  John Gardeniers Oct 22 '09 at 21:49
    
Yeah absolutely... Hmm what is the best way to back up a system? I tried rsync once but there's a ton of errors because it tries to backup /dev and things like that. –  nbolton Oct 25 '09 at 20:58
    
--exclude for the win. –  Dave Rickman Nov 9 '09 at 14:23
1  
--exclude /media --exclude /dev --exclude /sys --exclude /proc –  nbolton Nov 9 '09 at 15:31
    
@nbolton I suggest you peruse the backup tag for some ideas on backup strategies & software options. –  voretaq7 Mar 4 '13 at 16:28
add comment

At the risk of necroing, I came to this answer while trying to resolve the same. It's worth noting that if you try to recover from this while the system's still running, you may not be able to execute 'ln' because you'll be missing a lib - you'll need to do something like:

/lib/ld-2.11.1.so /bin/ln -s /lib/ /lib64/
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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