# mount -o bind /src/ /dst doesn't work in ramdisk - why?

## Januszzz

Like in subject. When I'm trying to mount a dir elsewhere I got 

```
drake ~ # mount -o bind /overlay/ /home/

mount: wrong fs type, bad option, bad superblock on /overlay,

       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try

       dmesg | tail  or so

```

Any ideas?

----------

## Sadako

What does dmesg tell you?

And when you say ramdisk, do you mean a tmpfs, a ramfs, or an actual ramdisk formatted with one of the standard linux filesystems?

----------

## Januszzz

absolutely nothing. I got no kind of logger on this too, if I have to I'll install (this is kinda of embedded appliance). I thought I'm lacking a module or sth.

----------

## mv

I cannot try in the moment, but shouldn't the syntax be 

```
mount --bind /overlay /home
```

----------

## Januszzz

 *Quote:*   

>  cannot try in the moment, but shouldn't the syntax be
> 
> Code:
> 
> mount --bind /overlay /home

 

Well, it doesn't work either - I've used to type mount -o bind, but I've tried this way too.

----------

## Januszzz

 *Quote:*   

> And when you say ramdisk, do you mean a tmpfs, a ramfs, or an actual ramdisk formatted with one of the standard linux filesystems?

 

Sorry, I've noticed this now. I boot the kernel and the kernel boots to unpacked ramdisk (kernel and ramdisk both loaded by GRUB). Mount looks like this:

```
rootfs on / type rootfs (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec)

udev on /dev type tmpfs (rw,nosuid,size=10240k,mode=755)

devpts on /dev/pts type devpts (rw,nosuid,noexec,gid=5,mode=620)

shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec)

/dev/sdb2 on /conf type ext2 (rw,noatime)

usbfs on /proc/bus/usb type usbfs (rw,noexec,nosuid,devmode=0664,devgid=85)

securityfs on /sys/kernel/security type securityfs (rw,noexec,nosuid,nodev)
```

Everything works perfectly besides mount -o bind. Maybe some more mount options are needed? I don't use any special kernel options, as far as I can recall kernel line looks like this (I would need to reboot).

```
kernel root=/dev/ram0 udev vga=791 init=/init
```

----------

## Sadako

A ramdisk is a block device, it still needs a filesystem on top of it, so which filesystem are you using?

It probably shouldn't make a difference anyway.

What about the rest of your system, are you using uclibc & busybox, and if you're using busybox are you by any chance using the mount utilities provided by it?

----------

## Januszzz

 *Quote:*   

> A ramdisk is a block device, it still needs a filesystem on top of it, so which filesystem are you using? 

 

Yep, I dunno if there is filesystem here  :Smile:   When booting, GRUB says it mounts ext2 filesystem, but I've created root tree, then packed the ramdisk using the command:

```
find . | cpio -o -H newc | gzip > /ramdisk
```

and later I just load it from grub. I do not create a filesystem. 

Default size of ramdisk is set to 400MB in the kernel, mine ramdisk when packed is 108MB, unpacked is 300MB. It boots fine, launch X, then my custom program, all other issues (maybe 100++) I've resolved. Until now I've even did some workaround to trick the mount issue, but still it would be cool to know.

 *Quote:*   

> What about the rest of your system, are you using uclibc & busybox, and if you're using busybox are you by any chance using the mount utilities provided by it?

 

No, I'm using full glibc, everything is compiled from stable x86 Portage branch (BTW I would really like to use uclibc, but my closed source programs have some ugly issue with it, so not this time).

EDIT: and I confirm the above options when booting the kernel - I only forgot to include quiet  :Smile: 

----------

## Sadako

Okay then, I really don't know what's wrong.

One possible guess; you're trying to mount over /home, however you stated you start up X, so maybe /home is just "busy" and can't be mounted over?

I really don't think it works like that, I'm fairly sure I've mounted over directories which were still in use by something, and anything that already had a file open before I did the mount continued to work as if I hadn't mounted at all, however it might be worth trying to mount over a new, unused directory instead.

Also, just to cover all your bases, try mounting some other directory than /overlay, although I can't see how that could possibly be the issue.

It's odd that dmesg doesn't tell you anything, these are all kernel messages so whether or not you have a system logger running should be of no consequence...

----------

## mv

I have two other guesses: First is that /home or /overlay (or symbolic links to them) are somewhere listed in your /etc/fstab: Then mount will automatically take that options and only add those options you enter on the command line.

The other guess: As I understand you are speaking about your initramfs, and your output of "mount" shows that /etc/mtab does not contain any information about /overlay. You might try to correct /etc/mtab. Perhaps it already helps if you pass "mount" the correct filesystem type with "-t tmpfs".

----------

## Januszzz

My fstab:

```
/dev/ram0     /           ext2    defaults      0 0 <-- shame on me, please forgive me  I didn't know ;-)

proc          /proc       proc    defaults    0 0

LABEL=termCF  /conf           ext2 defaults,noatime 0 0
```

 *Quote:*   

> The other guess: As I understand you are speaking about your initramfs, and your output of "mount" shows that /etc/mtab does not contain any information about /overlay. You might try to correct /etc/mtab. Perhaps it already helps if you pass "mount" the correct filesystem type with "-t tmpfs".

 

Yes, /etc/mtab doesn't include the info, but I'm sceptic if it is needed (anyway, I tried copying /proc/mounts /etc/mtab).

When the appliance is booted I do test if there is a device labelled termCF. It should contain additional configuration (netfilter, alsa, homes, etc.). I need to override defaults included on the appliance, so I wanted to:

- mount the termCF onto /conf

- mount -o bind /conf/home /home, mount -o bind /conf/netfilter /var/lib/iptables etc. 

I cannont simply rsync and overwrite/delete defaults because I need them if the termCF is gone (when termCF is gone I restart some services again).

----------

## Januszzz

hihihihi!!   :Cool: 

```

termCF ~ # ls -al /conf/

ls: cannot access /conf/lost+found: Input/output error

ls: cannot access /conf/boot: Input/output error

ls: cannot access /conf/home: Input/output error

ls: cannot access /conf/iptables: Input/output error

ls: cannot access /conf/kernel: Input/output error

ls: cannot access /conf/ramdisk: Input/output error

ls: cannot access /conf/alsa: Input/output error

ls: cannot access /conf/cups: Input/output error

total 8

drwxr-xr-x  9 root root 4096 Sep 14 21:46 .

drwxr-xr-x 16 root root    0 Sep 15 20:55 ..

d?????????  ? ?    ?       ?            ? alsa

d?????????  ? ?    ?       ?            ? boot

drwx------  2 root root 4096 Sep 14 20:49 core

d?????????  ? ?    ?       ?            ? cups

d?????????  ? ?    ?       ?            ? home

d?????????  ? ?    ?       ?            ? iptables

-?????????  ? ?    ?       ?            ? kernel

d?????????  ? ?    ?       ?            ? lost+found

-?????????  ? ?    ?       ?            ? ramdisk

termCF ~ #                     

```

Now my dmesg is full of output   :Laughing: 

I need to find another CF.

EDIT: suming this up I guess the issue is in kernel. I've never had problems with that before and I even remounted dirs with custom libs on embedded uclibc system, all was fine. Here is no problem, as I can make internal backup of those files I need, easy things just work. I will try to explain this later on, maybe when using other kernel.

----------

