0

I'm running Raspbian Lite on an RPi3B+. It's powered with a bench power supply capable of sourcing over 3A. I never see an "under-voltage" warning.

My application requires an USB pen drive always inserted - I mean it's cannot be plugged/unplugged with the system running. The end-user as to shutdown the system before disconnect it. This is by-design and I cannot change this behavior.

Here my /etc/fstab:

proc                    /proc           proc    defaults                    0   0
PARTUUID=7ee80803-01    /boot           vfat    defaults,ro                 0   2
PARTUUID=7ee80803-02    /               ext4    defaults,noatime,ro             0   1
PARTUUID=7ee80803-03    /home           ext4    defaults,noatime                0   2
tmpfs                   /tmp            tmpfs   nosuid,nodev                    0   0
tmpfs                   /var/log        tmpfs   nosuid,nodev                    0   0
tmpfs                   /var/tmp        tmpfs   nosuid,nodev                    0   0
/dev/sda1               /home/pi/extusb vfat    user,rw,umask=111,dmask=000,gid=1000,uid=1000   0   3

but after a couple of reboots during startup the system mounts the pen in read-only:

[    4.560207] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[    4.566705] scsi host0: usb-storage 1-1.2:1.0
[    5.593586] scsi 0:0:0:0: Direct-Access     Generic  Flash Disk       8.07 PQ: 0 ANSI: 4
[    5.597571] sd 0:0:0:0: [sda] 15728640 512-byte logical blocks: (8.05 GB/7.50 GiB)
[    5.598365] sd 0:0:0:0: [sda] Write Protect is off
[    5.598379] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
[    5.599085] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[    5.609056]  sda: sda1
[    5.611895] sd 0:0:0:0: [sda] Attached SCSI removable disk
[    5.612191] sd 0:0:0:0: Attached scsi generic sg0 type 0
[    5.890426] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[   52.418004] FAT-fs (sda1): error, fat_free_clusters: deleting FAT entry beyond EOF
[   52.418019] FAT-fs (sda1): Filesystem has been set read-only

the messages might change, but at the end it mounts in ro mode. To find the cause I did the following tests:

  • changed power supply (even I'm using a good one)
  • changed RPi
  • changed USB pens

I'm wondering if there's something wrong in my approach. Please note the user will cut the power to "shutdown" the system. This is also by-design. For this reason I mount the filesystem / in ro, but as you can see I have my /home partition on the sd-card mounted in rw and I never had a problem in 5-6 years and hundreds of systems out there.

My application writes on both partitions (/home and /home/pi/extusb) rarely. Anyway the issue I'm talking now happens even if I don't write anything to the USB pen. Just reboot few times and the device will corrupt.

  • "I'm wondering if there's something wrong in my approach..." Yes: "the user will cut the power to shutdown the system". This is just a design flaw. Using a ro filesystem will decrease the chances of fs corruption but I do not think it is eliminated. You are still arbitrarily cutting the power to the card and card reader; the "read-only" fs is only an operating system concept; ditto the USB stick. – goldilocks Feb 8 at 14:34
  • @goldilocks I understand, but it's an unattended industrial machine (on/off) I cannot "halt" the system. But why my /home partition never corrupts while the USB one does after 2-3 reboots? – Mark Feb 8 at 15:03
  • Good question, but the point is you've left the door open. It's essentially a sort of undefined behaviour; why what actually happens happens may be interesting curiosity wise but it will still always be gambling. I've killed the power plenty of times and almost never had to deal with corruption. WRT to the machine, if it is being turned off (as oppose to having its power arbitrarily killed), you could incorporate a circuit to trigger a shutdown first... – goldilocks Feb 8 at 15:43
  • ...If that's not possible, I think the Pi is not a good choice here; you want something that's designed to deal with your scenario. It isn't. – goldilocks Feb 8 at 15:43
  • @goldilocks it's supposed to stay alive forever, but in case of power failure it should not fail. As said my solution (without USB) successfully passed hard stress-tests. Even if I change the SBC it doesn't matter: I still must have a USB pen mounted in rw... – Mark Feb 8 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.