View previous topic :: View next topic |
Author |
Message |
benny1967 Apprentice
Joined: 25 Apr 2004 Posts: 224
|
Posted: Thu May 29, 2008 5:55 pm Post subject: [Solved] Can't umount JFFS2 / MTD :( |
|
|
I'm followed step-by-step instructions on how to mount a JFFS2-filesystem and to my surprise succeeded. the steps were:
- create a MTD node typing "mknod /dev/mtdblock0 b 31 0" (i don't have the slightest idea what this is, but i do as i'm told)
- setup a loop device with "losetup /dev/loop0 rootfs.jffs2"
- type "echo "/dev/loop0" > /sys/module/block2mtd/parameters/block2mtd" without knowing what its for
- and finally "mount -t jffs2 /dev/mtdblock0 /mnt/jffs2/"
Only when I tried to reverse the process (umount and detach), i get an errors about not being able to umount/detach the file because they're being used.
finally (and this is what scares me), when I shut down my box, it says it can't umount the partition my home directory is on. i guess that's because the jffs2-file is right there, on my home partition.
I can ignore the message but get tons of "replaying transaction..." messages on the next boot and i don't feel comfortable with this.
my personal suspicion is that the one step i fail to successfully undo is the "echo "/dev/loop0" > /sys/module/block2mtd/parameters/block2mtd"-thingie. the problem with that is that i don't know what it is, what it does, what it's for. i tried to "echo "" > /sys/module/block2mtd/parameters/block2mtd" but that didn't change a thing.
what's the correct way to cleanly detach/umount the jffs2-file without getting into trouble?
and, as a 2nd question: while i do find documents about MTD in general, i'm not sure how it is needed to use the JFFS2-file. it's a file system, isn't it? why can't it be mounted to a loop device without the hassle?
Last edited by benny1967 on Mon Jun 16, 2008 8:13 pm; edited 1 time in total |
|
Back to top |
|
|
BradN Advocate
Joined: 19 Apr 2002 Posts: 2391 Location: Wisconsin (USA)
|
Posted: Fri May 30, 2008 12:21 am Post subject: |
|
|
Which step are you unable to reverse?
If the umount command fails, it's almost assuredly because there's open files or directories within the mount (including any active shell sessions, or even graphical file managers - I've seen this with older konqueror). Also, mounting something else inside the mount will prevent the outer-most mount from being unmounted.
The lsof utility can be useful to determine what's preventing an umount. It can be used like:
lsof +D /mnt/jffs
to check every file/directory in /mnt/jffs against open files and report matches. The manpage warns that this will use a lot of time/memory if the directory to be searched has a lot of stuff in it. Alternately, you could run lsof by itself and grep the output. |
|
Back to top |
|
|
sjordan0228 n00b
Joined: 29 May 2008 Posts: 3
|
Posted: Fri May 30, 2008 3:25 pm Post subject: |
|
|
BradN wrote: | Which step are you unable to reverse?
If the umount command fails, it's almost assuredly because there's open files or directories within the mount (including any active shell sessions, or even graphical file managers - I've seen this with older konqueror). Also, mounting something else inside the mount will prevent the outer-most mount from being unmounted.
The lsof utility can be useful to determine what's preventing an umount. It can be used like:
lsof +D /mnt/jffs
to check every file/directory in /mnt/jffs against open files and report matches. The manpage warns that this will use a lot of time/memory if the directory to be searched has a lot of stuff in it. Alternately, you could run lsof by itself and grep the output. |
fuser is also very helpful when you cannot unmount a filesystem. I use it all the time to figure out who is on my mount when needing to unmount |
|
Back to top |
|
|
benny1967 Apprentice
Joined: 25 Apr 2004 Posts: 224
|
Posted: Fri May 30, 2008 6:02 pm Post subject: |
|
|
Thanks for the helpful input. I'll not be home before Monday, but I'll try then and let you know. |
|
Back to top |
|
|
benny1967 Apprentice
Joined: 25 Apr 2004 Posts: 224
|
Posted: Mon Jun 02, 2008 9:23 pm Post subject: |
|
|
OK, here we go again
I was afraid I'd fuck up my home partition again, so I tried it all on a USB stick this time. (USB- stick is on /media/USB\ DISK/ - important for the last step - and: I'm right in this directory when doing all this, so some paths are relative)
The results are the same. First I do the following steps to mount the file:
Code: | mknod /dev/mtdblock0 b 31 0
losetup /dev/loop0 initfs.jffs2
echo "/dev/loop0" > /sys/module/block2mtd/parameters/block2mtd
mount -t jffs2 /dev/mtdblock0 jffs/ |
Moutn shows it as
Code: | /dev/mtdblock0 on /media/USB DISK/jffs type jffs2 (rw) |
losetup -a reports:
Code: | /dev/loop0: [0861]:21 (initfs.jffs2)
/dev/loop/0: [0861]:21 (initfs.jffs2) |
and finally cat /proc/mtd says
Code: | dev: size erasesize name
mtd0: 001cf000 00001000 "block2mtd: /dev/loop0" |
Now I try to get rid of it again:
umount jffs/
seems to be OK, line is gone in 'mount'-output
then
losetup -d /dev/loop0
reports
Code: | ioctl: LOOP_CLR_FD: Device or resource busy |
and finally
umount /media/USB\ DISK/
gives
Code: | umount: /media/USB DISK: device is busy
umount: /media/USB DISK: device is busy |
(This is what would normally happen to my home partition when I shut down.)
Trying to find out what uses /media/USB\ DISK/ by using lsof +D as suggested reports - nothing.
From what I can tell the USB-Stick doesn't umount because it holds the initfs.jffs-file, and something thinks this file is still in use. This very something provents it from being detached from /dev/loop0. It doesn't show up in the lsof +D output, though. So I'm stuck with a loop device that I can't get rid of... and whenever I mount the JFFS2-file, I'm afraid to risk the integrity of the filesystem it happens to be on because it never gets umounted cleanly. |
|
Back to top |
|
|
BradN Advocate
Joined: 19 Apr 2002 Posts: 2391 Location: Wisconsin (USA)
|
Posted: Tue Jun 03, 2008 5:21 am Post subject: |
|
|
A couple thoughts: Try catting that file before you echo the name to it - maybe the initial setting can be restored to unlink the mtd device. Also, you could try linking it to /dev/null or something like that. |
|
Back to top |
|
|
benny1967 Apprentice
Joined: 25 Apr 2004 Posts: 224
|
Posted: Tue Jun 03, 2008 7:10 am Post subject: |
|
|
I tried to read whats in /sys/module/block2mtd/parameters/block2mtd before I do the echo-thing.
Guess what? I can't. Root can't.
File is write only if you look at the attributes ("--w-------")
I thought (see above) that I could maybe echo "" to it, but this didn't make any difference at all. |
|
Back to top |
|
|
benny1967 Apprentice
Joined: 25 Apr 2004 Posts: 224
|
Posted: Wed Jun 11, 2008 9:18 pm Post subject: |
|
|
any more ideas? this is really annoying as I do a lot of this stuff recently to get into some other stuff by trial and error, so I do the whole procedure 10x a day or so... and it always leaves me with a 'broken' (=busy) loopback device. |
|
Back to top |
|
|
BradN Advocate
Joined: 19 Apr 2002 Posts: 2391 Location: Wisconsin (USA)
|
Posted: Wed Jun 11, 2008 9:20 pm Post subject: |
|
|
Have you tried setting the mtd device to something like /dev/null, or even another dummy loopback linked to something on / where it will still allow you to unmount everything? |
|
Back to top |
|
|
benny1967 Apprentice
Joined: 25 Apr 2004 Posts: 224
|
Posted: Thu Jun 12, 2008 8:20 pm Post subject: |
|
|
EDIT:
I found talk on the lkml that, I guess, is relevant:
Quote: | Also, one can add a block2mtd mtd device with things like:
echo /dev/loop3,$((256*1024)) |
sudo tee /sys/module/block2mtd/parameters/block2mtd
but individual mtds cannot be removed. You can only do a
modprobe -r block2mtd to remove *all* the block2mtd mtds.
This patch proposes to add the cabability with:
echo /dev/loop3,remove |
sudo tee /sys/module/block2mtd/parameters/block2mtd |
So I guess there's nothing wrong with how I do it - it just cannot be done except block2mtd is compiled as a module. (which is what I'll try next.)
Thx for the support so far!
probably obsolete old post below.
===
I'm not sure I understand you correctly; what I tried was things like
Code: | echo "/dev/null" > /sys/module/block2mtd/parameters/block2mtd |
which doesnt change anything. I still get Code: |
# cat /proc/mtd
dev: size erasesize name
mtd0: 001cf000 00001000 "block2mtd: /dev/loop0" |
afterwards. |
|
Back to top |
|
|
BradN Advocate
Joined: 19 Apr 2002 Posts: 2391 Location: Wisconsin (USA)
|
Posted: Thu Jun 12, 2008 11:21 pm Post subject: |
|
|
Gotcha, it was probably overlooked as an unimportant limitation since loop backed mtd devices probably are only used for testing purposes. Using it as a module will probably be sufficient for what you want to do then. It just seems strange because the release code must be present (ie, the module can be unloaded without exploding things), but just not on an individual basis. |
|
Back to top |
|
|
benny1967 Apprentice
Joined: 25 Apr 2004 Posts: 224
|
Posted: Mon Jun 16, 2008 8:14 pm Post subject: |
|
|
Done. Compiling block2mtd as a module does the trick for now. |
|
Back to top |
|
|
|