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
    3
    arrow-down
    1
    ·
    2 hours 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
        1
        ·
        1 hour 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.

  • SavvyWolf@pawb.social
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 hours ago

    Snapshots seem an ideal tool for the job. It won’t replace a full backup system, but as long as the cost of failure (such as you mistyping a command and nuking the disk’s partition data or something) is only a few hours of OS reconfiguration rather than losing priceless family photos, it should work.

    I use btrfs snapshots on my system. When I’m about to do something “risky” (e.g. trying out kde or cosmic) I take a snapshot beforehand. Then when I want to go back, I just restore the snapshot and reboot.

    For /home, there won’t be a lot of OS configuration there, and if it’s a burner machine you probably won’t have much personalisation done on it. However, if you want to backup configuration there, look into a dotfile manager.

  • moonpiedumplings@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    ·
    5 hours 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.

  • skyline2@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    3
    ·
    9 hours ago

    This is what openSUSE Tumbleweed is designed to do, although config files in /home require manual setup to include. It allows you to completely rollback if necessary after a system upgrade, allowing you to use a bleeding edge distro without fear of having an unusuable system. If an upgrade goes bad, usual procedure is to roll back to the last btrfs snapshot and just wait for the fix (which usually comes in a couple days to a week, as Tumbleweed advances rather quickly).

    openSUSE has a specific btrfs subvolume setup and grub/systemd-boot integration to enable this, which is not too common even today, so it really is a bit special in that you can have this functionality without excessive time spent setting it up manually.

  • Onno (VK6FLAB)@lemmy.radio
    link
    fedilink
    arrow-up
    6
    ·
    11 hours ago

    While this doesn’t answer your question, I use Docker for this exact purpose, since you can throw away everything if it fails, whilst keeping a recipe for success documented in a Dockerfile.

  • BCsven@lemmy.ca
    link
    fedilink
    arrow-up
    3
    ·
    10 hours 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

  • Ada@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    1
    ·
    8 hours ago

    That’s exactly why I used them!

    I’m running a rolling distro on my main desktop, when I first moved over to linux (a couple of years ago now), I kept breaking things without having the knowledge to fix them. And then I discovered snapshots!

    The one thing I would say to be aware of, is to make sure you have a bootloader hook as well, that will let you actually boot in to the previous snapshots from the boot menu.

    I use CachyOS and it has this stuff as out of the box options during the installer.

  • tortiscu@discuss.tchncs.de
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    11 hours ago

    If you keep within the file system (e.g. don’t format anything or write to the device itself), are capable of executing a few commands in a terminal, and know how to boot from a live linux in case something goes wrong, you should be fine using snapshots, I’d say

  • hornedfiend@piefed.social
    link
    fedilink
    English
    arrow-up
    3
    ·
    11 hours ago

    Yes, it does. i recently installed a bunch on crap and decided I don’t need any of it, so I just rolled back to the snapshot I created manually, before starting the process and my system was simply restored.

    Just keep one thing in mind, rolling back automatically makes the filesystem read only so You need to remount.

  • DefinitelyNotBirds@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    9 hours 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
    ·
    edit-2
    10 hours 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