>>> "Manuel Wagesreither" <ManWag@xxxxxxxxxxx> schrieb am 16.02.2022 um 13:28 in Nachricht <acd7f33f-29c4-4197-b1e6-0b1703c2d88a@xxxxxxxxxxxxxxxx>: > Hi all, > > We'd like to implement a factory reset for an embedded device we are working > on. > > I think the cleanest approach would be a factory‑reset.target which > WANTS/REQUIRES reboot.target + a factory‑reset.service which wipes the > persistent storage. > > The thing is, START of factory‑reset.service would need to be synchronized > with the STOPs of some mount units which got started during system boot. > > For easier understanding: > > System start: > 1. Start path‑to‑first.mount > 2. Start path‑to‑second.mount > > System halt: > 1. Stop path‑to‑second.mount > 2. Stop path‑to‑first.mount > > Factory reset: > 1. Stop path‑to‑second.mount > 2. Start factory‑reset.service, wiping /path/to/first/* > 3. Stop path‑to‑first.mount > > I currently have no idea how to express this in systemd terms. If someone on > this list could provide some advice, it would be much appreciated. As for the recent "firmware flashing" thread I think it would be best to handle that via some boot parameter and something like a "boot once" boot entry that adds that specific parameter. I also think the clearing should be best done in initrd before the real root filesystem is mounted. That should be most flexible. > > Thanks in advance and best regards, > Manuel