Safe USB stick ejection

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
cliffcoggin
Level 8
Level 8
Posts: 2297
Joined: Sat Sep 17, 2016 6:40 pm
Location: England

Safe USB stick ejection

Post by cliffcoggin »

Greetings.

Over the years I have been caught out several times pulling out USB sticks too early and corrupting the data. When I remember I now use the sync command to ensure data transfer is complete, but the trouble is that I don't always remember. Is there a way to automatically generate some sort of confirmation message that it is safe to unplug the USB stick without having to open and use a terminal? Ideally I want to click on Eject then wait for the message on screen.

Code: Select all

[code]
System:    Kernel: 5.4.0-131-generic x86_64 bits: 64 compiler: gcc v: 9.4.0 
           Desktop: Cinnamon 5.2.7 wm: muffin dm: LightDM Distro: Linux Mint 20.3 Una 
           base: Ubuntu 20.04 focal 
Machine:   Type: Desktop System: Gigabyte product: A320M-S2H V2 v: N/A serial: <filter> 
           Mobo: Gigabyte model: A320M-S2H V2-CF v: x.x serial: <filter> 
           UEFI [Legacy]: American Megatrends v: F51 date: 08/03/2020 
Battery:   Device-1: hidpp_battery_0 model: Logitech Wireless Keyboard serial: <filter> 
           charge: 55% (should be ignored) status: Discharging 
CPU:       Topology: Quad Core model: AMD Athlon X4 950 bits: 64 type: MCP arch: Excavator rev: 1 
           L2 cache: 1024 KiB 
           flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm bogomips: 27948 
           Speed: 1718 MHz min/max: 1400/3500 MHz Core speeds (MHz): 1: 2770 2: 3712 3: 2106 
           4: 3751 
Graphics:  Device-1: NVIDIA GT218 [GeForce 210] vendor: ASUSTeK driver: nouveau v: kernel 
           bus ID: 09:00.0 chip ID: 10de:0a65 
           Display: x11 server: X.Org 1.20.13 driver: modesetting unloaded: fbdev,vesa 
           resolution: 1920x1080~60Hz 
           OpenGL: renderer: NVA8 v: 3.3 Mesa 21.2.6 direct render: Yes 
Audio:     Device-1: AMD Family 15h Audio vendor: Gigabyte driver: snd_hda_intel v: kernel 
           bus ID: 00:09.2 chip ID: 1022:157a 
           Device-2: NVIDIA High Definition Audio vendor: ASUSTeK driver: snd_hda_intel v: kernel 
           bus ID: 09:00.1 chip ID: 10de:0be3 
           Sound Server: ALSA v: k5.4.0-131-generic 
Network:   Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet vendor: Gigabyte 
           driver: r8169 v: kernel port: e000 bus ID: 08:00.0 chip ID: 10ec:8168 
           IF: enp8s0 state: up speed: 1000 Mbps duplex: full mac: <filter> 
Drives:    Local Storage: total: 670.70 GiB used: 77.10 GiB (11.5%) 
           ID-1: /dev/sda vendor: Kingston model: SA400S37240G size: 223.57 GiB speed: 6.0 Gb/s 
           serial: <filter> 
           ID-2: /dev/sdb vendor: Kingston model: SA400S37480G size: 447.13 GiB speed: 6.0 Gb/s 
           serial: <filter> 
Partition: ID-1: / size: 27.33 GiB used: 11.99 GiB (43.9%) fs: ext4 dev: /dev/sdb1 
           ID-2: /home size: 407.78 GiB used: 65.11 GiB (16.0%) fs: ext4 dev: /dev/sdb3 
           ID-3: swap-1 size: 3.82 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sdb2 
USB:       Hub: 1-0:1 info: Full speed (or root) Hub ports: 2 rev: 2.0 chip ID: 1d6b:0002 
           Hub: 1-1:2 info: Advanced Micro Devices Root Hub ports: 4 rev: 2.0 chip ID: 0438:7900 
           Hub: 2-0:1 info: Full speed (or root) Hub ports: 4 rev: 2.0 chip ID: 1d6b:0002 
           Device-1: 2-3:2 info: Prolific PL2303 Serial Port type: <vendor specific> 
           driver: pl2303 rev: 1.1 chip ID: 067b:2303 
           Device-2: 2-4:3 info: Logitech Unifying Receiver type: Keyboard,Mouse 
           driver: logitech-djreceiver,usbhid rev: 2.0 chip ID: 046d:c534 
           Hub: 3-0:1 info: Full speed (or root) Hub ports: 4 rev: 3.0 chip ID: 1d6b:0003 
           Hub: 4-0:1 info: Full speed (or root) Hub ports: 10 rev: 2.0 chip ID: 1d6b:0002 
           Hub: 5-0:1 info: Full speed (or root) Hub ports: 4 rev: 3.1 chip ID: 1d6b:0003 
           Hub: 6-0:1 info: Full speed (or root) Hub ports: 4 rev: 2.0 chip ID: 1d6b:0002 
           Hub: 7-0:1 info: Full speed (or root) Hub ports: 4 rev: 3.0 chip ID: 1d6b:0003 
Sensors:   System Temperatures: cpu: 30.6 C mobo: N/A gpu: nouveau temp: 47 C 
           Fan Speeds (RPM): N/A 
Repos:     No active apt repos in: /etc/apt/sources.list 
           Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list 
           1: deb https: //mirror.cov.ukservers.com/linuxmint una main upstream import backport
           2: deb http: //archive.ubuntu.com/ubuntu focal main restricted universe multiverse
           3: deb http: //archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
           4: deb http: //archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
           5: deb http: //security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
           6: deb http: //archive.canonical.com/ubuntu/ focal partner
Info:      Processes: 213 Uptime: 1h 09m Memory: 7.28 GiB used: 1.21 GiB (16.6%) Init: systemd 
           v: 245 runlevel: 5 Compilers: gcc: 9.4.0 alt: 9 Client: Unknown python3.8 client 
           inxi: 3.0.38 
[/code]
Last edited by LockBot on Mon May 15, 2023 10:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Cliff Coggin
User avatar
Jo-con-Ël
Level 11
Level 11
Posts: 3598
Joined: Sun Jun 20, 2021 12:41 pm
Location: donde habita el olvido

Re: Safe USB stick ejection

Post by Jo-con-Ël »

cliffcoggin wrote: Tue Nov 15, 2022 6:21 am Is there a way to automatically generate some sort of confirmation message that it is safe to unplug the USB stick without having to open and use a terminal? Ideally I want to click on Eject then wait for the message on screen.
You would automatically receive a warning when it is not possible to eject /safely remove USB (as when it is mouted and there is a Nemo window showing contents and need to be closed or another process is working on that device), You will receve a notification that you can unplug USB when it has been ejected/removed from file browser (nemo) w/o problems.

I do not receive that notification when ejecting/removing with right-click on device shortcut on Desktop on LM 20.3 una Cinnamon.

In any case, be sure Notifications are enabled on Menu>Preferences> Notifications and you have Notification applet installed on panel (Menu>Preferences>Applets>Notifications).

Also there would be a removable-drive applet you can install on panel to eject USB drive easily.
Screenshot_2022-11-15_14-25-12.png
Screenshot_2022-11-15_14-25-12.png (15.72 KiB) Viewed 1638 times
Ejecting USB with that applet I always receive notifications.
Screenshot_2022-11-15_18-02-43.png
Screenshot_2022-11-15_18-02-43.png (20.51 KiB) Viewed 1629 times
In other hand after ejecting/safely removing USB you can run Disks (Menu>Accessories>Disks) and power off that USB drive before unplugging. Select USB on the left and click on power icon on the top right. I think that is the most safety way to do it (eject/safely remove>power off>unplug).
Screenshot_2022-11-15_17-30-34.png
On LM 21 you can also eject USB from Disks (gnome-disk-utility 42.0).
Arrieritos semos y en el camino nos encontraremos.
cliffcoggin
Level 8
Level 8
Posts: 2297
Joined: Sat Sep 17, 2016 6:40 pm
Location: England

Re: Safe USB stick ejection

Post by cliffcoggin »

I do have the applet you mentioned installed and notifications enabled, and have had since Mint 18. While I accept that I can eject using the File Manager, I was hoping to get the safe notification by right clicking the desktop icon. From what you wrote it seems to be impossible, which is a shame. Thanks anyway.
Cliff Coggin
Locked

Return to “Storage”