6

I have written a dummy (ram disk) block device driver for linux kernel. When the driver is loaded, I can see it as /dev/mybd.

I can successfully transfer data onto it using dd command, compare the copied data successfully.

The problem is that when I create ext2/3 filesystem on it, I have to use -o loop option with the mount command. Otherwise mount fails with following result:

mount: wrong fs type, bad option, bad superblock on mybd, missing codepage or helper program, or other error

What could be the problem? Please help.

Thanks.

Sam Post
  • 3,721
  • 3
  • 17
  • 14
user295631
  • 61
  • 2
  • Post your driver unit and request routines? I have a ramdisk driver but have not seen this error, maybe seeing the code will help. – Sam Post Mar 17 '10 at 12:48
  • aah.. just crashed my linux system.. did a dd on wrong device! Need to start over again from installing linux... I will get back here if I can reproduce the problem. Thanks. – user295631 Mar 17 '10 at 12:54
  • Take a look at: http://user-mode-linux.sourceforge.net/ You can run a Linux within a Linux system. That would allow you to quickly build and 'deploy' a new version of plugin. And all the changes you would do (eg. `dd`) would be done within the guest OS, so it wouldn't break your native OS. As I remember there was even a possibility to have a `delta` of your file system changes in a separate file, so you could easily restore the initial state of your guest file system. – Grzegorz Oledzki Mar 17 '10 at 14:49
  • Any luck reproducing this error? Interested to see what the issue is... – Sam Post Mar 20 '10 at 04:18
  • I'm also curious to see the source code to the driver. – Tim Post Apr 26 '10 at 16:35
  • Jumpinjoe, please post your source... we're all curious to see what's going on. I have seen similar/same errors but only on VRAM – Sam Post Apr 29 '10 at 04:21

4 Answers4

3

Hmm, if it works with -o loop and doesn't work without, then I have bad news for you: your "device" is actually just a plain file in /dev. What does ls -l /dev/mybd show? If its filesize is non-zero, it's a regular file, and has nothing to do with your driver.

Use mknod to create the device file yourself if needed.

apenwarr
  • 10,838
  • 6
  • 47
  • 58
1

I see you're starting over again. As a quick note about your previous attempt, did you make sure your device appeared in /dev as a block device and not a character one?

Luke404
  • 10,282
  • 3
  • 25
  • 31
0

Create a filesytem on the device before mounting it:

mkfs -t ext2 /dev/mybd

or

mke2fs /dev/mybd
Doug
  • 8,780
  • 2
  • 27
  • 37
  • 1
    Try checking dmesg or /var/log/messages...sometimes the kernel writes diagnostic info there. – Doug Mar 17 '10 at 12:43
  • aah.. just crashed my linux system.. did a dd on wrong device! Need to start over again from installing linux... I will get back here if I can reproduce the problem. Thanks. – user295631 Mar 17 '10 at 12:54
0

The loop device is used to mount block special files on the linux filesystem emulating them as block devices. Hence, the mount throws error.

neil1234
  • 11
  • 2