Tiny Core Base > TCB Tips & Tricks

symlinks for external storage under /home/tc?

(1/3) > >>

jamtat:
As what I hope will be a final issue, I'd like to ask the possibility of getting symlinks that point to connected USB drives to appear in /home/tc. What I mean is that, when someone brings a USB drive and plugs it in, the OS finds and assigns it a mount point, and the drive can then be mounted by clicking on the relevant entry in the mnttool menu. That's all working fine and dandy.

In legacy Linux fashion, those mounts points get created under /mnt. The problem is, my users are probably going to have problems finding /mnt and are thus liable to be unable to use their flash drives. Besides, I'd rather not have them rooting around the file system trying to find the drive anyway.

What I thought of as a possible solution is for a symlink to appear in /home/tc once a portable drive is mounted. That would be preferable because I've already got pcmanfm in wbar and it opens in /home/tc when clicked. If a symlink to, say, /mnt/sdb1 were to appear there when /dev/sdb1 gets mounted, I think it would be much less confusing to my users.

So can anyone suggest a way to get the system to create symlinks in /home/tc when external storage gets mounted using mnttool?

Thanks,
James

jamtat:
I guess another possible option for getting the behavior I want would be to cause mnttool to, not just mount the drive when the relevant mnttool menu entry gets clicked, but to invoke pcmanfm as well and cause it to open in the directory where the drive gets mounted. I guess that might require tweaking mnttool's code, which is a bit beyond my capabilites, though.

James

roberts:
mnttool will use file manger set via FILEMGR environment variable.
example:

FILEMGR=fluff

Rich:
Hi jamtat
Some scripting may be of use to you for this.
This will search for drives sda, sda1-sda8, sdb, sdb1-sdb8, ......, sdd1-sdd8
If a drive is found and not mounted, it gets mounted, the drive designation is saved in a file, and a
link is created.

--- Code: ---#!/bin/sh
DRIVESMOUNTED="/tmp/newmounts"
for i in `grep -o "/mnt/[s]d[a-d][1-8, ]" /etc/fstab` 
do
j=`grep -o $i /etc/mtab`
[ -n "$j" ] && continue
mount "$i"
echo "$i" >> $DRIVESMOUNTED
ln -s /mnt/"$i" ~/"$i"
done
--- End code ---
This will unmount only the drives mounted by the above script and remove the previously created
links. Lastly it syncs the file system and removes the /tmp/newmounts file.

--- Code: ---#!/bin/sh
DRIVESMOUNTED="/tmp/newmounts"
while read -r i
do
umount "$i"
/bin/rm -f ~/"$i"
done < $DRIVESMOUNTED
rm -f $DRIVESMOUNTED
sync
--- End code ---
That should be an adequate framework to get you started. Add a couple of icons to the wbar to call
the scripts and you're done.

jamtat:

--- Quote from: roberts on January 25, 2012, 10:02:44 PM ---mnttool will use file manger set via FILEMGR environment variable.
example:

FILEMGR=fluff

--- End quote ---
Thanks for your input, roberts. You seem to be implying that mnttool can invoke a file manager: have I understood you correctly? If so, how does that occur? I've tried, for example, double-clicking on the menu entry for a connected drive but that does not invoke a file manager, even after I've issued env FILEMGR=pcmanfm (and confirmed that the setting "took" by inspecting the output of the env command). Further explanation will be appreciated, or a link to some documentation for mnttool, if there is any.

James

Navigation

[0] Message Index

[#] Next page

Go to full version