Home > database >  How to automating root filesystem cleaning without intramfs?
How to automating root filesystem cleaning without intramfs?

Time:03-04

I have an embedded device that on extremely rare occasions will have a dirty root filesystem. System-D will halt boot with:

Give root password for maintainence
(or type control-D to continue):

These situations are very rare and can be solved by doing the following after entering the root password:

# mount -o remount,ro /
# fsck /dev/mmcblk1p3 

Is there anyway to automate this or even try to perform the cleaning when the filesystem is in use?

CodePudding user response:

You can overwrite systemd emergency mode by editing the appropriate Unit file (or just systemctl edit emergency.service).

You can then add something like this:

[Service]
ExecStartPre=/bin/sh -c "mount -o remount,ro / && fsck /dev/mmcblk1p3 && /bin/systemctl reboot"
  • Related