Mounting USB Stick Issue

February 4, 2024, 21:05

seanz25

Hey all, So I’ve followed instructions on mounting a USB drive to my pi, for whatever reason I’m having issues that are hard to explain, effectively as you can see in the screenshot here I’ve mounted the drive to /mnt/usb2. Via file manager I’ve put some files on there, however, Gparted isn’t showing that the used space has gone up at all?

seanz25

I’ve tried to setup auto mounting using fstab, as far as I’m aware this is correct?

seanz25

When I rebooted earlier after setting up the stick also seemed to be wiped of files?

oops.se

Please crop pictures, and post text as text.

seanz25

Okay so there's files inside /mnt/usb2:

seanz25

Here's how I've written the automount in my fstab:

seanz25

Here's the mounts by UUID

oops.se

I asked for text not pictures and there are several reasons for that.

seanz25

omy bad

seanz25

GNU nano 7.2                              /etc/fstab                                       
proc            /proc           proc    defaults          0       0
PARTUUID=73c67cb4-01  /boot/firmware  vfat    defaults          0       2
PARTUUID=73c67cb4-02  /               ext4    defaults,noatime  0       1
UUID=c6ae76eb-aecd-4614-ac89-3df93cf4b832 /mnt/usb2 auto nofail,uid=1000,gid=1000,noatime 0 0
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that 

seanz25

Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/mmcblk0p2  30083620 28157460    635316  98% /

seanz25

seanz25@raspberrypi:~ $ ls -l /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 15 Feb  4 20:55 4aa56689-dcb4-4759-90e6-179beae559ac -> ../../mmcblk0p2
lrwxrwxrwx 1 root root 10 Feb  4 20:55 c6ae76eb-aecd-4614-ac89-3df93cf4b832 -> ../../sda1
lrwxrwxrwx 1 root root 15 Feb  4 20:55 EF6E-C078 -> ../../mmcblk0p1 

oops.se

That is NOT the USB /dev/mmcblk0p2

seanz25

that's what kicks back when I do
df /mnt/usb2

oops.se

Start with lsblkto show block devices

seanz25

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    1 114.6G  0 disk 
└─sda1        8:1    1 114.6G  0 part 
mmcblk0     179:0    0  29.7G  0 disk 
├─mmcblk0p1 179:1    0   512M  0 part /boot/firmware
└─mmcblk0p2 179:2    0  29.2G  0 part /

oops.se

mmcblk0 is your SD card

oops.se

sda is your USB block device

oops.se

The command to find the device id is blkid

seanz25

/dev/mmcblk0p1: LABEL_FATBOOT="bootfs" LABEL="bootfs" UUID="EF6E-C078" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="73c67cb4-01"
/dev/mmcblk0p2: LABEL="rootfs" UUID="4aa56689-dcb4-4759-90e6-179beae559ac" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="73c67cb4-02"
/dev/sda1: LABEL="usbkey" UUID="c6ae76eb-aecd-4614-ac89-3df93cf4b832" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="3f882e5d-5001-485f-a6b9-4b09b3292272" 

seanz25

So from what I followed, I'd set the UUID of the correct USB/Sda1 to auto mount in the
etc/fstab
tab

oops.se

Ok, see that now

oops.se

Then you can run tail -f /var/log/messages

oops.se

And while you connect/disconnect should show you whats happening

oops.se

And the command mount will show you whats mounted

oops.se

And to test if it is the UUID that struggling, replace that with /dev/sda1

oops.se

And to fore a reload or remounting of the /etc/fstab content run mount -a

oops.se

The issue with the command ls -l /dev/disk/by-uuid is that it shows the UUID for the device: But you need to mount the partition on the device and need the PARTUUID. To show that you can use blkid -t TYPE=vfat -sPARTUUID or sudo blkid, the later shows all partitions and PARTUUIDs.

seanz25

running this gave me the following error:
tail: cannot open '/var/log/messages' for reading: No such file or directory
tail: no files remaining

seanz25

ran this and sda isn't showing up anywhere on there in the long list lol

oops.se

You need to use sudo

oops.se

That because I told you earlier that you have mixed UUID and PARTUUID

seanz25

sorry, I appreciate it, this is a learning curve for me.

seanz25

it kicked back the same response

seanz25

So just to clarify, and again I appreciate the patience with me here, I've run
 sudo blkid
That returned:
/dev/sda1: LABEL="usbkey" UUID="c6ae76eb-aecd-4614-ac89-3df93cf4b832" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="3f882e5d-5001-485f-a6b9-4b09b3292272"
So I guess in my
/etc/fstab
I need to use the PARTUUID number here instead? Should it look like this:
PARTUUID=3f882e5d-5001-485f-a6b9-4b09b3292272 /mnt/usb2 auto nofail,uid=1000,gid=1000,noatime 0 0

oops.se

Yes

oops.se

And I think that is confusing as UUID is for the USB storage and you always need at least one partition on it to be able to mount it

oops.se

And all partitions have their own UUID aka PARTUUID

seanz25

it's strange but it makes sense now

seanz25

so I've just updated the fstab, I guess it's a case of restarting the pi?

oops.se

And you confused me by being so sure about your UUID so that made it harder to troubleshoot

oops.se

No

oops.se

You can reread the /etc/fstab with sudo mount -a

seanz25

it's weird, the pi guides online for beginners are generally really good, but for this they seem quite off the mark

oops.se

reread aka remount all from fstab

oops.se

Perhaps I should write one 😉

seanz25

seanz25@raspberrypi:~ $ sudo mount -a
mount: /mnt/usb2: wrong fs type, bad option, bad superblock on /dev/sda1, missing codepage or helper program, or other error.
       dmesg(1) may have more information after failed mount system call.

oops.se

Do you have TYPE="ext4" in fstab?

seanz25

I literally just pasted this in, I'm guessing replace auto with TYPE='ext4' ?
PARTUUID=3f882e5d-5001-485f-a6b9-4b09b3292272 /mnt/usb2 auto nofail,uid=1000,gid=1000,noatime 0 0

oops.se

only etx4 will also work

seanz25

dam still getting the same issue

seanz25

this is how my /etc/fstab tab is looking:
proc            /proc           proc    defaults          0       0
PARTUUID=73c67cb4-01  /boot/firmware  vfat    defaults          0       2
PARTUUID=73c67cb4-02  /               ext4    defaults,noatime  0       1
PARTUUID=3f882e5d-5001-485f-a6b9-4b09b3292272 /mnt/usb2 ext4 nofail,uid=1000,gid=1000,noatime 0 0

seanz25

I ran dsmeg as advised in the error message, it's bringing up this if it's any useful info?
[48443.763384] ext4: Unknown parameter 'uid'
[48472.287851] ext4: Unknown parameter 'uid'
[51773.989963] ext4: Unknown parameter 'uid'
[51793.836406] ext4: Unknown parameter 'uid'

oops.se

This is my /etc/fstaband it works
PARTUUID=447b84b0-01  /mnt/usb1       vfat    defaults          0       0
PARTUUID=040D-366E    /mnt/usb2       vfat    defaults          0       0

oops.se

And you can only use uid/gid with FAT filesystems

seanz25

I know this might be dumb to ask, but is it how the numbers are lined?

oops.se

Read your output from dmesg an my comment above

seanz25

think I got it working!

seanz25

How would I confirm lol

oops.se

write a file to /mnt/usb2

oops.se

unmount usb2

oops.se

ls /mnt/usb2

seanz25

working

seanz25

thanks so much <@796000224690307072>