File manager not reporting correctly when finished when writing to USB memory stick

Halvor Raknes

Member
Joined
Apr 19, 2021
Messages
143
Reaction score
15
Credits
1,123
Is there an app that will tell me when copying to a USB memory stick has finished. If I remove the memory stick once Caja notifies me that File operations have finished, I will experience that the file transfers have been truncated. One of my memory sticks has a light that shows when there is data transfer in progress, and it will keep on flickering for several minutes after the Caja file operations pop-up window has closed at the same time that the system notifies me that file operations have finished. But not all memory sticks have such an internal indicator.

Or better still, are there other file managers that will inform correctly on data transfers to memory sticks?

Additional information:

I have gotten the advice to run this command: sudo hdparm -W0 /dev/sdX to disable write cache when writing to the USB memory stick. However, when I ran this I got the following output:
Code:
$ sudo hdparm -W0 /dev/sda

/dev/sda:
 setting drive write-caching to 0 (off)
SG_IO: bad/missing sense data, sb[]:  f0 00 05 00 00 00 00 14 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]:  f0 00 05 00 00 00 00 14 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]:  f0 00 05 00 00 00 00 14 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 write-caching = not supported

I was then adviced that some memory sticks do not allow write caching to be turned off, which I find strange. Surely, the host controller can abstain from employing write cache when writing to sda independent of whether or not write cache can be disabled in the memory stick?

System information:

Code:
System:
  Kernel: 5.15.0-107-generic x86_64 bits: 64 compiler: gcc v: 11.4.0 Desktop: MATE 1.26.0
    wm: marco dm: LightDM Distro: Linux Mint 21 Vanessa base: Ubuntu 22.04 jammy
Machine:
  Type: Laptop System: HUAWEI product: NBLK-WAX9X v: M1010 serial: <superuser required>
  Mobo: HUAWEI model: NBLK-WAX9X-PCB v: M1010 serial: <superuser required> UEFI: HUAWEI v: 1.05
    date: 12/04/2019
Battery:
  ID-1: BAT1 charge: 49.6 Wh (100.0%) condition: 49.6/55.3 Wh (89.6%) volts: 17.2 min: 15.3
    model: Sunwoda-H HB4692Z9ECW-41 serial: <filter> status: Full
CPU:
  Info: quad core model: AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx bits: 64 type: MT MCP
    arch: Zen/Zen+ note: check rev: 1 cache: L1: 384 KiB L2: 2 MiB L3: 4 MiB
  Speed (MHz): avg: 2433 high: 3359 min/max: 1400/2100 boost: enabled cores: 1: 3342 2: 2476
    3: 1815 4: 1804 5: 3359 6: 3338 7: 1547 8: 1790 bogomips: 33538
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
Graphics:
  Device-1: AMD Picasso/Raven 2 [Radeon Vega Series / Radeon Mobile Series] vendor: Huawei
    driver: amdgpu v: kernel pcie: speed: 8 GT/s lanes: 16 ports: active: eDP-1
    empty: DP-1,DP-2,HDMI-A-1 bus-ID: 03:00.0 chip-ID: 1002:15d8
  Device-2: IMC Networks ov9734_azurewave_camera type: USB driver: uvcvideo bus-ID: 1-4:2
    chip-ID: 13d3:56db
  Display: x11 server: X.Org v: 1.21.1.4 compositor: marco v: 1.26.0 driver: X:
    loaded: amdgpu,ati unloaded: fbdev,modesetting,vesa gpu: amdgpu display-ID: :0 screens: 1
  Screen-1: 0 s-res: 1920x1080 s-dpi: 96
  Monitor-1: eDP res: 1920x1080 dpi: 158 diag: 354mm (13.9")
  OpenGL: renderer: AMD Radeon Vega 8 Graphics (raven LLVM 15.0.7 DRM 3.42 5.15.0-107-generic)
    v: 4.6 Mesa 23.2.1-1ubuntu3.1~22.04.2 direct render: Yes
Audio:
  Device-1: AMD Raven/Raven2/Fenghuang HDMI/DP Audio vendor: Huawei driver: snd_hda_intel
    v: kernel pcie: speed: 8 GT/s lanes: 16 bus-ID: 03:00.1 chip-ID: 1002:15de
  Device-2: AMD Raven/Raven2/FireFlight/Renoir Audio Processor vendor: Huawei
    driver: snd_pci_acp3x v: kernel pcie: speed: 8 GT/s lanes: 16 bus-ID: 03:00.5 chip-ID: 1022:15e2
  Device-3: AMD Family 17h HD Audio vendor: Huawei driver: snd_hda_intel v: kernel pcie:
    speed: 8 GT/s lanes: 16 bus-ID: 03:00.6 chip-ID: 1022:15e3
  Sound Server-1: ALSA v: k5.15.0-107-generic running: yes
  Sound Server-2: PulseAudio v: 15.99.1 running: yes
  Sound Server-3: PipeWire v: 0.3.48 running: yes
Network:
  Device-1: Realtek RTL8822CE 802.11ac PCIe Wireless Network Adapter vendor: & Tele RSH
    driver: rtw_8822ce v: N/A pcie: speed: 2.5 GT/s lanes: 1 port: 2000 bus-ID: 02:00.0
    chip-ID: 10ec:c822
  IF: wlp2s0 state: up mac: <filter>
Bluetooth:
  Device-1: Realtek Bluetooth Radio type: USB driver: btusb v: 0.8 bus-ID: 3-2:3
    chip-ID: 1358:c123
  Report: hciconfig ID: hci0 rfk-id: 0 state: down bt-service: enabled,running rfk-block:
    hardware: no software: yes address: <filter>
Drives:
  Local Storage: total: 506.76 GiB used: 407.06 GiB (80.3%)
  ID-1: /dev/nvme0n1 vendor: Samsung model: MZVLB512HAJQ-00000 size: 476.94 GiB speed: 31.6 Gb/s
    lanes: 4 serial: <filter> temp: 48.9 C
  ID-2: /dev/sda type: USB vendor: SanDisk model: Cruzer Glide size: 29.82 GiB serial: <filter>
Partition:
  ID-1: / size: 467.89 GiB used: 406.43 GiB (86.9%) fs: ext4 dev: /dev/nvme0n1p2
  ID-2: /boot/efi size: 511 MiB used: 6.1 MiB (1.2%) fs: vfat dev: /dev/nvme0n1p1
Swap:
  ID-1: swap-1 type: file size: 2 GiB used: 455.2 MiB (22.2%) priority: -2 file: /swapfile
USB:
  Hub-1: 1-0:1 info: Hi-speed hub with single TT ports: 4 rev: 2.0 speed: 480 Mb/s
    chip-ID: 1d6b:0002
  Device-1: 1-2:3 info: SanDisk Cruzer Glide type: Mass Storage driver: usb-storage rev: 2.0
    speed: 480 Mb/s chip-ID: 0781:5575
  Device-2: 1-4:2 info: IMC Networks ov9734_azurewave_camera type: Video driver: uvcvideo
    rev: 2.0 speed: 480 Mb/s chip-ID: 13d3:56db
  Hub-2: 2-0:1 info: Super-speed hub ports: 4 rev: 3.1 speed: 10 Gb/s chip-ID: 1d6b:0003
  Hub-3: 3-0:1 info: Hi-speed hub with single TT ports: 2 rev: 2.0 speed: 480 Mb/s
    chip-ID: 1d6b:0002
  Device-1: 3-1:2 info: Shenzhen Goodix Fingerprint Device type: Communication,CDC-Data
    driver: N/A rev: 2.0 speed: 12 Mb/s chip-ID: 27c6:5110
  Device-2: 3-2:3 info: Realtek Bluetooth Radio type: Bluetooth driver: btusb rev: 1.0
    speed: 12 Mb/s chip-ID: 1358:c123
  Hub-4: 4-0:1 info: Super-speed hub ports: 1 rev: 3.1 speed: 10 Gb/s chip-ID: 1d6b:0003
Sensors:
  System Temperatures: cpu: N/A mobo: N/A gpu: amdgpu temp: 78.0 C
  Fan Speeds (RPM): N/A
Repos:
  Packages: 2834 apt: 2812 flatpak: 22
  No active apt repos in: /etc/apt/sources.list
  Active apt repos in: /etc/apt/sources.list.d/brave-browser-release.list
    1: deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg arch=amd64] https: //brave-browser-apt-release.s3.brave.com/ stable main
  Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list
    1: deb https: //mirror.wtnet.de/linuxmint vanessa main upstream import backport
    2: deb http: //mirror.yandex.ru/ubuntu jammy main restricted universe multiverse
    3: deb http: //mirror.yandex.ru/ubuntu jammy-updates main restricted universe multiverse
    4: deb http: //mirror.yandex.ru/ubuntu jammy-backports main restricted universe multiverse
    5: deb http: //security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
  Active apt repos in: /etc/apt/sources.list.d/spotify.list
    1: deb http: //repository.spotify.com stable non-free
  Active apt repos in: /etc/apt/sources.list.d/tatokis-alarm-clock-applet-jammy.list
    1: deb http: //ppa.launchpad.net/tatokis/alarm-clock-applet/ubuntu jammy main
Info:
  Processes: 311 Uptime: 3h 25m Memory: 6.7 GiB used: 3.05 GiB (45.5%) Init: systemd v: 249
  runlevel: 5 Compilers: gcc: 11.4.0 alt: 11/12 Client: Unknown python3.10 client inxi: 3.3.13
 
Last edited:


@Halvor Raknes asked:
Is there an app that will tell me when copying to a USB memory stick has finished.
To check whether writing to a usb has completed, one can run the command: sync in a terminal.

The sync command synchronises the cached data with what is written to persistent storage. If writing to the usb has not been completed, the sync command in the terminal will hold itself open and not provide the next shell prompt until all is synchronised. When done, the shell returns the prompt. Then the usb needs to be unmounted, and can be safely removed. The unmounting itself may in some circumstances enforce the synching, in which case the sync command may be unnecessary, but it's a simple matter to check by running it.
 
one can run the command: sync in a terminal.

That's usually what I do, if you're using a GUI to copy files, there is usually a "remove safely" button or something similar.
That will force the buffer to write to the disk before you remove it.

If I mounted the disk from the command line, then obviously I know where I mounted it.
So, I sometimes try to do a "umount" and it will tell me the device is busy.

So, after the sync command, I just sit there are keep pressing the up arrow over and over again ( umount /dev/sda )
until it stops saying the disk is busy, and eventually un-mounts the disk.

Whenever I shutdown the or reboot the computer, I almost always do a "sync; reboot" or "sync; shutdown".

I've read plenty of documentation and articles that says the kernel will write the buffer to disk before it shuts down.
But I've tested this, and it doesn't always work for me that way.

Nvidia kmod driver updates are notorious for not completely rebuilding before the system reboots.
 

Members online


Top