Web lists-archives.com

Re: pmount could perhaps be of greater utility?

On Sun 12 May 2019 at 23:35:11 (+1000), Erik Christiansen wrote:
> On 12.05.19 13:45, Eric S Fraga wrote:
> > On Sunday, 12 May 2019 at 17:52, Erik Christiansen wrote:
> > > On 11.05.19 14:38, Eric S Fraga wrote:
> > >> This is nice; is there an equivalent for FAT file systems?  Most of the
> > >> devices I mount using pmount are sd cards (cameras etc.).
> > >
> > > Pmount is just a wrapper around the standard mount program, and that
> > > will try to guess the fs type if not specified in the invocation - as
> > > above. That manages ext2 and ext3 without assistance, but ... Ah, yes,
> > > with a vfat stick it gives:
> > 
> > Sorry, I should have been more explicit.  I use pmount all the
> > time.  Works fine.  What I was looking for was an equivalent of e2label
> > for vfat, if that even makes any sense.
> Dunno how much sense can be found here, as dosfslabel doesn't do it,

Perhaps you're looking at, or for, the wrong item. dosfslabel
(aka fatlabel) should do exactly what e2label does:

# fatlabel /dev/sdb1
China 1
# dosfslabel /dev/sdb1
China 1
# findfs LABEL='CHINA 1'
# findfs UUID=F8FA-4A08

so it looks as though you were confusing the UUID with the LABEL.

However, on my system e2label and dosfslabel are not user commands,
and also are fs-specific, so I have functions defined for what I make
use of, like:

$ type fslabel
fslabel is a function
fslabel ()
    lsblk -o NAME,LABEL -l | sed -e "/^$1 /!d;s/^[^ ]\+[ ]\+//;"

(and ditto for UUID and FSTYPE).

I don't use pmount myself, but I installed it just to try it out.

$ ls -ld /media/C*
ls: cannot access '/media/C*': No such file or directory
$ pmount /dev/sdb1 "$(fslabel $(basename /dev/sdb1))"
$ ls -ld /media/C*
drwx------ 11 foo foo 16384 Dec 31  1969 /media/China 1

That seemed to work fine and could be wrapped in your lmount function.

> but
> this gives the appearance of doing it for me:
> $ blkid | awk --field-separator '"' '/sdb1/ { print $2 }'
> 4DAB-09E3

/dev/sdb10 would match too, wouldn't it? (My bash function above
has a space after the $1.)

> from blkid's line:
> /dev/sdb1: UUID="4DAB-09E3" TYPE="vfat"

For me, blkid is not a user command either, hence my using lsblk.

$ /sbin/blkid

> As it replicates the automounter's behaviour, and that uses the label
> for ext[23] sticks, I'm happy to take that UUID as the label, since I
> have nothing else to go on. (Never had a winderz box in 30 years in IT,
> or the 11 years since.)

LABELs give you IIRC 11 characters rather than the eight hex digits
of the UUID. Of course, if you're using LABELs to name mount points,
it pays to be a bit more circumspect than I was above. I added the
space etc here just for the proof of concept; they're normally a-z0-9