View previous topic :: View next topic |
Author |
Message |
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 606 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Mon Jul 27, 2025 2:12 am Post subject: OOOPS.... Now what? |
|
|
so we are all familiar with the following command, and it fills us with dread to our very bones...
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 |
|
lynch Moderator

Joined: 15 Nov 2025 Posts: 2659 Location: The Diamond State
|
Posted: Mon Jul 27, 2025 8:54 am Post subject: |
|
|
Recover everything? I doubt it.
At least you can congratulate yourself for doing backups.
What was the equivalent command?
_________________ Mandriva 2025 Spring -2.6.31.12-server-2mnb
PCLinuxOS 2025 -2.6.26.8.tex3
|
|
Back to top |
|
nukes Linux Guru

Joined: 29 Aug 2025 Posts: 4558
|
Posted: Mon Jul 27, 2025 11:30 am Post subject: |
|
|
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 
_________________ Gentoo x86-64 2.6.29.1
FreeBSD 7-CURRENT
Arch x86 2.6.30
|
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 606 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Mon Jul 27, 2025 5:34 pm Post subject: |
|
|
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 |
|
mushroom Ultimate Member

Joined: 29 Jun 2025 Posts: 2128 Location: Queen Charlotte B. C. Canada
|
Posted: Tue Jul 28, 2025 4:54 am Post subject: |
|
|
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 
_________________ 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 |
|
nukes Linux Guru

Joined: 29 Aug 2025 Posts: 4558
|
Posted: Tue Jul 28, 2025 3:36 pm Post subject: |
|
|
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 |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 606 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Wed Jul 29, 2025 3:05 am Post subject: |
|
|
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 |
|
masinick Linux Guru

Joined: 03 Apr 2025 Posts: 8595 Location: Concord, NH
|
Posted: Wed Jul 29, 2025 4:02 pm Post subject: A variant: rm -fre / |
|
|
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! 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!  |
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 606 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Wed Jul 29, 2025 5:26 pm Post subject: |
|
|
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 |
|
masinick Linux Guru

Joined: 03 Apr 2025 Posts: 8595 Location: Concord, NH
|
Posted: Wed Jul 29, 2025 5:44 pm Post subject: |
|
|
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 /"!  |
|
Back to top |
|
nukes Linux Guru

Joined: 29 Aug 2025 Posts: 4558
|
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 606 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Wed Jul 29, 2025 9:36 pm Post subject: |
|
|
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 |
|
masinick Linux Guru

Joined: 03 Apr 2025 Posts: 8595 Location: Concord, NH
|
Posted: Wed Jul 29, 2025 9:38 pm Post subject: |
|
|
That looks like you can wipe out the entire drive with that one! |
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 606 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Thu Jul 30, 2025 12:42 am Post subject: |
|
|
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 |
|
masinick Linux Guru

Joined: 03 Apr 2025 Posts: 8595 Location: Concord, NH
|
Posted: Thu Jul 30, 2025 12:56 am Post subject: |
|
|
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. |
|
Back to top |
|
|