Safely removing USB drive from L5

I don’t know if it’s my particular USB drive (Patriot brand), but whenever I want to remove it from the phone, I get the message “Unable to stop drive.” This happens whether or not I’m copying any files at the time.

Eject also doesn’t remove it from the Files menu, although no error is displayed.

I then go to the Disks app, select the drive, and power it off from the settings.

I don’t have another USB-C type drive to test, unfortunately.

I also don’t have any problems removing the drive from my laptop.

2 Likes

Did you try
umount -f /path/to/usb_drive
and
lsof /path/to/usb_drive?

How do I fill this in? (an example)

Should it look like this? sudo umount -f /dev/sdb

This one should work I think, but also path to the folder where it’s mounted should also work. And the second command should AFAIK act on the mounted path.

Example:
sudo -f umount /media/patriot

Hmmm… not mounted, although I see it in Nemo, and I can move files to and from it:

purism@pureos:~$ sudo umount -f /dev/sdb
umount: /dev/sdb: not mounted.
purism@pureos:~$

Can you cd into it in the terminal? If you can, you can use the corresponding path for umount.

I get this error when I first insert the drive:

1 Like

None of the paths I’ve tried can find it.

Aha! Figured it out: /media/purism/PATRIOT

purism@pureos:~$ cd /media/purism/PATRIOT
purism@pureos:/media/purism/PATRIOT$ sudo umount -f /media/purism/PATRIOT
umount: /media/purism/PATRIOT: target is busy.
purism@pureos:/media/purism/PATRIOT$

1 Like

It’s generally a good idea to use sudo umount --recursive -f $PATH, but I doubt something is getting auto-mounted inside the flash drive.
Try the following:

sudo -i
lsof | grep /media/purism/PATRIOT

It should tell you want is using it. Little hint, when you are sitting in the path you want to unmount, $$ (your shell) is using it.
Try cd /media/purism && sudo umount -f /media/purism/PATRIOT

1 Like

Thanks. Will try later.

I wonder if your brand of USB is made in China and it is constantly trying to “phone home” ?

1 Like

Let’s hope not! Lol!

Of course it is busy. You are inside the mount folder (with the bash shell). Just issue a plain

cd

(this will take you to /home/purism) and then

umount /media/purism/PATRIOT

If it insists that it is busy then another app is accessing the folder.
lsof /dev/sdb
should tell you which one it is. You first exit that app and then umount.

3 Likes

Thanks. I’m glad I have all you guys to straighten me out! :stuck_out_tongue_winking_eye:
Just tested again:

  1. Insert USB.
  2. Copy a file to USB.
  3. Select “Safely remove drive”.
  4. Get “Unable to stop drive” error.
  5. ssh to L5 from laptop.
  6. Apply command:

purism@pureos:~$ umount /media/purism/PATRIOT
purism@pureos:~$

  1. USB drive still appears in Files as if mounted, as well as in Disks. (Maybe the L5 simply exhibits different behavior from other computers?)

So am I safe just yanking the thing out after the umount?

1 Like

@amarok, let us learn from each other. This was wrong:
pureos:~$ sudo umount -f /dev/sdb
Correct:
pureos:~$ sudo fdisk -l
pureos:~$ umount /dev/sdb1

pureos:~$ cd /media/purism
pureos:~$ ls -la
Correct:
pureos:~$ umount /media/purism/PATRIOT

@antonis, this is correct (I’ve learned something):
pureos:~$ lsof /dev/sdb1
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME … evince …
pureos:~$ umount /dev/sdb1
Error unmounting block device … DeviceBusy: Error unmounting /dev/sdb1: target is busy
I’ve closed opened Evince file.
pureos:~$ lsof /dev/sdb1
pureos:~$ umount /dev/sdb1
Done!

Is /dev/sdb1 an ext4 partition?

FAT (32-bit vesion)

This definitely unmounts it, as seen in the Disks app, so that’s good to know. It stays in the menu, however, and when I select it in the Files app, a notification pops down and says it’s now ready to open.

Selecting Safely remove drive gets the Unable to stop drive message. Back to Disks, where it shows as mounted again.

So looks like I have to issue the command every time (at least with this drive).

1 Like

Yes, Files app will mount USB Drive again (by selecting it). Make sure you are at Home Folder or close Files app. And check this with umount /dev/sdb1 again.

P.S. I’d format this USB drive on Librem 5 itself to ext4.

Yes

Yes, I had done this. I also closed and reopened Disks again after that, and it still showed as mounted. When I run the command, it unmounts it, no problem.

I will reformat the USB at some point. Then I’ll report back to say whether that corrected the behavior.
Thanks for all the tips!

1 Like

I just noticed that Eject (in the Files app) actually unmounted the drive, so… maybe I don’t need to do it in the terminal. I’ll continue to check it in the meantime.

2 Likes