Damaged filesystem after normal shutdown

  • Hi,

    I am running libreelec 10.0.1 on a raspberry pi 4. It is installed on a USB-harddisk/ssd.

    I initiate a shutdown via kodi, the system shuts down, the harddisk/usb switches off

    and after some seconds I pull out the power-socket. That works just fine. But

    sometimes, when booting, the filesystem is corrupt and needs a fsck. The system waits

    2 minutes.

    Why does that happen? How can I shutdown/poweroff without damaged filesystem?

    For me it looks like the usb-power is switched off before the filesystem is unmounted.

    Is there any race-condition in the shutdown process?

    Can I change the 2 min. wait somewhere? In my opinion it is useless to wait 2min. the

    fsck can start suddenly.

  • Please provide a full debug log.

    How to post a log (wiki)

    1. Enable debugging in Settings>System Settings>Logging
    2. Restart Kodi
    3. Replicate the problem
    4. Generate a log URL (do not post/upload logs to the forum)

    use "Settings > LibreELEC > System > Paste system logs" or run "pastekodi" over SSH, then post the URL link
  • Here it is:

    External Content pastebin.com
    Content embedded from external sources will not be displayed without your consent.
    Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.

    But I don't think that it has something to do with kodi as it happens before/after kodi is running.

  • Thanks. It's not related to LE's mounting process. Your SQLite database seems to be broken:

    Code
    2022-02-27 19:10:01.642 T:1062    ERROR <general>: SQL: [MyVideos119.db] SQLite error SQLITE_CORRUPT (database disk image is malformed)
                                                       Query: vacuum
                                                        (database disk image is malformed)
    2022-02-27 19:10:01.643 T:1062    ERROR <general>: Compress - Compressing the database failed
  • It was already damaged multiple times and I repaired it. The DB is damaged

    because the filesystem is always damaged after shutdown. I guss it is because the power of

    USB (harddisk) is switched off before unmounting. I don't have problems with kodi, I have

    problems with the underlying linux (init-/shutdown-system).

    I repaired the db with .recover:

    xbmc1:~/.kodi/userdata/Database # for i in *.db ; do echo $i ; sqlite3 $i "PRAGMA integrity_check"; done

    Addons33.db

    ok

    Epg13.db

    ok

    MyMusic82.db

    ok

    MyVideos119.db

    ok

    TV38.db

    ok

    Textures13.db

    ok

    ViewModes6.db

    ok

    They are now fine. After that I made some shutdowns and it happened again: filesystem damage, need

    to wait 2 minutes for fsck

    Any other idea?

    Edited once, last by ojoa (February 28, 2022 at 10:41 AM).

  • Then you could be right. Try to write custom shutdown / poweroff scripts containing:

    1. umount your USB drive
    2. sleep for some time
    3. call the systems shutdown / poweroff
  • I can not use a custom shutdown script. The usb drive is still mounted under /var/log and /storage with open files, e.g. systemd logging daemons and also the shutdown script itself which is in /storage.

    Any other Idea?

    I still think it is a bug in the systemd shutdown process. Maybe its not forced to first umount and then switchoff power of usb. Maybe its allowed to do in parallel. Systemd tries to do as much as possible in parallel.

    Problem is I still did not find the script/process which powers off the usb. Then I could add a dependency to first umount