rm /*
In my case, I ran rm /*
without -rf
option on a Debian 10 server.
A bit less critical, but not too far .
System is still alive but many things are broken.
- Mostly all commands are unavailable in my command line
- I can not open a new SSH session
- But, astonishing: my services are still running (docker, ssh, ...)
If I restart the server, I won't be able to login.
It would run in recovery mode.
I've made all my tests on an equivalent case on a local VM to check my operations.
The point is that all symbolic links and files on /
path are deleted.
Fortunately, all directories looks untouched. (that what has saved the situation )
Detailed road back to operational
Here are my detailed steps to get back to my machine with a runnable status.
Start server with an Ubuntu ISO to get a terminal from a bootable CD.
Debian should work also.
Boot on CD.
Do not install it, just use try mode.
In my case, I'm using french keyboard ⌨ and I went through many keyboard issues.
So, I decided to install openssh
temporary server to run all following steps via SSH connection . For this, you can
- open terminal (
Ctrl+Alt+F3
/ password: ubuntu)
and type sudo apt-get install -y openssh-server
- Customize password, with
passwd
command
- Then, I was able to connect to
ssh ubuntu@my-ip
Get IP by typing ip a
- and then, with
sudo -s
, I was back again in root mode in an efficient way
Mount harddrive on /debian
path.
mkdir /debian
mount /dev/sda1 /debian
Here is the tricky part: you have to compare your /debian subdirs with a equivalent system.
On basic Debian 10.11 setup, here is default structure : .
In my case, I started with following
- main directories :
bin
, lib
, lib32
, lib64
, libx32
and sbin
vmlinux
and initrd.img
files
For this,
- go to
/debian
dir with cd /debian
- then, use syntax
ln -s ./usr/bin ./bin
.
Relative path are required.
Have a look on script section below, it can help
From this, first reboot
try. (hardware reboot, with CD removal).
But, fortunately, it starts again in normal mode
I've declined this on 3 test VM before running it in production.
I've tested Debian 11, Debian 10.11 & Ubuntu
If your on a virtual system, you may run a snapshot on broken server before running these steps, in order to get back if things go worst.
I'm running tests for a few hours now, but it looks 100% operational and back to previous settings.
You can breath again
Script
For fast deployment of these steps, you can use my script on linux-rm-all-recovering.sh.
wget https://media.gtnapp.com/it/linux-rm-all-recovering.sh
bash linux-rm-all-recovering.sh