[Unit]
Description = External USB stick storage
[Mount]
What = LABEL=Verbatim
Where = /mnt/storage
Type = fat
Options = rw,relatime,data=ordered
[Install]
WantedBy = multi-user.target
The folder /mnt/storage is created but when I copy a file to this folder it is not copied to the USB stick. What’s wrong with my setup ? Maybe I cannot use FAT format ?
Hey, you can use the web terminal or resin ssh to go into your container and check the status of that service by systemctl status mnt-storage.mount.
In this case, you had actually 3 issues with that service file:
FAT labels are all uppercase (the error logged by systemd was mount: can't find LABEL=Verbatim, so have to update that
The file system type’s name is not fat, but vfat (the error logged by systemd was mount: unknown filesystem type 'fat'
The options there are from ext4, I think, and not the proper options for vfat. See the available options in this doc (the error logged was mount: wrong fs type, bad option, bad superblock on /dev/sda1)
With all these changes, here’s the working version of your mnt-storage.mount service file:
[Unit]
Description = External USB stick storage
[Mount]
What = LABEL=VERBATIM
Where = /mnt/storage
Type = vfat
Options = rw
[Install]
WantedBy = multi-user.target
The USB might have been corrupted try contacting your USB provider. If that does not work out then look for third party software’s including SysInfoTools Software, Aryson Technologies. They work out fantastically.
I have done the same solution and it works nicely with LABEL=STORAGE and naming different USB sticks to STORAGE
but when I unplug a USB stick and reinsert it I get input output errors.
If i reboot the machine it works nicely again.
This is after I reinserted a USB drive
----snap dmesg output
[314008.563247] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[314008.595727] scsi host6: usb-storage 1-1.2:1.0
[314010.535236] scsi 6:0:0:0: Direct-Access SMI USB DISK 1100 PQ: 0 ANSI: 4
[314010.547511] sd 6:0:0:0: [sda] 31211520 512-byte logical blocks: (16.0 GB/14.9 GiB)
[314010.548022] sd 6:0:0:0: Attached scsi generic sg0 type 0
[314010.548968] sd 6:0:0:0: [sda] Write Protect is off
[314010.549013] sd 6:0:0:0: [sda] Mode Sense: 43 00 00 00
[314010.550391] sd 6:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn’t support DPO or FUA
[314010.562474] sda: sda1
[314010.569243] sd 6:0:0:0: [sda] Attached SCSI removable disk
An ls works nicely so the mount seems to be working
root@88110ad:/usr/src/app# ls /mnt/storage/
Also syctemctl likes it
root@88110ad:/usr/src/app# systemctl status mnt-storage.mount
● mnt-storage.mount - External USB stick storage
Loaded: loaded (/etc/systemd/system/mnt-storage.mount; enabled)
Active: active (mounted) since Fri 2017-08-11 12:07:10 UTC; 1h 9min ago
Where: /mnt/storage
What: /dev/sdb1
Process: 44 ExecMount=/bin/mount -n LABEL=STORAGE /mnt/storage -t vfat -o rw (code=exited, status=0/SUCCESS)
Aug 11 12:07:10 88110ad systemd[1]: Mounted External USB stick storage.
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
@JoachimLindborg, hmm, Input/output errors usually mean a corrupted disk, but as you said you can write to it fine if the usb stick already present at boot? You have tried an alternate usb stick right?
I managed to reproduce this, restarting the service fixes it, so you could have a udev rule to do that as a temporary work around. But it’s probably just a .mount option that we are missing, will try dig into the docs a little more and let you know.
Let me know if you make any progress in the meantime.