Trying to add a RAM disk device to Minix 3.1.8

288 views
Skip to first unread message

orangemako

unread,
Oct 16, 2011, 9:13:24 AM10/16/11
to minix3
Hi everyone,

I am having trouble with adding a new RAM disk and mounting it in
Minix 3.1.8.

It seems that I may not be initializing some fields or structs. Or
we may not be calling a particular method that populates the
super-block for our ram disk.

Here's some details of what I've done so far:

When I try to mount my ram disk through the command line after
having created the ram disk device file through mknod:
mknod /dev/mydisk b 1 13
mount /dev/mydisk /mnt

I get the following error message from mount:
mount: Can't mount /dev/mydisk on /mnt: Invalid argument

In memory.c I set the number of ram disks to be 7 and in the
sef_cb_init_fresh function I initialized the device's base, size
and virtual address base. (similar to how imgrd device is
initialized).

I also defined the minor device number for the device as well in
dmap.h.

I traced the error for the mount to where it tries to tell the FS
which device to mount. The function call is in
/usr/src/servers/vfs/mount.c line 294 (req_readsuper).

I am currently trying to trace the error more thoroughly and also
investigating how other disks were initialized.

Thanks for any help you can provide.

pikpik

unread,
Oct 16, 2011, 4:17:32 PM10/16/11
to minix3
Hi,

On Oct 16, 9:13 am, orangemako wrote:

> Hi everyone,
>
> I am having trouble with adding a new RAM disk and mounting it in
> Minix 3.1.8.
>
> It seems that I may not be initializing some fields or structs.  Or
> we may not be calling a particular method that populates the
> super-block for our ram disk.
>
> Here's some details of what I've done so far:
>
> When I try to mount my ram disk through the command line after
> having created the ram disk device file through mknod:
> mknod /dev/mydisk b 1 13
> mount /dev/mydisk /mnt
>
> I get the following error message from mount:
> mount: Can't mount /dev/mydisk on /mnt: Invalid argument

You may want read older posts about this:
http://groups.google.com/group/minix3/browse_thread/thread/c9c5b68fa438adc7/d78ca5adf1d43388?lnk=gst&q=ramdisk

It looks like "ramdisk <memory size> <device>" is used.

I hope this helps,
pikpik

Antoine LECA

unread,
Oct 17, 2011, 3:52:11 AM10/17/11
to min...@googlegroups.com
orangemako wrote:
> It seems that I may not be initializing some fields or structs. Or
> we may not be calling a particular method that populates the
> super-block for our ram disk.
>
> Here's some details of what I've done so far:
>
> When I try to mount my ram disk through the command line after
> having created the ram disk device file through mknod:
> mknod /dev/mydisk b 1 13

Block device, handled by 'memory' driver, device #13 (i.e. 1 more than
the "usual" number).

You can probably make it easier to debug by using any number between 7
and 12 instead, i.e. sticking to the already defined any-use ramdisks.
This would mean not having to modify anything in memory.

Minor 4 (BOOT_DEV, i.e. /dev/boot) can also be considered if you want to
avoid fiddling with the user ramdisks.


> mount /dev/mydisk /mnt
>
> I get the following error message from mount:
> mount: Can't mount /dev/mydisk on /mnt: Invalid argument

Well, the only occurrence of EINVAL (the same as "Invalid argument") in
drivers/memory/memory.c is
switch (m_device) {
/*...*/
default:
/*...*/
/* Bogus number. */
if(m_device < 0 || m_device >= NR_DEVS) {
return(EINVAL);
}

So either the 'memory' driver which is answering to mount/VFS is not the
one you modified (and in the in-use memory driver, ramdisk#7 i.e. minor
13 will indeed appears as EINVAL); or EINVAL is returned by the code in
mfs/mount.c or mfs/super.c`read_super(); as you can see, there are quite
a number of reasons for this code...


Another options is to try fsck against the ramdisk image, then against
the device.


Antoine

Thomas Veerman

unread,
Oct 17, 2011, 4:18:01 AM10/17/11
to min...@googlegroups.com
Hi,

On 10/16/2011 03:13 PM, orangemako wrote:
> Hi everyone,


>
> Here's some details of what I've done so far:
>
> When I try to mount my ram disk through the command line after
> having created the ram disk device file through mknod:
> mknod /dev/mydisk b 1 13
> mount /dev/mydisk /mnt
>
> I get the following error message from mount:
> mount: Can't mount /dev/mydisk on /mnt: Invalid argument
>

It seems to me you've missed the part where you format the ram disk.
That's causing req_readsuper to fail; there is no super block. So the
steps are:

ramdisk <size in kB> /dev/ram?
mkfs.mfs /dev/ram?
mount /dev/ram? /mnt

It's not entirely clear to me why you'd want to create an additional ram
disk minor. There are already several available to you (and, in general,
unused): /dev/ram0 up to /dev/ram5. Please note that, as I said in the
thread linked to by pikpik, the memory driver has a hard coded limit of
6 ram disks. You first need to recompile the memory driver with a higher
constant if you need more than that.

--
Thomas

Reply all
Reply to author
Forward
0 new messages