Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #286464

Re: Making shutdowns safer for external drives

From "Alexander V. Makartsev" <avbetev@gmail.com>
Newsgroups linux.debian.user
Subject Re: Making shutdowns safer for external drives
Date 2026-04-30 23:40 +0200
Message-ID <MPHgZ-1CeN-5@gated-at.bofh.it> (permalink)
References <MPFoR-1AYP-1@gated-at.bofh.it> <MPGbf-1Byw-1@gated-at.bofh.it> <MPGkW-1BC6-39@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 5/1/26 01:34, debian-user@howorth.org.uk wrote:
> "Alexander V. Makartsev"<avbetev@gmail.com> wrote:
>> On 5/1/26 00:30,coffeeforblood.pardon117@slmail.me wrote:
>>> I have some USB-attached HDDs connected to a laptop running Debian
>>> 12. Recently I had a problem ejecting them using the file manager
>>> and the Disks app, something on the drives was still "in use" even
>>> when I had closed every open application.
>>>
>>> Since then I've learned of the existence of 'lsof', but at the time
>>> my experience of Windows and macOS suggested that, under these
>>> kinds of circumstances, performing a shutdown will clear the holds
>>> on the drives and cleanly eject them during the process. So as I
>>> didn't know what else to do I shut down Debian using the menu.
>>>
>>> The last thing I saw before the laptop powered off was a series of
>>> messages reporting that both external drives had failed to unmount
>>> cleanly, and this was confirmed by the nasty clunking noise from
>>> the drives indicating sudden parking of the drive heads when the
>>> USB power was unexpectedly removed. Following this incident I've
>>> had to recover some several GBs of files from each drive.
>>>
>>> Obviously this wasn't a very pleasant experience, so I'd like to
>>> know what steps I can take to make Debian act more responsibly in
>>> future.
>>>
>>> IM(H)O part of the problem was that the first thing to get torn
>>> down during the shutdown was the GUI, which meant that there was no
>>> way for a user to intervene if there was a problem with ejecting
>>> the drives cleanly. Windows and macOS will prompt the user using
>>> the GUI if there's a problem that means a drive can't be
>>> automatically ejected cleanly during a shutdown, giving users an
>>> opportunity to abort. Can I modify the Debian shutdown sequence to
>>> keep the GUI available until all drives are safely ejected?
>>>
>>> I'd welcome any other suggestions to make Debian less likely to
>>> cause data loss on external drives during shutdown.
>> It is a good habit to issue "sync" command, before disconnecting any
>> USB storage devices.
>> Some storage devices have very slow write speeds, so you have to wait
>> for the "sync" command to finish syncing cached writes.
>> When it finishes you can run it again, just to be sure it worked and
>> it should finish in an instant.
>> Now you can safely unmount and then physically disconnect USB storage
>> devices.
> Why doesn't the OS run synce twice on every storage device when it's
> shutting down?
I'm guessing "umount" command is just as good to safely unmount 
filesystems during shutdown, but the actual process (systemd units?) 
that does it could be getting interrupted by timeout.
IIRC 1 minute 30 seconds is the default timeout for systemd units.
If a slow USB storage device has a few gigabytes of cached writes it 
won't make it in time.
SATA\M.2 connected storage devices are not affected because they are 
many times faster and the connection is more robust.
I've never actually tested this and never tried to shutdown a PC with a 
few terabytes of pending writes to the root filesystem.
Like I said, I have a good habit to type "sync" whenever I need to flush 
all cached writes to all storage devices and it never failed me.

As an additional thought, there could be something wrong with the OP's 
HDD drive, like bad\remapped sectors, or any other issue, making its 
write speed even slower.

-- 

  With kindest regards, Alexander.

  Debian - The universal operating system
  https://www.debian.org

Back to linux.debian.user | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Making shutdowns safer for external drives coffeeforblood.pardon117@slmail.me - 2026-04-30 21:40 +0200
  Re: Making shutdowns safer for external drives "Alexander V. Makartsev" <avbetev@gmail.com> - 2026-04-30 22:30 +0200
    Re: Making shutdowns safer for external drives debian-user@howorth.org.uk - 2026-04-30 22:40 +0200
      Re: Making shutdowns safer for external drives "Alexander V. Makartsev" <avbetev@gmail.com> - 2026-04-30 23:40 +0200
        Re: Making shutdowns safer for external drives Charles Curley <charlescurley@charlescurley.com> - 2026-05-01 00:00 +0200
          Re: Making shutdowns safer for external drives Jan Claeys <lists@janc.be> - 2026-05-02 15:30 +0200
        Re: Making shutdowns safer for external drives Dan Ritter <dsr@randomstring.org> - 2026-05-01 15:10 +0200
    Re: Making shutdowns safer for external drives <tomas@tuxteam.de> - 2026-05-01 08:30 +0200
  Re: Making shutdowns safer for external drives Stefan Monnier <monnier@iro.umontreal.ca> - 2026-05-01 04:50 +0200
    Re: Making shutdowns safer for external drives ghe2001 <ghe2001@protonmail.com> - 2026-05-01 05:40 +0200
      Re: Making shutdowns safer for external drives Charles Curley <charlescurley@charlescurley.com> - 2026-05-01 07:20 +0200

csiph-web