I have an embedded linux on arm7.
I have a rootfs mounted on MTD partition 10 (for example), i.e. /dev/mtd10, which is a flash device. The volume is UBIFS device UBI0 (/dev/ubi0).
I have setup a pivot_root (similar to a chroot) tmpfs roughly following the instructions from here: resize-a-live-root-fs-a-howto.
I want to erase/re-format mtd10 (UBI0) The problem that I have is that I can't detach/format UBI0 until I have because it tells me its busy. So, I use the command:
fuser -vm /dev/mtd10
and this gives me a list of processes that I can kill, so I do all that and then umount (or umount -l) all the partitions that are mounted on UBI0.
So my system no longer has any dependency on UBI0... except the shell I am running. I have tried combinations of many things, but the only thing that seems to work (once I have tidied up) is to logout (using exit
command) and then log back in (for me I just have to type in the username root
).
As soon as I logout/run telinit u
at this point then I see the UBI0 go away and I can detatch it.
update: killing rc_mxc.S
has a similar effect to loging out (i.e. it ends my shell and I have to login again. But this also ends my script :(
The problem here is that I don't know how I can script that up. Running exit
in a script just ends the script.
exec /tmp/.../bin/sh /tmp/.../myscript
to swap over to a new shell script, releasing some of these.exec myscript.sh
to kill of everything including thesh
that was running on the device and that seemed to work (but after the script I still need to login again) - however I think because mysh
that I start in is on the device then the exec may also be on it so I had to not terminate thesh
that I spawned ...complicated! - in short, I will try your recommendation as it seems sound :)