Author Topic: Mount Confusion  (Read 2600 times)

qx773

  • Full Member
  • ***
  • Posts: 219
    • View Profile
Mount Confusion
« on: September 01, 2005, 02:49:06 am »
In the Sharp ROM on my SL-C760, if your present working directory is "/mnt/card" and you type at a shell prompt:

mount directoryname

Then the computer acts as if you typed:

mount /usr/mnt.rom/card/directoryname

because /mnt/card is a symbolic link to /usr/mnt.rom/card.

However, if your present working directory is not /mnt/card and you type:

mount /mnt/card/directoryname

Then the computer acts as if you typed

mount /mnt/card/directoryname

The program that implements the mount command, busybox, looks through the /etc/fstab file and looks for an exact string match to either /usr/mnt.rom/card or /mnt/card, but not both.  If you have one or the other string on a line in /etc/fstab, then the mount command will fail in one of the instances that I described above.  This failure is what is probably stopping most people from installing the dev-img1.5 setup script on Zauruses that have the Sharp ROM.  If you have two separate entries in /etc/fstab with the /usr/mnt.rom/card and /mnt/card strings to mount the same directory and use the "mount -a" command to mount everything mentioned in /etc/fstab, then there will be two separate mounts for the same directory, which is undesirable if you are mounting loop devices and have a limited number of loop devices.

Here is a work-around.  The mount command exists as a symbolic link in /bin/mount to busybox.  Write a shell script called mount and put it in a directory that is closer to the beginning of the $PATH environment variable.  On my computer, the /home/QtPalmtop/bin directory is earlier in the path than /bin.  You have to be the root user by executing the "su root" command in order to be able to place the new mount script in the /home/QtPalmtop/bin directory.  The content of this /home/QtPalmtop/bin/mount shell script is one line:

Code: [Select]
/bin/mount $(echo $* | sed "s/\/mnt\/card/\/usr\/mnt.rom\/card/" | sed "s/\/mnt\/cf/\/usr\/mnt.rom\/cf/")
This script can be made executable with the commands:

su root
chmod 755 mount


What this script does is replace the first "/mnt/card" string in the parameter list with "/usr/mnt.rom/card".  The script also replaces the first instance of "/mnt/cf" with "/usr/mnt.rom/cf".  The script then passes the altered parameters to the original "/bin/mount" to process.  This script makes the path names consistent when you use the mount command.

You also need to do one more thing.  In your /etc/fstab file, you have to replace "/mnt/card" with "/usr/mnt.rom/card", and you have to replace "/mnt/cf" with "/usr/mnt.rom/cf".  That way, the /bin/mount command will find an exact string match in /etc/fstab.
« Last Edit: September 01, 2005, 07:41:25 pm by qx773 »

qx773

  • Full Member
  • ***
  • Posts: 219
    • View Profile
Mount Confusion
« Reply #1 on: September 03, 2005, 04:44:28 am »
When I try to mount some loop devices in

/etc/rc.d/rc.local

with a line like:

mount /home/zaurus/develop 2> /home/zaurus/mount.err

after editing

/root/etc/rc.d/rc.sysinit

to enable the execution of

/etc/rc.d/rc.local

then after rebooting, the mount.err file contains:

mount: ioctl: LOOP_SET_FD: Bad file descriptor
mount: Could not setup loop device


When do the loop devices become active?
« Last Edit: September 03, 2005, 04:48:35 am by qx773 »

qx773

  • Full Member
  • ***
  • Posts: 219
    • View Profile
Mount Confusion
« Reply #2 on: January 01, 2006, 11:35:05 pm »
It seems that rc.local is a bad place to execute the mount command.  A better place is:

/etc/rc.d/rc5.d/S99local

You can create the S99local file if it does not exist:

cd /etc/rc.d/rc5.d
su root
echo mount -a >> S99local
chmod 755 S99local
exit


I am attaching a copy of my file.

The S99local file can act like the AUTOEXEC.BAT file in MSDOS/Windows once everything else has initialized.  The number after the letter S indicates the order in which the initialization scripts execute, so a high number of 99 will make the S99local script run last.
« Last Edit: January 02, 2006, 12:29:19 pm by qx773 »