I don’t fucking know why I can’t eject USB hard drives. I installed the SysInternals apps, and best they can tell me is that Dropbox is fucking with the drives. I explicitly told Dropbox to not fuck with USB drives. I don’t know who’s lying, I just want whoever is fucking with the drives to stop fucking with the drives, OK??? OK.

  • Tamlyn@lemmy.zip
    link
    fedilink
    arrow-up
    29
    ·
    2 days ago

    How is linux handle such situations, i’m new using it and haven’t looked that up yet, well i didn’t got in such a situation yet, but i only used a handful of time a external hard drive

    • prole@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      4
      ·
      edit-2
      1 day ago

      Linux doesn’t care if you have a file open in multiple places. In fact, if you edit it in one place, it might even prompt you to overwrite with the new data, or save-as to a different file, in the other place

    • Rose@piefed.socialOP
      link
      fedilink
      English
      arrow-up
      33
      ·
      2 days ago

      Basically, if you, as a regular user, cannot unmount a device, you can usually just go to root shell (sudo -i), see where the thing is mounted (just use mount) and then unmount it (umount /media/blah/floop). If it says the device is still busy, as root you can remount it as read-only and then unmount it (seeking documentation left as an exericise to the reader, as I’m sitting at a Windows system now).

      There’s also lsof (“list open files”) tool, which can be used to see which exact programs are using files on that device, which you can then use to kill those sneaky processes (ps, kill).

      • halcyoncmdr@lemmy.world
        link
        fedilink
        English
        arrow-up
        34
        arrow-down
        16
        ·
        2 days ago

        So a complicated set of terminal commands and alternatives you need to have memorized ahead of time. That’s definitely the linux solution. You can do it, but no average user would ever be able to when they need it.

        Windows probably has some equally complicated way of finding what is locking a file/folder… or you can just install File Locksmith which is a Microsoft PowerToys tool, and just have it in the context menu everywhere.

        • TheTechnician27@lemmy.world
          link
          fedilink
          English
          arrow-up
          36
          arrow-down
          7
          ·
          edit-2
          2 days ago

          No average user would be able to look up what commands to run? Because newsflash: unlike Windows, searching for a common problem on Linux normally turns up a solution written by a human who knows what they’re talking about.

          “Windows doesn’t even have basic package management like every Unix-like OS does so you don’t have to individually update applications and go find them on the Internet, but this one edge case on Linux requires like two terminal commands (the sudo -i is totally superfluous if you just put sudo in front of commands) instead of installing an entire separate tool you’ll ever use one time like on Windows and which an average user wouldn’t even know exists. Therefore Linux is more complicated.”

          Incidentally, here’s what Microsoft officially recommends for the “average user” regarding PowerToys:

          It’s insane how nose-blind Windows users are to how user-unfriendly their OS is.

          • halcyoncmdr@lemmy.world
            link
            fedilink
            English
            arrow-up
            20
            arrow-down
            6
            ·
            2 days ago

            It’s insane how nose-blind Windows users are to how user-unfriendly their OS is.

            Oh the irony. You clearly don’t work with any sort of end user.

            For 99% of computer users, if the GUI doesn’t have an option, it doesn’t exist. They aren’t searching past a basic Google of the issue showing them step by step instructions of how to use the GUI to fix the problem. If there is no way to do so in the GUI, it’s not getting fixed by them, they’ll take it to the Geek Squad if they even decide to fix it at all. They’re must more likely to just ignore an issue. In this case, just removing the USB drive and complaining about something being corrupt later on. The idea of the terminal scares the average person.

            Windows doesn’t even have basic package management like every Unix-like OS does Well that’s simply wrong. winget upgrade --all I just upgraded 44 apps I definitely didn’t install via winget, they were all installed via individually downloaded installers at some point in the past, but all upgrade with a single package manager command in a terminal. Certainly seems similar to me. It may not be everything, but it’s certainly the majority of things on this system other than the games.

            • u/lukmly013 💾 (lemmy.sdf.org)@lemmy.sdf.org
              link
              fedilink
              English
              arrow-up
              15
              ·
              2 days ago

              Alright, so others went over the “easy” way to see which program is being the offender. But I feel like the average Lemmy user just skips GUI at this point.
              Say hello to KDE:

              KDE also does automatic fsck before mounting, which is why it may take some 2 seconds to mount a drive.

              HDDs it properly spins down and unpowers as well.

            • Rose@piefed.socialOP
              link
              fedilink
              English
              arrow-up
              23
              arrow-down
              2
              ·
              edit-2
              2 days ago

              For 99% of computer users, if the GUI doesn’t have an option, it doesn’t exist.

              Literally 99% of Windows tech support is

              Have you right clicked on Windows menu, selected Terminal (Admin), then entered sfc /scannow and then DISM /Online /Cleanup-Image /CheckHealth and DISM /Online /Cleanup-Image /ScanHealth and DISM /Online /Cleanup-Image /RestoreHealth? …ohhh shit you’re still fucked up - well, maybe you need to completely reinstall windows, well, here’s the page on how to do it.

              That’s the difference with Linux. Your average user never uses terminal, and when they do, they find the tools suck.

            • Honytawk@lemmy.zip
              link
              fedilink
              English
              arrow-up
              16
              ·
              2 days ago

              They aren’t searching past a basic Google of the issue showing them step by step instructions

              Your users are searching for their problems???

              Most wouldn’t even do that.

              If the button isn’t right there to fix everything automatically, the problem just stays that way until they (maybe) restart

            • pivot_root@lemmy.world
              link
              fedilink
              arrow-up
              4
              ·
              edit-2
              2 days ago

              If there is no way to do so in the GUI, it’s not getting fixed by them, they’ll take it to the Geek Squad if they even decide to fix it at all.

              The best part is that Geek Squad probably won’t even fix it.

              With the amount of time allocated to tasks and the lack of autonomy retail workers are given, the solution to anything not explicitly written in an employee runbook is going to be “we need to reinstall windows” or “it can’t be fixed, but we have a new computer you can buy”

          • The_Decryptor@aussie.zone
            link
            fedilink
            English
            arrow-up
            4
            ·
            2 days ago

            Windows doesn’t even have basic package management like every Unix-like OS does so you don’t have to individually update applications and go find them on the Internet

            Funny thing is that it does (winget), but it’s a terminal app. Windows users who look down on Linux users for “needing” to use a terminal don’t want to bring it up, so Linux users also aren’t aware of it and never point to it as a counter example.

        • Rose@piefed.socialOP
          link
          fedilink
          English
          arrow-up
          8
          arrow-down
          3
          ·
          2 days ago

          Well, the commands that I presented (sudo, mount, umount, ps, kill, even lsof) are actually just normal commands that you use to do ordinary things on your system to manage account elevation, mounted disk volumes, processes, and running processes. You need to “memorise” them just as much as you need to memorise their counterparts in a Windows system (Run As/Explorer/Explorer Eject/taskmgr) (…what kind of nerd memorises Ctrl+Alt+Esc anyway?).

          …except you don’t have lsof, you literally need to install SysInternals Process Explorer.

        • raspberriesareyummy@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          2 days ago

          You can also just pull the USB drive out, if you have waited a reasonable time after last writing to it, no harm will be done.

          Also, terminal commands have the advantage that they are the same over the course of 20something years and across all desktop environments, while the tinyfloppy windows moves critical functions around with every second patch so you have to relocate stuff you had just memorized.

          • Russ@bitforged.space
            link
            fedilink
            English
            arrow-up
            4
            ·
            2 days ago

            And if you’re not sure whether the cache has been fully flushed, run sync and it’ll return once it’s done!

        • BombOmOm@lemmy.world
          link
          fedilink
          English
          arrow-up
          4
          arrow-down
          2
          ·
          2 days ago

          So a complicated set of terminal commands and alternatives you need to have memorized ahead of time. That’s definitely the linux solution. You can do it, but no average user would ever be able to when they need it.

          As a point of contrast. In Linux Mint you press the eject button. That’s it.

          The other guy was getting into more detail for people who want it.

          • halcyoncmdr@lemmy.world
            link
            fedilink
            English
            arrow-up
            5
            ·
            2 days ago

            And the same works 99% of the time in Windows. We’re talking about the small fraction where pressing eject doesn’t work for whatever reason.

          • halcyoncmdr@lemmy.world
            link
            fedilink
            English
            arrow-up
            3
            ·
            1 day ago

            It’s nothing about learned helplessness, it’s about what the average user experience is for new and inexperienced users. And terminal commands are just not new user friendly. If Linux ever wants to consider being true competition for a Windows replacement with the average user, it has to provide easy to use GUI options for most commands, and it needs to do all basic functionality without a terminal ever being needed.

            Like @[email protected] posted elsewhere in the thread, KDE has a good GUI for an end user experience for this exact situation. It shows files are open from the device, and what has them open, in the same interface an end user would use to eject the drive.

            • prole@lemmy.blahaj.zone
              link
              fedilink
              arrow-up
              1
              ·
              1 day ago

              Maybe it’s just because I’m old and remember DOS, but I just don’t see having to type such simple words into a terminal as complicated. 🤷‍♂️

              • halcyoncmdr@lemmy.world
                link
                fedilink
                English
                arrow-up
                2
                ·
                1 day ago

                It is. And so do I. The terminal isn’t hard, it’s just for the average user, it feels intimidating and/or extremely old and thus inherently bad. They rely on the GUI as the user experience. And to be honest, they’re right. A modern system should not require terminal interaction for every day use cases, or even infrequent use cases. It’s just not a user-friendly interface for a consumer.

                And that doesn’t even get into the youngest generations that have grown up with touchscreens, where many can barely use a mouse. Even those most would probably consider to be more tech-literate, like gamers. PirateSoftware (I know, I know, but it is a real world interaction versus theoretical) brought a demo to one of the conventions, with 2 stations for a game, 1 KB&M and 1 controller. For the few kids that tried to use the KB&M stations, they moved the keyboard out of the way and tried to touch the screen to interact, because they didn’t know how to interact with it like that, they knew how to use a controller and a touchscreen. That was how they played games. Their tablets, and controllers probably on consoles. Youtube Shorts video explaining. That’s the average user. No one anywhere near a place like lemmy is an average user.

    • azertyfun@sh.itjust.works
      link
      fedilink
      arrow-up
      16
      ·
      2 days ago

      Real answer: it depends.

      • Deleting a file in use: no problemo. File is removed from the directory immediately, but exists on disk until last program who had the file open closes. Everyone wins! (Unless you’re trying to free up space by deleting a huge file that’s being held open by a program and not understanding why the filesystem usage didn’t go down)
      • Unmounting a hard drive in use: Will error out similarly to Windows. lsof can tell you which process has which files open. There’s nuance with lazy unmounts and whatnot but that should not be used in most cases.

      Now in practice you should be wary of one very important thing that changes compared to Windows: Writes are asynchronous on Linux. First the kernel writes to RAM, then it flushes to disk at a later time for performance reasons (this is one of the reasons why writing a bunch of small files is many times faster on Linux than Windows). The upshot is that just because your file copy is “done” doesn’t mean you can just yank the USB cable. Always safely unmount before unplugging a storage device on Linux.

      • u/lukmly013 💾 (lemmy.sdf.org)@lemmy.sdf.org
        link
        fedilink
        English
        arrow-up
        9
        ·
        2 days ago

        Writes are asynchronous on Linux.

        Unless I mount it with sync, which I wish would be default for non-system drives (which are going to be in fstab anyway). I didn’t notice any difference, aside from the lack of guessing when the magic is over. 2GiB goes into black hole, now what?

        • azertyfun@sh.itjust.works
          link
          fedilink
          arrow-up
          3
          ·
          1 day ago

          Strongly disagreed. A lot of removable storage benefits very strongly from async writes. The performance benefits are night-and-day and worth the hassle of explicitly unmounting.

          I think a better compromise would be to mount non-journaled + removable storage (e.g. vfat USB keys) as sync.

    • Eiri@lemmy.ca
      link
      fedilink
      arrow-up
      15
      ·
      2 days ago

      Idk how Linux handles it but today on Mac I accidentally sent a folder to trash that was in use by four programs at once.

      Mac OS did not give a shit. It nuked it.

    • BombOmOm@lemmy.world
      link
      fedilink
      English
      arrow-up
      15
      ·
      2 days ago

      Linux Mint has an eject button that allows any cached writes* to finish, prevents new ones from starting, and un-mounts it. It’s actually important to use the eject button as flash drives are slow, and the write cache can obscure the fact that a file isn’t done writing yet.

      *Copying a file will add it into the write cache while it writes out to the disk. As soon as it is in the cache, you can use the file as if it was already done copying, including making changes.

    • Rentlar@lemmy.ca
      link
      fedilink
      arrow-up
      11
      ·
      2 days ago

      Many files copied to an external disk are cached, and not written immediately unless you run the “sync” command.

      So when you press the “eject” icon, on most frontends a notification will tell you not to unplug it right away, once the write is complete it will send a “it is safe to remove the drive” message. This can take a couple minutes if you are writing a big file to a slow drive.

      • halcyoncmdr@lemmy.world
        link
        fedilink
        English
        arrow-up
        7
        ·
        2 days ago

        By default Windows disables file caching on external USB drives. It should be writing those files directly. That doesn’t prevent a program from locking a file or folder that it is using though.

    • marcos@lemmy.world
      link
      fedilink
      arrow-up
      6
      arrow-down
      1
      ·
      2 days ago

      I basically never have this problem on Linux.

      I think programs can’t hold removable media busy by default on Debian. If you remove, you lose whatever changes aren’t there. Either way, Linux programs just read files and close them, they mostly don’t keep files open.