Accidently ran sudo rm -rf /*

Or read posts #7 #8 #10 which discuss preserve-root.

1 Like

I got lazy, and called out for it… :smiley:

That is… good to know…

See my earlier post. /* is a glob pattern that is expanded by the shell before being passed to rm (or any other command, see echo /* for example).

The POSIX standard only specifies that the rm command will fail if the operand resolves to the root directory, which is /, not /bin or /boot or anything else in the root directory.

3 Likes

Just like pointing gun at your head and pressing the trigger might kill you? Yeah, valuable info.

Well, I’ve learned something from you as I’d never heard of ext4magic. On the occasions when a folder got accidentally wiped I tried testdisk, but so far it doesn’t seem to work with Linux. Seems to only work with partitions, but not deleted files or folders. But the Windows version of testdisk always seems to work well with both.

As for your issue, I’m afraid it’s re-install time. Take an image of your system using Disks next time while it’s working and just after a system update. Make sure Manjaro works okay after the update before you ever take an image (eg reboot Manjaro first). When you re-install I’d advise making a separate Home partition, which is an install option.

If you’re in UEFI mode I’d advise that your disk is formatted to GPT during installation. But watch out if you have Linux and Windows on the same disk as you will wipe Windows during that process. If you install Linux on a separate disk you should be fine formatting the intended Linux disk to GPT.

@Warp And this time, use btrfs and separate home.
Make sure timeshift is setup and that an update-grub finds them.

That way you would never end up in this situation again. Then you could have used a live iso, chroot, install grub and let grub find the timeshift subvolumes to boot/restore from. Also install kernels if needed.

But a timeshift is not a complete backup!

I read the whole thread now and it seems you are accepting your fate and take it as a learning experience, well done!

Good luck!

And then there are still some people that decides “I don’t believe you! I’m gonna do it, and nothing bad will happen.”

They’re right that nothing bad will happen for humanity.

My bad for not replying in a tad bit, had to sort out some business.

On the topic of recovering the lost files, I dd’ed (not dd-rescue, should I try that instead?) it into an ISO, and got testdisk to work, despite the previous error. I believe I’ve had testdisk running for about 19 hours now, and it’s got 995,865 files (bytes? sectors? not exactly sure) recovered, 16 failed, out of 468,854,977. That is a HUGE difference between the amount of files recovered, and the amount of files to be copied, and keep in mind that is has been running for 19 hours. I think it got the home folder done, but nothing from /bin/, /boot/, /dev/, or /etc/, so it might be time to just stop testdisk and just rsync the rest over. I think that there is no denying that I’m in for a reinstall now, unless?

Will consider.

Sounds good to me.

No windows. Just Linux. I will attempt to get UEFI to work.

Pretty much. Looks like I’ve got no other choice. I’m pretty sure I can’t just go about deleting the boot folder, the essential binaries folder, the device files, and the configuration files for about every application on the system, and expect to just be able to fix it without any consequences. This seems like a good start, but I’m a pessimistic person, and I feel like recovery is going to take a lot more than that.

Just thought of this:

IF you have extra, spare space at least the size of your disk, or can get it, there is a chance you can recover your data using Testdisk:

I myself have used it at least twice now. Once on my own disk, when I accidentally deleted the wrong directory, causing about 1.5TB of MIA sh…tuff. It recovered it better and faster than someone using Windows did. Thee other time was ~250GB for family, on a NTFS partition even. If you follow the instructions to the letter it should help.

Use it to copy all your data over to the other disk, reformat this one, and copy it back. TADA!!!

1 Like

I made a little mistake in my last post, I meant I’ve had testdisk running for about 19 hours, not dd.

AH, sh1te. Sorry then. Bummer indeed.

If the filesystem was not being used, I don’t think it would matter, but I could be wrong. Since you started and so much time has passed, if you fail, you can retry with dd-rescue.
But one thing. dd doesn’t care about how much data is on the device, it will copy everything (if it’s empty, it might just be zeros, but dd will still copy the complete drive). Yes, if the drive is big, it can take a LONG time.

God damn it, I typed all this up and in the meantime…
Well, maybe it will benefit someone… xD

Good luck!!

Edit

Ok buddy, are you ok? xD

You don’t need /dev. It’s a tmpfs — a filesystem in virtual memory — and it is populated by the kernel at boot time, and managed by udev at runtime.

Oh. Well that’s nice. Makes this job 1/4 less hard, statistically. Why would the rm command not segfault if it was trying to delete those files?

If I were you, I’d simply back up /home and reinstall. It’s going to take far less time and be far less painful than trying to salvage that mess. :man_shrugging:

Erm…I think so… :sweat_smile:

Fixed now.

1 Like

That would probably be for the best, though it would be pretty nice to have to /etc/ folder just for reference.

Well, if it’s gone, it’s gone. :frowning_man:

It’s a lesson hard-learned, but maybe now you’ll start afresh with a decent backup strategy. :slight_smile:

Fair enough. It’s what I get for not making 'backupes" :laughing:

2 Likes

I would suggested to setup TimeShift on your new installation for the system itself, don’t do automatic snapshots they are kinda pointless, just do a system snapshot once in a while to have a recent version of the system available if needed (and manually manage your snapshots, keep one or more, delete old ones). Of course, saving the snapshots on the same disk will not help if you do that again, and delete the whole system disk, so another advice, save the snapshots on another partition or disk if you can.

For the Home folder do not use TimeShift it is a bad idea, as restoring a snapshot will remove/revert any change in the Home folder from the time the snapshot has been taken, things WILL be lost. Use other tools like DejaDup or similar, and discard folders like Downloads, Steam, Games, or other high volume folders that are pointless to backup for safekeeping.

Don’t do commands you’re not 100% sure the result will be exactly what you expect.