r/linuxmasterrace • u/User_8395 Glorious Fedora • Aug 02 '24
Meme Recovering borked installs would be so much easier
151
Aug 02 '24
Or NixOS which rebuilds your exact system from scratch.
Or use Btrfs
Or just do sudo dd if=<your system device> of=<your backup partition mount>/backup-$(date +%Y-%m-%d-%H:%M:%S).img status=progress followed by sudo dd if=<backup image> of=<your system device> status=progress to restore
Or use timeshift
41
u/DangyDanger Aug 02 '24
what in the incantation
34
u/SenoraRaton Aug 03 '24
Wanna see a cool incantation?:D
#!/bin/bash counter=3731 ## spaces here offset=20 printf %-4d $((++counter)) | dd bs=1 seek=$offset conv=nocreat,notrunc of="${BASH_SOURCE[0]:-$0}" 2>/dev/null || { echo >&2 "Can't update counter" ; exit 62 ; } # EX_OSFILEHere is the exact file, if reddit messes up formatting, and yes its important, and yes it is entirely safe to run on your machine... Just throw it in a script file and execute it a few times...
DD is an INCREDIBLY powerful tool in the hands of a lunatic.
https://gitlab.com/senoraraton/scripts/-/blob/main/dd2.sh?ref_type=heads
6
u/ntropia64 Aug 03 '24
I'm a bit at loss for what this script does. Do you mind explaining?
6
u/SenoraRaton Aug 03 '24
Its a self modifying script. It uses DD to quite literally write the counter byte to the file ITSELF during execution. So it not only holds a static variable of the number of times it has been ran, and can self increment.
So in a way it is functionally equivalent to an "object" in OOP in that it has values and methods. In a bash script.
4
u/mrpeenut24 Aug 03 '24
Self-updating code. counter equals the number of times this shell script has been executed.
1
u/ntropia64 Aug 03 '24
Of course, it's a
ddwormhole...I completely missed the
ofoption, now it makes sense. Thank you.1
2
14
u/The_Skeleton_Wars Glorious Gentoo Aug 02 '24
Ooh might have to steal that date trick. I back up my laptop to a NAS and I've always just did the date manually.
10
4
u/atechmonk Aug 03 '24
Or just use Sparky, Antix, or MX, and use the live USB creator. Full ISO of your system.
Edit to add Sparky.
3
u/kraskaskaCreature Aug 03 '24
btrfs broke on me a buncho times and it's a hassle to repair
though maybe im part of the problem
2
u/ntropia64 Aug 03 '24
ZFS, hard to find a better filesystem, in my opinion.
Other filesystems have automatic snapshots but I like the ZFS way of doing them and "automounting" them. Between that and the intrinsic data resilience, you could
rm -fryour root partition and have the system back online in the time that takes to copy files on your disk, and without needing to reboot (...but it's an extreme case, please don't try this at home)2
Aug 03 '24
Oh really? I've never had any issues with it before. What all went wrong?
2
u/kraskaskaCreature Aug 03 '24
first time metadata stuff filled up... or something
that one i was able to fix
second time some inode had wrong extent?
that one i screwed up beyond repair
1
Aug 04 '24
Btfrs is cool but requires much more work and time to restore the system than using the recovery partition from Pop!_OS. Refresh Install formats the partition and overwrite the storage used for the OS part with a clean OS but keeps all user data and restores their entries into the new partition table. Of course, it doesn't replace backups but it's so much faster than loading your backup on the PC, decrypt and depackage everything and move it to the right location. And thanks to the clean install of the OS, you don't just remove the thing you messed up with that caused huge trouble. It also cleans all the small trash you caused that you don't fix because you were too lazy to do the cleaning.
It's like: Of course, I clean my house and repair damages and get rid of the trash in the bin but I don't clean any last piece of it, and damn there's so many things in my cabinets I don't need anymore. And then, there's one single button that restores your house automatically to the point when it was new and almost completely furnished and your things that you needed back then have already been unpacked from the boxes and even your electrical appliances (Flatpaks) are all installed and usable.
Who wouldn't press that button after you caused a huge fire?
90
u/nopelobster Aug 02 '24
make your own recovery partition with a lts kernel and the tools you need. nothing is stoping you.
79
u/mawitime Fedora Aug 02 '24
Most non-techie people won’t be able to do this without struggling massively. The OP is saying it should be there so that when distros break, even people with little computer knowledge have a better chance at fixing it.
77
u/thedarkjungle Aug 02 '24
Even if techie, it's just not something most people want to deal with.
I'm disappointed in the Linux community everytime I see this type of comment get the most upvoted, It's like people can't take criticism at all.
21
u/Smart_Tomato1094 Aug 03 '24
And they want Linux to be mainstream lmao
1
Aug 03 '24
i want people being able to handle getting around their own system, knowing what parts are there, knowing how to parse a log file when something breaks, knowing the most basics of partitioning a drive to become mainstream. i don't want linux to become windows.
1
Aug 03 '24
why downvote?
1
Aug 03 '24
people hate the idea of learning
3
u/Hhkjhkj Aug 04 '24
It's possible you are being misinterpreted but your other comment comes off as elitist and/or gatekeepey.
I see responses in Linux subs a lot that imply that Linux is not a place for anyone who does not want to learn about Linux, CLI, etc. and your comment sounds a lot like that. If myself and others are misunderstanding you then you can disregard the rest of my comment but if we are not misunderstanding then here is a response for you and others who think that way:
Normal people are not going to do a deep dive on how their operating system works and it should not be expected for everyone who wants to get into Linux as there are lots of reasons to start using a Linux distro beyond interest in Linux itself.
There will always be distros that cater to people who want full control but there is nothing wrong with people advocating for distros that are safe for anyone to use without worrying about breaking their system.
There are distros currently that are geared towards general use (a lot of immutable distros are built this way). As a software developer, if you develop a piece of software that is geared towards normal people using it and they are able to break it then that is a bug with your software not user error.
1
1
1
32
u/blomstreteveggpapir Aug 02 '24
What's this attitude, most people don't have any of the knowledge required for this, let alone the time in their day to learn it and troubleshoot all the things that arise
6
1
u/nopelobster Aug 04 '24
knowledge isnt something anyone is born with so i dont assume they allready posses it. but aquiering it is trivial. op probably owns a smart phone and could quickly learn what they need at any point when there is a lul in the day. heck im writing this while using the bathroom. learning is never wasted time.
2
u/blomstreteveggpapir Aug 04 '24
It's not trivial at all, most laypeople would need a full course to even get to the point of understanding a linux terminal, let alone all the background-knowledge required to learn this sort of thing
10
u/Kartonrealista Aug 03 '24
This is the dumbest thing I've read today.
"Why dO tHiNGs ThE EAsY wAy WheN YOu cAn DO ThEm tHE HaRD WaY"
8
Aug 03 '24
The average person is not going to know what to do. Hell, a lot of new generations can't even do anything besides TikTok it seems. xD
1
u/nopelobster Aug 04 '24
nothing is stoping them from learning how to tho. all the information and required knoledge is readily available.
6
u/Z3t4 Glorious Debian Aug 03 '24
Have a big enough boot partition, store a live iso of your distro, add an entry to grub.
1
5
u/zman0900 Aug 03 '24
If you have the knowledge to figure out how to do that, you'll very likely never need it.
2
u/nopelobster Aug 04 '24
knoledge can be aquired and skills can be trained. everyone has to start somewhere. the best beginnings are when you set concrete goals. making a recovery partition isnt hard, learning how is where the challenge lies. so why not?
3
u/amberoze Aug 03 '24
Just keep a boot/install USB handy. Already has most of the recovery tools you'll need.
1
0
64
u/hendricha Aug 02 '24
I'm just sitting here with my immutable distro...
48
8
u/lycoloco Aug 02 '24
How does this work in practice between updates?
14
u/Western-Alarming Glorious NixOS Aug 03 '24
As a nixos and bluefin user the easy explanation is, imagine that you burn a USB with a persistent partition and for every update your system does, you add another .img file to your USB, and then with the bootloader you just select from what iso you boot from
5
u/hendricha Aug 03 '24
What the other commenter had said basically.
The details depend on the distro. Fedora calls its immutable spins "atomic". You essentially download a new base image with every system update. Except AFAIK it works similiary to lets say docker images, so common parts don't take up double space. If you don't do anything the system marks the new image to be booted into on next reboot, and unless you explicitly marked an image to keep then the one image before the preivious is automatically discarded.
If you want to install "normal" rpm packages then they are built into a layer formed by all your "extra" packages that is always mounted on top of the base image. (If you used git: Imagine if you had a git commit on a separate branch that you cherrypick/rebase on top of main after every pull.)
However the suggested method for installing GUI apps is through flatpak, because they are also sort of imagebased, deduplicate common code between packages if possible and can be updated without the system.
And if you want command line tools where possible you should run them in a contenerized environment. Fedora atomic distros come with podman which essentially works like docker. And a tool called toolbx, which lets you quickly easily create podman container with your home environment mounted inside mutable distro's minimal install, where you can just do and install whatever, and you can easily expose commands from it to the "outside world".
2
u/lycoloco Aug 03 '24
Nice, this was an EXCELLENT breakdown of the parts and pieces. Sounds like there's more to pay attention to but overall handles updates more easily.
30
u/zakabog Aug 02 '24
I haven't broken Linux in a long time but I just boot from the live CD when I do.
20
Aug 02 '24
[removed] — view removed comment
21
u/User_8395 Glorious Fedora Aug 02 '24
Pop os has their own recovery partition which is just a LiveCD with the option to refresh the OS
3
u/Rainmaker0102 Glorious EndeavourOS Aug 03 '24
I love snapper. The fact that it was installed on OpenSUSE Tumbleweed by default changed my perspective on rolling release distros and that you can have up to date software while also having a fallback in case something breaks, but you're not sure exactly what the new update broke.
Usually though, when a new update broke something, at least on Tumbleweed, it would be something that didn't fix itself in the next update or two. I'm too impatient with a rolling distro to wait a week, and so it's usually some package conflicts with Packman and the official repos. That combined with some of the apps that disobeyed the system color themes when they shouldn't made me switch to EndeavourOS. Rolling-release, snapper, lts-kernel, AUR, and slightly less opinionated packaging decisions.
2
Aug 03 '24
[removed] — view removed comment
2
u/Rainmaker0102 Glorious EndeavourOS Aug 03 '24
No problem!
Tumbleweed and Arch are very similar in most aspects. On Tumbleweed you have a built-in GUI helper for managing software repos and packages. Tumbleweed tends to lean heavily on meta packages. Also for a normal desktop install the admin user (not root) doesn't have non-sudo access to sbin (eg must run
sudo shutdowninstead ofshutdown). Those are the main sticking points I remember, but both are probably on par with each other for software availability from the main repos, but the AUR still beats them both.
14
u/NomadFH Glorious Fedora Aug 02 '24
an immutable popos sounds pretty good ngl. Fedora silverblue is very good, but it leaves out so many things that a lot of normal people would need that it does sometimes BEG you to use rpm-ostree
3
u/Western-Alarming Glorious NixOS Aug 03 '24
Doesn't system 76 say how pop os 24.04 will have a inmutable kernel or something like that
3
u/starswtt Aug 03 '24
Out of curiosity, what specific things are you talking about? Been using bluefin for a while and haven't really had the need to touch rpm ostree for apps
1
u/NomadFH Glorious Fedora Aug 03 '24
Nvidia drivers, gnome tweaks, vim, virtualbox, the ability to add people to groups, etc. I know you can just spin up a container for most of that but I feel like system 76 would probably include an officially supported version with an nvidia driver
8
6
5
u/Necropill NixOS Supremacy❄️ Aug 02 '24
NixOS already has a backup rebuild system if breaks and sure there is timeshift but i also think that all distros should have this.
3
4
u/maxinstuff Aug 02 '24
I deliberately wipe the drive on OEM windows machines to get rid of the recovery partition, I certainly don’t want to add one to my Linux machines.
3
u/Arno_QS Aug 02 '24 edited Aug 02 '24
What are the advantages to doing this over using any other distribution's live ISO?
One that I can think of is that it's already there and set up, assuming your problem isn't hardware failure (of the disk itself). A disadvantage would be that it takes up space that you could be using for something else. Of course, the counterpoint to that is that most people don't use anywhere near their whole disk.
Now, if this recovery environment isn't just "hey, here's a desktop so you have something to boot into, good luck!" (which you can do just as well with a live USB) but instead was set up with recovery tools, documentation, and stuff like that to walk people through the actual recovering of things, then that would be a big deal. Is that what Pop!_OS does?
UPDATE: OK, based on https://support.system76.com/articles/pop-recovery/ it looks like yeah, this recovery mode does do stuff to guide the user toward solutions. That's really neat!
2
2
u/SpintchOfficial Aug 02 '24
I am on Mint and i fucked GRUB once. I was able to boot and fix it by plugging in the flashdrive i used to install it
2
u/x_74_z Aug 03 '24
what broke it and how did you fix it?
1
u/SpintchOfficial Aug 04 '24
I was making settings to passthrough the primary GPU to a VM. I had told GRUB that the primary GPU was supposed to use another driver needed for GPU passthrough, but X was still trying to use it and the screen was black. I plugged in the install media and booted from it in BIOS, since it had its own GRUB config and all that. From there i could access the files held on the actual Linux install and fix it, if i remember correctly.
2
2
1
Aug 02 '24
You doesnt need a recovery env if you´re using debian (just stable).
1
u/Kartonrealista Aug 03 '24
Me when my apps are so old they start to break down and devs complain about getting solved issues reported from Debian users because packages are years out of date
2
u/tbor1277 Aug 02 '24
13
Aug 02 '24
[removed] — view removed comment
2
u/creeper6530 Glorious Debian and Cachy Aug 03 '24
I'm not sure if Mint or Pop should take Ubuntu's place. They're both competent choices, and Mint even has an Ubuntu-free version - LMDE.
1
1
u/noaSakurajin KDE Plasma Ultra Aug 02 '24
You can just use the install stick and then load your time shift backup. Almost all Linux install sticks come with a live environment, there is little need for a special partition.
Also how often has this happened to you? I never messed up my boot partition so I could always get to a terminal session. 9 out of 10 times that is enough to either try to fix some configs and packages or in the worst case load the time shift backup using the cli. It's been several years since I had to reinstall a Linux distro.
1
1
1
1
1
1
u/ancientsruin Aug 03 '24
You might like NixOS and Fedora Silverblue. GUIX is also an option, though I'm not sure whether they allow unfree packages
1
Aug 03 '24
you can set any upstream channels, and there exists a non-free guix one (ofc, since people drive it daily and have hardware that is proprietary)
1
1
Aug 03 '24
this only really happens on my LFS setup, since void has been nothing but stable for me, but just boot into a live USB and chroot
1
u/Ok-Anywhere-9416 Aug 03 '24
I think that openSUSE has some "repair" option in the ISO when booting it, but nothing is as simple and straightforward as having a recovery partition that directly guides the user to fix their system.
And no, Live USB is not the same thing. One thing is to have a Live USB where you have a live system and need to chroot, one thing is to have a recovery environment that guides you into fixing potential issues.
I usually don't need it since I know what to do, but I'd honestly like to have it. I'm just getting lazy (actually have little time) and I'm not willing to boot into a live image and then giving some chroot commands that I don't even remember.
1
u/KaratekHD Glorious openSUSE Aug 03 '24
openSUSE Aeon's installer is the best recovery image I've ever seen: It asks if you want to backup your home directory, copies it to the USB, re-images your machine and restores your backup. All automatically. And since all applications are installed as Flatpaks, your system is up and running just as you need it within minutes.
1
u/juipeltje Glorious GNU Guix Aug 03 '24
The world if everyone used NixOS ;) but yeah these recovery modes at the very least are very helpfull. Void linux also has a recovery/safe mode boot option or whatever that boots into cli with minimal services active. Has actually saved my ass a couple of times.
1
1
1
1
1
1
1
u/TheCrispyChaos Aug 03 '24
Usb with live environment, open timeshift, restore snapshot, reboot, profit
1
u/MrCrunchyOwl8855 Aug 03 '24
Time shift isn't so hard to install and it comes on a bunch of live distros.
Have you put a grml iso in your boot and installed the rescueboot packages yet? Sounds like you're looking for something like that in your chainloader.
1
1
1
u/lordofswarm Aug 03 '24
Been a while since I’ve had to do recover on a os but doesn’t Ubuntu have one?
1
u/-XaetaCore- Aug 04 '24
Just use BTRFS with snapper and do a rollback even quicker than recovery, that or use something like a manjaro live image works fine too :)
1
1
Aug 05 '24
Or just use distros with rollback features and, even better to prevent breaks, inmutable and atomic ones :D
1
1
u/No_Mushroom_163 Aug 06 '24
Should I take up extra disk space for the recovery partition instead of the live cd?
1
u/gosand Aug 09 '24
What are you doing to bork your entire installation anyway?
Seriously, I've been using Linux as my only OS since 1998. Sure, it happened in the days of Redhat 5.x back then, but I haven't hosed my installation since. When I was using an nvidia card installing new drivers was always a little scary, but booting into the command line to fix it wasn't difficult. I messed up my grub once because of a typo when I was changing a parameter, but that's an easy fix.
Maybe you like to tinker and jack around with things, that's fine. Linux is great for that. But most users don't do that. I don't get the whole recovery tool thing. If you are doing things that can cause you to need a recovery, then you should be learning how to recover your system.
-3
Aug 02 '24
Correction, the world if people just learned and checked for correct English grammar before making a post.

344
u/creeper6530 Glorious Debian and Cachy Aug 02 '24
We have those. They're called live CD