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
As soon as I logout/run
telinit u at this point then I see the UBI0 go away and I can detatch it.
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.