update a running busybox

Harald Becker ralda at gmx.de
Tue Mar 29 15:32:09 UTC 2011


 Hallo Arno!

> mount -r -o remount /
> reboot
>
> The problem is, I can't remount it r/o. "device is busy".
> And without doing this, my jffs2-filesystem is not in a stable state
> while reboot.

Do a lazy umount before reboot (umount -l). My approch:

sync; sleep 0.25s
killall5 -TERM
sync; sleep 1.5s
umount -afrld
killall5 -KILL
sync; sleep 0.25s
sync; sleep 0.5s
exec reboot

... that leaves my SSD (flash card on notebook) in a stable state.
Depending on system and flash speed you may need to experiment a bit
with the sleep delays (shouldn't need more than 2 or 3 seconds on last
sleep).

The "killall5 -KILL" is really required in cases where kernel threads
and mount helpers are still running. Most of such kernel threads are not
affected directly by the killall5, but it helps to kill all pending
processes and close resources, that hold kernel threads open.

The lazy umount option in combination with "-f" and "-r" forces umount
even in such "Device busy cases", delaying the umount until all
processes has shut down (hence "exec reboot" and you need to run that
last script with exec too).

script busybox_update.sh:

#!/bin/busybox ash
... do your update here
sync; sleep 0.25s
killall5 -TERM
sync; sleep 1.5s
umount -afrld
killall5 -KILL
sync; sleep 0.25s
sync; sleep 0.5s
exec reboot

... make that script executable and run that script with "exec
busybox_update.sh"

--
Harald



More information about the busybox mailing list