Just-partitioned USB flashdrive has an elusive name

9 respostas [Última entrada]
amenex
Desconectado
Joined: 01/03/2015

This is the fourth in a series of 256GB SanDisk flashdrives, the first three of which are auto-mounting
without any problems.
This morning I used GParted for the nth time to partition this flashdrive to the following specifications:
gpt partition and ext4. I named the partition Thumb256D.

Here's what GParted now says ==>
Partition ... Name ........ File System .. Size ..... Used .... Unused
/dev/sdc1 ... Thumb256D ... ext4 ......... 233.25 GiB 3.84 GiB 229.41 GiB

There's one, 36 byte file on it now.

When I insert the drive into a USB port, it's automounted to /dev/sdc1 but the logo usb0 appears on the desktop.
When I subsequently use sudo umount /dev/sdc1, followed by sudo mount /dev/sdc1 /media/george/Thumb256D
and subsequently set the permissions with sudo chown -R $USER:$george Thumb256D, I find that I cannot
eject the flashdrive.

I can only manage unplugging the flashdrive by using sudo umount /dev/sdc1. That's entirely too cumbersome.
When I insert the just-removed flashdrive, its logo appears as usb0 on the Desktop. I can see as well as
open that one 36 Byte file, but the partition name Thumb256D never appears unless I go through the steps
of mounting /dev/sdc1 to /media/george/Thumb256D.

The other three flashdrives automount to /media/george/Thumb256A (or B or C) and respond to the eject button
in the File Manager. What's amiss ?

George Langford

Magic Banana

I am a member!

I am a translator!

Desconectado
Joined: 07/24/2010

sudo chown -R $USER:$george Thumb256D
george is certainly not a defined Shell variable. As a consequence, $george is certainly an empty string. You wanted to execute:
$ sudo chown -R george:george /media/george/Thumb256D
Or (exactly the same, after interpretation by the Shell):
$ sudo chown -R $USER:$USER /media/george/Thumb256D

amenex
Desconectado
Joined: 01/03/2015

Thanks MB for that last piece of advice.

Upon further experimentation I came upon the following "solution":
sudo mount /dev/sdc1 /media/george/Thumb256D
At long last the flashdrive is mounted at /media/george/Thumb256D, and if I apply chown thereafter
I can then read its contents.

Alas, when I try to unmount it with the file manager, I get this ominous reply:
umount: /media/george/Thumb256D: umount failed: Operation not permitted

I thought I could unmount it from the console instead:
sudo umount /media/george/Thumb256D ... Reply: target is busy
In a pinch, I could just make sure that there aren't any ongoing operations and then disconnect it,
but the other three otherwise identical flashdrives present no such obstacles.

I went ahead and disconnected the flashdrive, leaving the now-empty mount point (Thumb256D) sitting
forlornly on the Desktop. Upon re-insertion, the former mountpoint usb0 reappeared on the Desktop,
containing the same files that were on the Thumb256D while it was mounted there.

The file manager won't let me unmount usb0, either, but the console does permit unmounting usb0.

BTW, overnight I added a 100 GB directory to the flashdrive.

Also: The permissions of the 100 GB directory displayed under the Properties tag look oK, but when
I try to look at the permissions for the drive itself ==> "the permissions could not be determined."

Magic Banana

I am a member!

I am a translator!

Desconectado
Joined: 07/24/2010

A file on the drive was certainly opened, by some process, hence the error message.

nadebula.1984
Desconectado
Joined: 05/01/2018

Both mount and umount require privilege elevation. Using udisksctl is better.

To unmount a block device, use the command (unmount, not umount here):

$ udisksctl unmount -b /dev/sdxn

amenex
Desconectado
Joined: 01/03/2015

There's still something wrong.
The current way the automount is handled is to place the flashdrive here: /media/usb0
I accept that, as there's work to be done.

Now I'm faced with a "Permission denied" problem after applying these three steps:
cp Temp10012020C04.txt UsefulScript and sudo chmod +x UsefulScript
followed by ./UsefulScript

Here's a representative line from that script:
awk 'END {print FILENAME"\t"NR}' Domains/RussiaIndex/EC.RU.C11.index.txt >> SS-HN-GLU-BFEH-May2020-IndexOrderTally.txt
All it's doing is counting the number of records (NR) in the target file. I can paste the
entire 137-row set of scripts into the terminal and run them without encountering any problems.

I have previously applied the following command: sudo chown -R $USER:$USER /media/usb0

Note addedon 10/7/2020: It's even worse than I thought:
All the ./...Script execution attempts are getting "Permission denied" responses.

amenex
Desconectado
Joined: 01/03/2015

Here's the situation:
,
Whenever I insert one of the four USB flashdrives (Thumb256A, B , C, or D) the file manager
says that it's unable to mount the device because another device is at that mount point, so
I execute /media sudo umount [that mount point]. Then after several tries I can insert Thumb256A,
which appears on the desktop as /media/usb0. If I execute /media sudo unmount usb0, I can then
unplug it and then plug it in again without complaint from the file manager.

The mount point returned by the file manager is sdc0 or sdc1, not usb0 or usb1, but the minimal
instructions in the /etc/usbmount/usbmount.conf file say that a flashdrive meeting the file
specifications (in my case ext3/ext4) will be mounted at the next unfilled mount point from the
list: MOUNTPOINTS="/media/usb0 /media/usb1 /media/usb2 /media/usb3
/media/usb4 /media/usb5 /media/usb6 /media/usb7"

What I apparently need to control is the order in which the flash drives are recognized in the
list: sdc0, sdc1, sdc2, sdc3

amenex
Desconectado
Joined: 01/03/2015

Progress report:

If I start the 'puter with Thumb2456A and Thumb256B in two of the USB ports, the
system starts normally and the ikons Thumb2456A and Thumb256B appear on the desktop.
Thumb256A opens to /media/usb0 and Thumb256B opens to /media/usb1.

Then I execute sudo unmount usb0 and sudo unmount usb1 and shut down the 'puter.

Not so good with the other two; repeating the exercise and starting the 'puter
with Thumb256C and Thumb256D in their respective USB ports, two ikons appear,
one labelled Thumb256C and the other, 256 GB Volume.

After much poking around, I discovered a rogue mount point, competing with /media/george/Thumb256C,
called /media/george/Thumb256C1 and redacted with a dark green background. That mount point also
was listed when I looked at the flashdrive with GParted.

Then I shut down the 'puter and restarted it again with both Thumb256C and Thumb256D in their
respective USB ports.

On further investigation GParted gives the following results:

/dev/sdc1................................................./dev/sdd1
Label: [none].............................................Thumb256C
UUID: [redacted]..........................................[redacted]
Status: Mounted on /media/usb0............................Mounted on /media/usb1
Name: Thumb256D...........................................[none]

Looks as though I need to undo this mess by giving Thumb256D a proper label; is that still possible ?

The disconnect between the labels that the Desktop ikons display and the actual
names of the mount points reported by the file manager may also be the cause of the
reluctance of the system to honor any ./...Script execution.

Back in the good old days, about a week ago, the flashdrives Thumb256A and Thumb256B always
appeared at /media/george/Thumb256A and /media/george/Thumb256B, but even when I change the
paths that appear in the script to /media/usb0 and /media/usb1 and apply chmod +x all over
again, the execution of such scripts is still blocked.

amenex
Desconectado
Joined: 01/03/2015

Putting my crutches to the side, I can report progress and some clues to the dilemma:

Upon insertion of the flashdrive Thumb256A, file manager responds that another nonexistent) drive
occupies /dev/sdc1; so I unmount /dev/sdc1 and then execute:
sudo mount /dev/sdc1 /media/george/Thumb256A
after which I can initiate a script from the directory wherein it resides:
cd /...WorkingDirectory ./...Script
and file manager does not object.

I checked the permissions of Thumb256A ==> They are as I wish.

After ejecting Thum256A as root and then trying the exercise with Thumb256B as above until:
sudo mount /dev/sdc1 /media/george/Thumb256B
file manager is still accepting my commands, though only as root (i.e., sudo).

Then I repeated the exercise with the mis-named flashdrive Thumb256D, whose ikon appears, not as Thumb256[D]
like the first two, but as "256 GB Volume." Nevertheless, its files are accessible and the permissions are OK.

Lastly, without ejecting Thumb256D, I insert Thumb256C ... file manager remains silent.
I execute:
sudo mount /dev/sdc1 /media/george/Thumb256C
Oops; now there are two mount points with the same files ....
sudo umount /media/george/Thumb256C
sudo mount /dev/sdd1 /media/george/Thumb256C

corrects the musical-chairs issue. And I can execute a script with
cd /...WorkingDirectory ./...Script

Nevertheless, while I can eject Thumb256C as root OK, upon re-insertion, file manager complains:
Device /dev/sdd1 is already mounted at `/media/usb0'
Which suggests that there are competing mount points.

amenex
Desconectado
Joined: 01/03/2015

Problem solved:

"... competing mount points ..." was exactly the problem.

Whenever one of the USB flash drives was inserted, it was getting automounted to one of the
mount points set up (probably by usbmount) at this location:
media/usb, usb0, usb1 ...usb7

After I deleted all but /media/usb and usb0, insertion of one of those flashdrives now
causes it to be automounted to /media/george/Thumb256[A, B, C or D] as appropriate. Except
for Thumb256D, which still hasn't got a proper label. Neverthless, mounting and unmounting
are hassle-free now.

George Langford