BUG: Mount Loopback FS over Block Dev in 2.3.7+

Byron R. Stanoszek (byron@hilbert.math.uakron.edu)
Wed, 23 Jun 1999 14:46:22 -0400 (EDT)


I've encountered a big problem with mounting loopback devices on remote
systems. I will explain the details below. I'm not Quite sure if this worked
on 2.3.5 or not, but I just tested it out on 2.2.5 and there is no problem
with it; i.e. 2.2.5 works the way it should, 2.3.7+ is broken.

What I did:
-----------

Let us pretend there are two machines, Mach_A and Mach_B.

On Mach_A:
# dd if=/dev/zero of=diskimage bs=1k count=32768

That should create for me a zeroed image file, 32Mb.

# mke2fs -m0 -i32768 diskimage ; Create the filesystem in that file.

# mkdir /ext0
# mount -o loop diskimage /ext0 ; Mount the new filesystem via loopback.

# cp -a /stuffIneedtocopy/* /ext0 ; Copy my files over.
# umount /ext0

Now I should have a perfectly valid loopback image. Note that this procedure
so far works perfectly on a 2.2.5 kernel.

-------------------------

On Mach_B, mounting Mach_A over NFS:

I have rd.c set up to use 16 ramdisks of 32768K. I only use /dev/ram0.
NFS is fully mounted. I proceed to copy my diskimage file into /dev/ram0.
I have a special program that copies text into /dev/ram0 with a blocksize of
4K, but this should also work too (as it does on 2.2.5):

# cd /nfsdir
# cat diskimage > /dev/ram0
# mount /dev/ram0 /ext0

Now I can correctly mount /dev/ram0 as it was from the image file.
The problem occurs when I actually go into it. The directory structure looks
perfectly okay..

# cd /ext0/etc
# ls -l

total 440
-rw-r--r-- 1 root root 13 Jun 17 15:39 group
-rw-r--r-- 1 root root 135 Jun 17 15:42 hosts
-rw-r--r-- 1 root root 50 Jun 21 15:35 inittab
-rw-r--r-- 1 root root 59 Jun 11 10:19 issue
-rw-r--r-- 1 root root 1250 Jun 17 16:29 localtime
-rw-r--r-- 1 root root 51 Jun 23 13:57 mtab
-rw-r--r-- 1 root root 31 Jun 17 16:32 passwd
-rw-r--r-- 1 root root 1191 Jun 21 14:59 protocols
-rwxr-xr-x 1 root root 279 Jun 22 15:32 sysinit
-rw-r--r-- 1 root root 434898 Mar 29 11:08 termcap
drwxr-xr-x 2 root root 1024 Jun 21 15:56 vga

# cat group

<No output>

# less group

^@^@^@^@^@^@^@^@^@^@^@^@^@
(END)

More or less, all the files here have NULL characters in them, the amount of
NULLs equal to the size of the file.

Note that if I do this same procedure in 2.2.5, 'cat group' actually prints:

root::0:root

(as it should).

---------------------------

This is the thing. If IN 2.3.7/2.3.8, if I do:

# mount -o loop /dev/ram0 /ext0

INSTEAD OF

# mount /dev/ram0 /ext0

so that /ext0 uses /dev/loop0, it works perfectly as it should, and
'cat /ext0/etc/group' prints the correct output. For it to work on 2.3.8
though it MUST be mounted as loopback. Please fix so that such a filesystem
does not need to be mounted from /dev/loop0.

---
Final comments:
---------------
Somewhere in the new FS code I believe mounting a filesystem on /dev/ram0
(or perhaps /dev/fd0 too, any block device . . .) does not work if the
filesystem was first created in a file via Loopback (-o loop).

The actual mke2fs/mount -o loop on Mach_A does not seem to make any difference if Mach_A was 2.2.5, 2.3.7, or 2.3.8.

I also tried this with ramdisk_size=4096 instead of 32768. Same problem occurs only under 2.3.7+.

Please email me <byron@math.uakron.edu> if you have any questions about what I am trying to get at, or if you need me to test any additional configurations to track down the error.

---
Byron Stanoszek        <byron@math.uakron.edu>
System Administrator - University of Akron Applied Mathematics Dept.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/