Question about mount
Alexander Griesser
alexander.griesser at lkh-vil.or.at
Tue Mar 28 23:06:00 PST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Rob Landley wrote:
Sorry, I forgot to CC the list...
> For remount, it should check /proc/mounts. (Or /etc/mtab if you built the
> thing to maintain its own mtab. I didn't extensively test maintaining your
> own mtab because it's only relevant if you have no /proc directory.)
[lxtc3861 - ~ #] bbconfig | grep MTAB
# CONFIG_FEATURE_MTAB_SUPPORT is not set
[lxtc3861 - ~ #]
>> If the mountpoint can't be found in /etc/fstab, try to mount
>> the last entry in /etc/fstab and that is exact that, what happens.
>
> I don't understand what you're trying to say here.
The source code seems to do this in mount.c:
- ------------------------ 8< -------------------
// Loop through entries until we find what we're looking for.
memset(mtpair,0,sizeof(mtpair));
for (;;) {
struct mntent *mtnext = mtpair + (mtcur==mtpair ? 1 : 0);
// Get next fstab entry
if (!getmntent_r(fstab, mtcur, bb_common_bufsiz1,
sizeof(bb_common_bufsiz1)))
{
// Were we looking for something specific?
if (optind != argc) {
// If we didn't find anything, complain.
if (!mtnext->mnt_fsname)
bb_error_msg_and_die("Can't find %s in %s",
argv[optind], fstabname);
- ---->> // Mount the last thing we found.
mtcur = mtnext;
mtcur->mnt_opts=bb_xstrdup(mtcur->mnt_opts);
append_mount_options(&(mtcur->mnt_opts),cmdopts);
rc = singlemount(mtcur);
free(mtcur->mnt_opts);
}
break;
- ------------------------ 8< -------------------
> It takes the last of multiple matches because in /proc/mounts you can
> overmount the same mount point multiple times, and the last one is the one
> you want.
Ah, ok, now I understand. Sorry for that.
>> [lxtc3861 - ~ #] mount /
>> mount: Mounting /dev/hda1 on /system failed: No such device
>> [lxtc3861 - ~ #]
>
> Out of morbid curiosity, how did you get here without / already mounted?
/ is mounted, but it is mounted readonly.
In my init-scripts I then try to mount it readwrite.
> I notice that if you try to mount something in two places with different
> flags, the kernel sometimes gives strange error messages when refusing to do
> so. However, if you have something mounted in just one place, -o remount,rw
> should work.
OK, now I checked some files on my system and found something strange in
/proc/mounts, maybe that is the reason for this problem:
[lxtc3861 - ~ #] cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext3 rw,data=ordered 0 0
/dev/hda1 /system ext3 rw,data=ordered 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
none /proc/bus/usb usbfs rw 0 0
devpts /dev/pts devpts rw 0 0
tmpfs /var/tmp tmpfs rw 0 0
[lxtc3861 - ~ #]
The line containing rootfs looks strange, but I'll have to investigate
this further to see, where it comes from.
/system is definetly only mentioned once in /proc/mounts and in
/etc/fstab, so I'll try with this mountpoint:
Current situation:
- ------------------
[lxtc3861 - ~ #] cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext3 rw,data=ordered 0 0
/dev/hda1 /system ext3 rw,data=ordered 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
none /proc/bus/usb usbfs rw 0 0
devpts /dev/pts devpts rw 0 0
tmpfs /var/tmp tmpfs rw 0 0
Remount to readonly:
- ---------------------
[lxtc3861 - ~ #] mount -n -o remount,ro /system
[lxtc3861 - ~ #] echo $?
0
[lxtc3861 - ~ #] cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext3 rw,data=ordered 0 0
/dev/hda1 /system ext3 rw,data=ordered 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
none /proc/bus/usb usbfs rw 0 0
devpts /dev/pts devpts rw 0 0
tmpfs /var/tmp tmpfs ro 0 0
[lxtc3861 - ~ #] touch /system/x
[lxtc3861 - ~ #] rm /system/x
- -> Did not work, but:
[lxtc3861 - ~ #] mount -n -o remount,ro /dev/hda1 /system
[lxtc3861 - ~ #] touch /system/x
touch: /system/x: Read-only file system
[lxtc3861 - ~ #]
- -> works.
When only using `mount /system` or `umount /system` it works, but
in combination with "-o remount" the problems arise.
> Ah, I hadn't spotted the /dev/root!
>
> Ok, the behavior to look up /dev/root was taken out. Instead mdev grew an
> extra function, when populating /dev it creates a symlink from /dev/root to
> your real root device (if there is one). If your real root device is nfs or
> ramfs or some such, we could never do anything intelligent with this anyway.
I don't use mdev.
My root device is a gzipped filesystem image that I extract to /dev/ram0
at boot-time.
The underlying hardware contains an M-IDE storage that holds my
"firmware" for the thinclients. In my /linuxrc, I do the following
(which I found somewhere on the web):
- ------------------- 8< ----------------
#!/bin/sh
mount /dev/hda1 /mnt
echo -n "Installing ramdisk, please wait..."
gunzip -c /mnt/lxtc-firmware.bin.gz >/dev/ram0
echo done
umount /mnt
- ------------------- 8< ----------------
That works quite well, but maybe this is the reason why I am getting
the line with rootfs in /proc/mounts...
> If you're not using mdev, and you want to have /dev/root in your fstab, you
> need /dev/root in your /dev as well. Make a symlink to your real root
> device.
I know, that if I want to use /dev/root in /etc/fstab it has to exist.
I didn't use /dev/root by now in my fstab, but wondered why I could
mount/remount my root filesystem by calling it /dev/root, as in my
previous/origin mail to this topic.
I now changed my fstab to use /dev/root anyway.
ciao,
- --
Alexander Griesser (Netzwerkadministration)
E-Mail: alexander.griesser at lkh-vil.or.at | Web: http://www.lkh-vil.or.at
KABEG LKH Villach | Nikolaigasse 43 | 9500 Villach
Tel.: +43 4242 208 3061 | Fax.: +43 4242 971 3061
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEKjHX66HVD6KUm1oRAmpqAJ4tC8qxWNMzptf4G21xtkm12F1WFgCfYZN3
878PGbbHXAM7+b3S8ZmpxLI=
=uqgM
-----END PGP SIGNATURE-----
More information about the busybox
mailing list