PDA

Bekijk de volledige versie : automount to a folder at your choise



newbiefan
06-10-2007, 13:09
Well, I had a particular problem, which I solved with a workaround:

Any attached storage device is mounted after reboot to /tmp/harddisk/part1 - partx.
I have a HDD with 3 partitions always connected to my Asus at the lower USB Port.
Part1 is mounted to /opt, part2 is a 512MB swap and part3 is a 100 GB share partition
mounted to /tmp/harddisk/share which is my samba share folder.
Sometimes, I've to connect several sticks, hdds with different datas to my usb-hub
(connected to my asus router) and make all data available in samba. But after start up,
I don't know how many devices will be connected. Hence, I had to mount it by hand to
my samba sharefolder, because a samba config (smb.conf) with unknown folders at start up
is not possible. Further, due to some external devices, mounted to a folder
/tmp/harddisk/external it was not allowed to set my sambashare-folder to /tmp/harddisk.
So it would be necessary to recompile the complete firmware to change scsi hotplug or to
manage it by a workaround. As I'm not firm with compiling such firmware, my preferred
solution was a workaround.

The main point is to speed up your post-boot, this is the most important thing for
a well working solution. Serveral howtos have many sleeps in the post-boot which can cause
really long delays. So I removed any delay in my post-boot as long as it hasn't any
influence to a stable operation.
Please check well and remove really all not needed sleeps in your post-boot if you wanna
give it a try.

PRECONDITIONS: A valid and running installation according wenigs howto or any other optware.
Samba is not a must, but a present and valid /opt/etc/init.d and a /opt/sbin folder is needed.
Download all files and remove the extension (.txt) eg.: atmnt.txt to atmnt

Installation:
1.) Move file atmnt (V0.9.4) with winscp to /opt/sbin
2.) Move file attached (V0.1) with winscp to /opt/sbin
3.) Move file S99attached to /opt/etc/init.d
4.) Now use putty to change your post-boot vi /tmp/local/sbin/post-boot
(with "i" you start insert mode) and remove all sleep (except a needed one)
Now insert right before starting rc.unslung

#if opt is mounted, we mount all devices which are
#not mounted yet to our samba share folder, using script atmnt
if [ -d /opt/sbin ]
then
/opt/sbin/atmnt #execute automount at start-up
fi
Then exit vi and store your post-boot with: "ESC : wq ENTER"

5.) "cd /opt/etc/init.d"
perform a "chmod +x S99attached"
6.) "cd /opt/sbin"
perform a "chmod +x atmnt"
perform a "chmod +x attached"
"vi atmnt"
Choose a loglocation, consider to choose a writeable location or use /dev/null (linux nirwana)
If you wanna use "logger", just exchange all echo >> loglocation with logger messages.
Change sambasharefolder, this can be any writeable directory (eg /tmp/harddisk).
Change the name of the attached dirs, I use "attached". It can have any name.
If you want to use more as maxdisk, then increase it - same thing with maxparts and maxattached.
Exit vi and store your configured atmnt with: "ESC : wq ENTER"
7.) Finally, we have to store changed post-boot to flash:
"flashfs save && flashfs commit && flashfs enable && reboot"

Now you get the following behavior of any attached storage device (at runtime or boot):
Every storage is checked for more valid partitions and they are automatically mounted to
your sambasharefolder in folders with the name attachname. Further, numbers starting with 1
are used, eg. /sambasharefolder/attachname1.
For instance: sambasharefolder=/tmp/harddisk/share and your attachname=dongle
When a usb-flash or hdd is plugged to your asus, following directory is created and the device is mounted to:
/tmp/harddisk/share/dongle1, for the next one: /tmp/harddisk/share/dongle2 and so on.

I have added my post-boot just to allow you a closer look if yours fail.

Any comments, suggestions and improvements are greatly appreciated.
I know, some improvements are obvious, therefore a left-over was necessary :-)
Have fun!!

Newbiefan