0

I'm developing a small "kiosk" app, running on Debian10 on a BeagleBone Black board, which has one single USB port. I've wrote a line in the fstab file that auto-mount /dev/sda1 in /media/usb, and my app "polls" that last directory to see if there's a stick, and then data to be read or written.

I stumbled in an USB stick that wasn't auto-mounted, but plugging it in a Windows PC shows that there's valid data in it. So i started to look at what was the problem and now i'm super-confused. This is the summary:

  • On the BBB the USB drives is seen as /dev/sda but there's not a partition sda1
  • if plugged in a Debian10 PC with GNome it will be auto-mounted and seen as a normal drive
  • Windows disk manager sees it as a completely normal drive
  • The owner told me that the USB stick was formatted on a Windows 10 PC by answering "Yes" to a popup saying that the drive was unreadable and needed to be formatted (so, not using the usual "Format" dialog)

So i tried to look at it from Debian, and this is what i got:

fdisk -l /dev/sdb

Disk /dev/sdb: 14,7 GiB, 15728640000 bytes, 30720000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0dff6f63

Dispositivo Avvio Start Fine Settori Size Id Tipo /dev/sdb1 1635000430 2179175648 544175219 259,5G 72 sconosciuto /dev/sdb2 1918986614 1919645402 658789 321,7M 72 sconosciuto /dev/sdb4 28049408 28049850 443 221,5K 0 Vuoto

Partition table entries are not in disk order.

lsblk /dev/sdb -fs

NAME FSTYPE LABEL    UUID                                 MOUNTPOINT
sdb  vfat   ONLY SDA E2CF-E64D                            /media/fc/ONLY SDA

lsblk /dev/sdb -O

NAME KNAME MAJ:MIN FSTYPE MOUNTPOINT         LABEL    UUID                                 PARTTYPE PARTLABEL PARTUUID PARTFLAGS  RA RO RM HOTPLUG MODEL            SERIAL            SIZE STATE   OWNER GROUP MODE       ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE TYPE DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO WSAME WWN RAND PKNAME HCTL       TRAN SUBSYSTEMS          REV VENDOR
sdb  sdb     8:16  vfat   /media/fc/ONLY SDA ONLY SDA E2CF-E64D                                                                  128  0  1       1 USB Flash Drive  54136B750AFD1FBC 14,7G running root  disk  brw-rw----         0    512      0     512     512    1 cfq       128 disk        0        0B       0B         0    0B        1        2:0:0:0    usb  block:scsi:usb:pci 2.00 Lexar   

parted /dev/sdb print

Model: Lexar USB Flash Drive (scsi)
Disk /dev/sdb: 15,7GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number Start End Size File system Flags 1 0,00B 15,7GB 15,7GB fat32

sudo file -s /dev/sdb

/dev/sdb: DOS/MBR boot sector, code offset 0x58+2, OEM-ID "MSDOS5.0", sectors/cluster 16, reserved sectors 2798, Media descriptor 0xf8, sectors/track 63, heads 255, sectors 30720000 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 14985, reserved 0x1, serial number 0xe2cfe64d, unlabeled

(on a Debian 10 PC)

mount /dev/sdb

/dev/sdb on /media/fc/ONLY SDA type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

The question

how could i auto-mount an USB drive like this?

My understanding is that I should mount partitions (like sda1) first ('cause i can write "over" them if i mount and write sda), and then "superfloppies" only if don't found a partition (but should i check if there's a filesystem in it?) How to make this logic working in automatic?

(i would look into the Debian PC but i'm too noob to know what to look)

If, while giving an answer, someone could teach me what's happening here, it would be a good learning (and also if i SHOULD treat a drive like this as a valid one as my Debian PC seems to do)

Parduz
  • 113

0 Answers0