Background:

Typically when I’m trying something new on Linux, I search for an online guide that doesn’t assume I’m already an expert and looks like it should be easy enough for a pleb like myself to follow. Whatever it is I’m trying to do, it usually takes me multiple tries to get it right. Sometimes, when I’m venturing into new territory, I’ll derp around in a VM so I can take snapshots and then revert to the last good snapshot when something inevitably goes wrong. This approach works well for me most of the time.

But every now and then, I don’t want to use a VM, I want to use a spare laptop that I have lying around, “bare metal” if you will. It just feels more… authentic? My hesitation w/ practicing on spare laptops is that when I mess it up, the only way I know how to start over with a clean slate is to reinstall the OS and try again. This approach is not ideal b/c I mess up a lot - this is a fact of my life - and reinstalling the OS after every mistake takes a lot of time, to the point that I just stop persuing whatever project I was working on.

Question:

Is this a good use case for btrfs? How easy is it for a pleb like myself to take snapshots and then roll back to the previous state after jacking up a config file in /home or /etc or something?

  • doodoo_wizard@lemmy.ml
    link
    fedilink
    arrow-up
    8
    arrow-down
    1
    ·
    3 days ago

    Yeah I guess if you’re constantly slamming your penis in the car door than having a button that turns back time would be one approach.

      • doodoo_wizard@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        3 days ago

        NASA collected ancient herminudic texts and combined the antediluvian wisdom within with cutting edge materials science and technology to produce a device that could reverse the events of the last few seconds within a 1m radius at phenomenal energy cost, scrubbing the mission in the process.

        The soviets welded the capsule shut.

  • hobata@lemmy.ml
    link
    fedilink
    arrow-up
    2
    ·
    3 days ago

    Yes. If you can turn a blind eye to the terrible cli, or somehow set up an automated workflow once or find a nice gui/tui tool (by the way if you find one, post it here) - it’s well suited for your task.

  • Nibodhika@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    3 days ago

    Yes, that should work, but as someone who went through that phase before BTRFS was a thing keeping /home in a separate partition helps quite a lot, because then reinstalling the system is just a 15 min afair and you’re mostly back where you were before except some programs you might have installed that you will need to do so again.

    The next logical step for me was to keep a list of those programs, so I could just run a single command and get all of them installed. That eventually evolved into convincing me to use Gentoo, since it has this concept baked into the system. But compiling everything wasn’t for me, so I went back to Arch where I stayed for over a decade. And even though I almost never broke my system again, I always had that fear. I even switched to BTRFS when it became more stable, but never had to use a snapshot, so can’t help you on how much it restores.

    Recently I’ve migrated to NixOS, and I’m very happy with it. The appeal of it for me was how the system is declared, which is a very advanced version of my packages in a file that also includes configurations. This makes it so that making changes to your system requires you to modify those files and rebuild your system, and at boot time you can select from the previous generations of the system in case you broke something. In short, this makes your system unbreakable because worst case scenario you boot into the previous generation that worked and figure out what you did wrong.

    That being said, it’s learning curve is very steep, but the payoff for those of us who like to tinker is huge. If you’re interested I recommend checking vimjoyer’s YouTube channel, he has several videos about it, and since you’re already used to running things in VMs to test it should be easy for you to get started. And the best thing is that once you’re done with configuring the VM, almost the exact same config would work on your main machine out of the box and give you the exact same system (the only caveat is that there’s one file that relates to hardware which would have to be different, but it gets auto-generated during the install process).

  • moonpiedumplings@programming.dev
    link
    fedilink
    English
    arrow-up
    4
    ·
    3 days ago

    Yes, but there is something important to remember.

    By default, most Linux installs put there kernels in /boot, which is not on the btrfs partition. This is not an issue on distros that keep multiple kernel versions, but it can cause issues on distros that only provide one kernel version (Arch and Arch based distros).

    Because the kernels are not stored on the btrfs partition, they are not restored by btrfs snapshots. And if the rest of the system, including kernel modules, are a mismatched version due to restoration, then it means your system is unbootable.

    A simpler fix is to install ArchLinux’s linux-tls package, which is the stable version of Linux that doesn’t update constantly.

    But what I do to get around this, I put /boot on the btrfs partition, and /boot/efi is the seperate efi partition where grub is installed. Then, kernels are restored when I restore a snapshot.

  • BCsven@lemmy.ca
    link
    fedilink
    arrow-up
    3
    ·
    3 days ago

    Yes. Snapshot…make your changes… Try the system…and if it is messed use the old snapshot.

    If you try tumbleweed the snapshots are also integrated to the grub menu so you can boot to any snapshot, and if you like the one you booted to you issue sudo snapper rollback and that makes your current snapshot the default.

    It also has auto snapshots anytime you use the GUI yast tools, or other CLI tools like zypper, so you don’t have to manually created snapshots. Also has cleanup schedule to remove old snaphots either by date or number of snapshots

  • DefinitelyNotBirds@lemmy.mlBanned
    link
    fedilink
    arrow-up
    1
    ·
    3 days ago

    The snapshot approach works, but there is a trap nobody mentions: most people set up btrfs after the system is already installed, so the first快照 only captures whatever state they reached after those multiple failed attempts. The real win is snapshotting before you touch anything at all, ideally right after a fresh install when things actually work. Rolling back to a known-good state beats googling the same error message for the third time.

  • isgleas@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    3 days ago

    Usually, under btrfs filesystems containing system data you can get snapshots and rollback flawlessly, but some subfilesystems do not get those snapshots by default, like /var/log or /home, so you may need to set them up in order to enable snapshots, and manually create one when you start tinkering with your system. You then can revert the full snapshot, or even individual files