[systemd-devel] reformat partition when device is in emergency mode
Lennart Poettering
lennart at poettering.net
Mon Jan 13 10:39:57 UTC 2020
On Mo, 13.01.20 10:19, Belisko Marek (marek.belisko at gmail.com) wrote:
> Hi,
>
> I have embedded system which contains fat32 partition at the end of
> partition table. In case partition cannot be mounted (I'm using
> fstab-generator to automatically mount partition) device will enter
> emergency mode. My idea is to check somehow in this mode that
> partition is corrupted and reformat it. Is there some simple way to
> detect that condition? Thanks for any pointers.
By default all mounts not marked with "noauto" or "nofail" in fstab
are odered before local-fs.target and made a Requires= dependency of
it, so that the whole target fails as result and the system enters
emergency state. If you don't want that to happen and want to handle
the error on your own, an OK'ish hack would be to put together a
simple service that you use in place of the fstab line, and that does
your fsck + mount + mkfs loop. Could even be a shell script. write it
carefuly, wrap it in a service, and order local-fs.target with
REquires= + After= to it, so that it is used in lieu of the mount
unit.
Lennart
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list