sudo’s Hall of pain

  • brokenlcd@feddit.it
    link
    fedilink
    arrow-up
    14
    ·
    edit-2
    6 months ago

    More than a sys admin thing is a general linux user thing; i switched from an emmc computer with no drives marked as sdx; to one with nvme and hdd; i was used to my old pc where sda was whatever usb stick i plugged in; and i used dd with sda1… I nuked 1tb of data and i am still running photorec to try and recover something at least; fml.

      • brokenlcd@feddit.it
        link
        fedilink
        arrow-up
        12
        arrow-down
        1
        ·
        6 months ago

        Unfortunately to do backups i need the money to buy a drive to do backups on; most of my pcs are literally made out of scrap parts from broken machines.

        • Atemu@lemmy.ml
          link
          fedilink
          arrow-up
          5
          ·
          6 months ago

          I use scrapped drives for my cold backups, you can make it work.

          Though in case of extreme financial inability, I’d make an exception to the “no backup, no pity” rule ;)

          • brokenlcd@feddit.it
            link
            fedilink
            arrow-up
            1
            ·
            6 months ago

            I’m trying to do that; but all of the newer drives i have are being used in machines, while the ones that arent connected to anything are old 80gb ide drives, so they aren’t really practical to backup 1tb of data on.

            For the most part i prevented myself from doing the same mistake again by adding a 1gb swap partition at the beginning of the disk, so it doesn’t immediatly kill the partition if i mess up again.

            • Atemu@lemmy.ml
              link
              fedilink
              arrow-up
              1
              ·
              6 months ago

              I’m trying to do that; but all of the newer drives i have are being used in machines, while the ones that arent connected to anything are old 80gb ide drives, so they aren’t really practical to backup 1tb of data on.

              It’s possible to make that work; through discipline and mechanism.

              You’d need like 12 of them but if you’d carve your data into <80GB chunks, you could store every chunk onto a separate scrap drive and thereby back up 1TB of data.

              Individual files >80GB are a bit more tricky but can also be handled by splitting them into parts.

              What such a system requires is rigorous documentation where stuff is; an index. I use git-annex for this purpose which comes with many mechanisms to aid this sort of setup but it’s quite a beast in terms of complexity. You could do every important thing it does manually without unreasonable effort through discipline.

              For the most part i prevented myself from doing the same mistake again by adding a 1gb swap partition at the beginning of the disk, so it doesn’t immediatly kill the partition if i mess up again.

              Another good practice is to attempt any changes on a test model. You’d create a sparse test image (truncate -s 1TB disk.img), mount via loopback and apply the same partition and filesystem layout that your actual disk has. Then you first attempt any changes you plan to do on that loopback device and then verify its filesystems still work.

              • brokenlcd@feddit.it
                link
                fedilink
                arrow-up
                1
                ·
                edit-2
                6 months ago

                The problem is that i didn’t mean to write to the hdd, but to a usb stick; i typed the wrong letter out of habit from the old pc.

                As for the hard drives, I’m already trying to do that, for bigger files i just break them up with split. I’m just waiting until i have enough disks to do that.

                • Atemu@lemmy.ml
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  6 months ago

                  The problem is that i didn’t mean to write to the hdd, but to a usb stick; i typed the wrong letter out of habit from the old pc.

                  For that issue, I recommend never using unstable device names and always using /dev/disk/by-id/.

                  As for the hard drives, I’m already trying to do that, for bigger files i just break them up with split. I’m just waiting until i have enough disks to do that.

                  I’d highly recommend to start backing up the most important data ASAP rather than waiting to be able to back up all data.

        • billgamesh@lemmy.ml
          link
          fedilink
          arrow-up
          3
          ·
          6 months ago

          I’m in a similar boat, but tend to mirror my important files across a lot of my drives. Also, whenever I move hard drives computer to computer, I first look at the drive and copy everything I don’t wanna lose, just in case… Basically, learned to be careful the hard way a few times lol

        • Appoxo@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          2
          ·
          6 months ago

          You can buy (or get) cheap 1tb ssds or bigger 2tb hdds for sub 100€ where I am from.
          Pairing that with extreme conpression from veeam, not installing all programs in C:\ (or whatever system directory for linux) and either doing volume or file level backups should give you plenty of space to do those.

      • null@slrpnk.net
        link
        fedilink
        arrow-up
        4
        ·
        6 months ago

        I have plenty of non-critical Linux ISOs that I don’t back up (because that’d be like 12 TB).

        But I’d still be pissed if I accidentally wiped them.

  • 𝘋𝘪𝘳𝘬@lemmy.ml
    link
    fedilink
    arrow-up
    4
    ·
    6 months ago

    Some time ago I wanted to clean up home directory files permissions to be not readable by group or others. Instead of just removing group/other permissions I hard-set all directories to 700 and all files to 600.

    Took quite some time to repair not working scripts and “application containers”.

    • wellDuuh@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      6 months ago

      Well I nuked myself with chmod -r on my home directory this morning… My day is now dedicated to reinstalling nixos on my laptop… Glad I didn’t do this on a production server…

      Will be extra cautious now with the -r commands

      PS: I now see the need of timeshift despite of using nixos… I could have backed up my home dir… And restore the prev state

      • 𝘋𝘪𝘳𝘬@lemmy.ml
        link
        fedilink
        arrow-up
        1
        ·
        6 months ago

        Imagine accidentally running it on / instead …

        But wasn’t NixOS not specifically design to be protected against such issues?

        • wellDuuh@lemmy.worldOP
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          6 months ago

          😂 heck no! (Just found out)

          Nix provides a platform where you define how the system should be by specifying what version of apps to install, and configurations to inherit.

          It does not back up any configuration and files that are outside the defined configuration file! And Turns out there are plenty of them.

          What, You changed into dark theme on your android studio? Stored on home dir .local, not on nix configuration file

          Every app that I customized it whilst inside the app, the changes are thrown on .local.

          Again… TIMESHIFT would have saved me sooo much time.

          This is me Sangry now

          Edit: I hope this post saves someone a world of pain in the future

  • kattfisk@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    6 months ago

    Not chmod related, but I’ve made some other interesting mistakes lately.

    Was trying to speed up the boot process on my ancient laptop by changing the startup services. Somehow ended up with nologin never being unset, which means that regular users aren’t allowed to log in; and since I hadn’t set a root password, no one could log in!

    Installed a different version of Python for a project, accidentally removed the wrong version of Python at the end of the day. When I started the computer the next day, all sorts of interesting things were broken!