rootfs contains a file system with errors (how to avoid and replicate?)

Hi, this is my System

file system: ext4
eeprom:[A335BNLTGW1ABBGW16050761]
model:[TI_AM335x_BeagleBone_Green_Wireless]
dogtag:[BeagleBoard.org Debian Image 2018-02-01]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2018.01-00002-g9aa111a004]:[location: dd MBR]
kernel:[4.9.88-ti-r109]

I have several beaglebones working with my python script.

From time to time I need to fix the file system at boot with:

fsck /dev/mmcblk1p1

Now I found this and I’ll set all beaglebones with FSCKFIX=yes
http://xmodulo.com/automatic-filesystem-checks-repair-linux.html

Three question:

  1. Why this happen?
    Think this is caused by improper shutdown, here are logs from 3 machines that fail
    https://pastebin.com/4aE6QJCi
    https://pastebin.com/2PMmQGy1
    https://pastebin.com/zRAzfjQU

  2. how to avoid this?
    write files less frequently?, change file system options?

  3. how to replicate this to test?
    Already try this and it’s not working

dd if=/dev/urandom of=yourfile.z bs=1024 seek=$((random%10)) count=1 conv=notrunc
dd if=/dev/zero bs=1 count=10 of=/dev/sda1 seek=10000

thanks!

Sebastián

On Wed, 30 May 2018 07:42:26 -0700 (PDT), Sebastián Sáez
<otrab86@gmail.com> declaimed the following:

1) Why this happen?
Think this is caused by improper shutdown, here are logs from 3 machines

2) how to avoid this?
write files less frequently?, change file system options?

  Never just pull the power -- always issue a SHUTDOWN command and WAIT
for the LEDs to go out.

most people don't realize this. they just unplug power and hope for the
best.

I know, but beaglebones are remote and I can’t control how the users power down the system

Then you did not design your hardware correctly.

Not really a hardware problem, more of a software issue.

On any Linux system that can have the power arbitrarily yanked without
notice, it is best to have all the non-volatile storage mounted as
read-only. If that isn't possible, there are various mount settings
(like noatime) and system configurations (like disabling logging, use
of ram based filesystem for ) that can vastly reduce the number of
writes made to the storage media.