USA Linux Users Group Forum Index
Log in Register FAQ Memberlist Search USA Linux Users Group Forum Index Album

OOOPS.... Now what?
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Servers and Server Administration
View previous topic :: View next topic  
Author Message
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Mon Jul 27, 2024 2:12 am    Post subject: OOOPS.... Now what? Reply with quote

so we are all familiar with the following command, and it fills us with dread to our very bones...

Code:
sudo rm -rf /


Well stupid me.... I accidentally executed the equivalent of this on one of my servers.

Fell free to stop laughing at any time....

Anyway... does anyone know of a possible... Undo command or something? or am i screwed?

It's not like there was a *LOT* of data on the server and most of it was backed up, but i would rather avoid spending hours traversing the various backups and piecing the server back together....



_________________
ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)

PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
Back to top
View user's profile Send private message Visit poster's website
lynch
Moderator


Joined: 15 Nov 2024
Posts: 2659
Location: The Diamond State

PostPosted: Mon Jul 27, 2024 8:54 am    Post subject: Reply with quote

Recover everything? I doubt it.
At least you can congratulate yourself for doing backups.
What was the equivalent command?



_________________
Mandriva 2024 Spring -2.6.31.12-server-2mnb
PCLinuxOS 2024 -2.6.26.8.tex3
Back to top
View user's profile Send private message
nukes
Linux Guru


Joined: 29 Aug 2024
Posts: 4558

PostPosted: Mon Jul 27, 2024 11:30 am    Post subject: Reply with quote

It depends on the filesystem, assuming you immediately unmounted it, and haven't replayed the journal (e.g. mount read-only even) it may be possible.

One tool to look at is ext3grep, which is quite complicated to use. You need to discover the inode of the relevant files/directories, then the block that contained them - which requires you to pick through the journal backwards. Not easy, but sometimes possible.
http://code.google.com/p/ext3grep

If it's reiserfs, you might try --rebuild-tree, sometimes that can help, but more often than not it produces unintended results.

This all depends on the actual command you did, if it was something like cat /dev/zero > /dev/sda or whatever, you're not going to get the data back.

Backups are all well and good, but you need a procedure for restoring them (too many places get caught up with the idea of backups, but not the act of restoration, which is the main point). at least you've got them Wink



_________________
Gentoo x86-64 2.6.29.1
FreeBSD 7-CURRENT
Arch x86 2.6.30
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Mon Jul 27, 2024 5:34 pm    Post subject: Reply with quote

the equivalent command was actually run by a script.

Code:
 sudo rm -rf $PACKAGE/$VERSION


buuuuuut....... turns out those variables were uninitialized and therefore empty......

The filesystem is Reiserfs4. I will not be using it again for a while, not until kernel support evolves some more. it's been more trouble than I want to deal with... I'll probably go back to reiserfs 3.5 or 3.6, both of which have given me good to excelent results in the past.



_________________
ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)

PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
Back to top
View user's profile Send private message Visit poster's website
mushroom
Ultimate Member


Joined: 29 Jun 2024
Posts: 2129
Location: Queen Charlotte B. C. Canada

PostPosted: Tue Jul 28, 2024 4:54 am    Post subject: Reply with quote

Lord.DragonFly.of.Dawn wrote:
The filesystem is Reiserfs4. I will not be using it again for a while, not until kernel support evolves some more. it's been more trouble than I want to deal with... I'll probably go back to reiserfs 3.5 or 3.6, both of which have given me good to excelent results in the past.

The scandal around Reiser got me looking at other file system about a year or so ago. Even with all the power bumps and outages Reiserfs performed well for me.
Now I use XFS and find it performs even better than Reiserfs Arrow



_________________
SuSE 8.0, 8.2, 9.0, 9.1, 9.2, 9.3, 10.0, 10.1, 10.2, 10.3, 11.0, 11.1
Live CDs Mepis 8.0, Puppy 4.3.1, netbook- Zenwalk 6.2
Back to top
View user's profile Send private message Visit poster's website
nukes
Linux Guru


Joined: 29 Aug 2024
Posts: 4558

PostPosted: Tue Jul 28, 2024 3:36 pm    Post subject: Reply with quote

Lord.DragonFly.of.Dawn wrote:
the equivalent command was actually run by a script.

Code:
 sudo rm -rf $PACKAGE/$VERSION


buuuuuut....... turns out those variables were uninitialized and therefore empty......

Reminds me of this:
http://thedailywtf.com/Articles/Bourne-Into-Oblivion.aspx



_________________
Gentoo x86-64 2.6.29.1
FreeBSD 7-CURRENT
Arch x86 2.6.30
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Wed Jul 29, 2024 3:05 am    Post subject: Reply with quote

I mayhap have been using the same script....

or i should really not write shell scripts at 3AM after a night at the bar.....



_________________
ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)

PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
Back to top
View user's profile Send private message Visit poster's website
masinick
Linux Guru


Joined: 03 Apr 2024
Posts: 8615
Location: Concord, NH

PostPosted: Wed Jul 29, 2024 4:02 pm    Post subject: A variant: rm -fre / Reply with quote

One lesson for the wise - ANY script that does an rm -fr of anything should have checks in it - and at least a echo or two to help diagnose it, but if it has variables and their values are empty or NULL, that should raise a flag and force termination of the script - but with a few diagnostic messages before termination to help deduce what is going on.

Some of the better Bourne, Korn, and Bash scripts put ${var} in place and evaluate ${var} before even placing it into any kind of expression. Failing to do that, as we can see - and as I have also experienced, can lead to some VERY interesting results, to say the least!

This reminds me of my own story. In March 1998 I left Digital Equipment Corporation after a very nice 13 1/2 year career there. My last job was in the Digital UNIX Engineering organization, specifically in the DUDE - Digital UNIX Development Environment, working on Internationalization (I18N) and Localization (L10N) --- see why we abbreviate? Those are LONG words!

Anyway, I always used to kid about using rm -fr /, (cd / && rm -fr *), and similar variations. Well, it just so happened that the Digital UNIX implementation of the rm command also happened to offer an e option to list errors and output. So a great way to watch a system self destruct is the command rm -fre /.

Since our organization produced and frequently tested nightly builds, plus we had every production release available, the fact that it took all of 20-30 minutes to build a new system from scratch, and the fact that whoever inhereted the systems that I was leaving would almost certainly rebuild them to suit their own needs, I thought, "What a great way to see the system - themas - go down in flames as I got ready to leave!" Only problem was that there was SO MUCH output that it took a long time to SEE all of the files getting removed as the system removed itself! Smile I finally gave up watching it around 4:30 PM and turned in my badge as I left. It was interesting watching it tear itself apart! Smile



_________________
Brian Masinick
Distros: SimplyMEPIS
sidux - no CAPS!, antiX, Debian
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Wed Jul 29, 2024 5:26 pm    Post subject: Reply with quote

mkfs is quicker, but not nearly so satisfying.....



_________________
ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)

PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
Back to top
View user's profile Send private message Visit poster's website
masinick
Linux Guru


Joined: 03 Apr 2024
Posts: 8615
Location: Concord, NH

PostPosted: Wed Jul 29, 2024 5:44 pm    Post subject: Reply with quote

Lord.DragonFly.of.Dawn wrote:
mkfs is quicker, but not nearly so satisfying.....


Yeah, you can't see the "torching" effect like you can with the famous "rm -fre /"! Smile



_________________
Brian Masinick
Distros: SimplyMEPIS
sidux - no CAPS!, antiX, Debian
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
nukes
Linux Guru


Joined: 29 Aug 2024
Posts: 4558

PostPosted: Wed Jul 29, 2024 6:22 pm    Post subject: Reply with quote

well, mkfs you could potentially recover from, only one directory is created (the root).
rm-ing everything, especially on journalled filesystems generally destroys the directory descriptors for each and every one.

wrt after nights at the bar - when i first went to uni there were a number of times I woke up and my computer was hosed - had to use a livecd to get it back up and running. I had vague memories of trying to reconfigure the whole system to do some silly thing or work in some ridiculous way but only getting half way through or getting stuck etc.

WRT self destruction, my best experience was on FreeBSD 6 - I was trying to rebuild the whole system with GCC4, and fix any compilation problems along the way. I was logged into X at the time, and the system literally broke around me - various features stopped working, and by the end of it I couldn't launch any programs (even xterm or csh) and all i had were xchat and a few terminals already running.

I didn't even bother trying to boot back into it after that Smile



_________________
Gentoo x86-64 2.6.29.1
FreeBSD 7-CURRENT
Arch x86 2.6.30
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Wed Jul 29, 2024 9:36 pm    Post subject: Reply with quote

or how about this fun one?

Code:
tee /dev/sda < /dev/urandom


thats a fun way to kill a install



_________________
ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)

PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
Back to top
View user's profile Send private message Visit poster's website
masinick
Linux Guru


Joined: 03 Apr 2024
Posts: 8615
Location: Concord, NH

PostPosted: Wed Jul 29, 2024 9:38 pm    Post subject: Reply with quote

That looks like you can wipe out the entire drive with that one!



_________________
Brian Masinick
Distros: SimplyMEPIS
sidux - no CAPS!, antiX, Debian
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Thu Jul 30, 2024 12:42 am    Post subject: Reply with quote

yep... and you see on the screen whats getting written to the drive!



_________________
ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)

PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
Back to top
View user's profile Send private message Visit poster's website
masinick
Linux Guru


Joined: 03 Apr 2024
Posts: 8615
Location: Concord, NH

PostPosted: Thu Jul 30, 2024 12:56 am    Post subject: Reply with quote

Lord.DragonFly.of.Dawn wrote:
yep... and you see on the screen whats getting written to the drive!


Ah, that might be fun! But when I did my famous "rm -fre /" on my AlphaStation back in 1998, I was IN X - CDE - the Common Desktop Environment, probably using a dtterm. Imagine when that environment vaporized but it was still providing stdout pretty far into all of it!

Your approach might carry it pretty far in too.



_________________
Brian Masinick
Distros: SimplyMEPIS
sidux - no CAPS!, antiX, Debian
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Servers and Server Administration All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All content © 2024-2009 - Usa Linux Users Group
This forum is powered by phpBB. © 2024-2009 phpBB Group
Theme created by phpBBStyles.com and modified by Crouse