Unfortunately no one can be told what fun_plug is - you have to see it for yourself.
You are not logged in.
I'm a newbie reading and learning as I go (first experience w/linux ever) so I do appreciate your help.
Below is the fun_plug example on attaching a USB drive from the Wiki...I've numbered the lines to make it easier to ask a couple questions about it...
Wiki wrote:
1. #
2 # fun_plug for sharing two external USB Discs
3 #
4 DIR=/mnt/HD_a2
5 if [ ! -d lnx_bin ]
6 then
7 exit 0
8 fi
9 if [ -f $DIR/lnx_bin/usb-storage.ko ]
10 then
11 insmod $DIR/lnx_bin/usb-storage.ko
12 dmesg > $DIR/lnx_bin/logs/dmesg.out
13 mkdir $DIR/usb_120
14 mkdir $DIR/usb_240
15 mount /dev/sdc1 $DIR/usb_120
16 mount /dev/sdd1 $DIR/usb_200
17 fi
I have placed usb-storage.ko on my DNS in the lnx_bin directory, and created a lnx_bin/logs directory as well. I've also placed ntfs.ko there as well, though I'm not sure if it is required or not. (ntfs.ko was mentioned on a thread on this I found while searching, but there was no info on how/when it was used...)
Questions:
1. Do I need to invoke ntfs.ko in any way if I'm using NTFS drives in the USB enclosure? If so, what commands would I insert in the fun_plug above, and where?
2. In line 14: "usb_240" doesn't match the "usb_200" in line 16...is that just a typo, or are they different for another reason? Should they both be the same, and are they intended to match the actual sizes of the discs that are attached?
3. The above code seems to imply that the same two drives are always attached...is that correct? It seems like I will not be able to swap drives around on the DNS like I can with Windows. I'd have to update the fun_plug to include any changes, correct?
4. I assume I take the code for my fun_plug, save it from a linux-compatible editor (I'm using EditPad Lite) and name it (usb_plug), copy it to the DNS next to where I have fun_plug, CHMOD usb_plug to 777, plug in the USB drive and then reboot. Is that corerct? Is CHMOD to 777 sufficient to ensure that it executes on each reboot of the DNS?
5. Working from the above example, if I'll have one 200 MB drive, I assume I would set up my fun_plug as below...is this correct? And to ask again, do I need to do anything w/ntfs.ko in the lines below?
#
# fun_plug for sharing one 200 MB external USB Disc
#
DIR=/mnt/HD_a2
if [ ! -d lnx_bin ]
then
exit 0
fi
if [ -f $DIR/lnx_bin/usb-storage.ko ]
then
insmod $DIR/lnx_bin/usb-storage.ko
dmesg > $DIR/lnx_bin/logs/dmesg.out
mkdir $DIR/usb_200
mount /dev/sdd1 $DIR/usb_200
fi
And, if I was going to occassionally going to attach a 300 MB NTFS USB disc, could I add lines for it and just let them error out if the disc was not connected at that time? Restart and connect it, since the lines for it would be there?
#
# fun_plug for sharing one 200 MB external USB Disc
#
DIR=/mnt/HD_a2
if [ ! -d lnx_bin ]
then
exit 0
fi
if [ -f $DIR/lnx_bin/usb-storage.ko ]
then
insmod $DIR/lnx_bin/usb-storage.ko
dmesg > $DIR/lnx_bin/logs/dmesg.out
mkdir $DIR/usb_200
mkdir $DIR/usb_300
mount /dev/sdd1 $DIR/usb_200
mount /dev/sdd1 $DIR/usb_300
fi
Thanks very much...hope I don't look too stoopid here... Been reading and pondering, but this is not obvious stuff...to me.
Offline
Like I said in the other thread, I'm no linux guru - but I do have a little working knowledge.
1 - I have no idea if you do need it, but if you do, just put another insmod line directly below the first one - insmod $DIR/lnx_bin/ntfs.ko
2 - I think you're right, they need to be the same - they are names, making the name the same as the size makes then easier to remember.
3 - I don't think you can hot swap like you can with Windows, you might need to unmount, swap and then remount to avoid corruption.
4 - Not certain, but I'd call it fun_plug.
5 - There are a couple of possible trouble spots
Here's where I think you could get into trouble...
The command "mount /dev/sdd1" - is an instruction to mount the first partition on the fourth disk drive, and assuming you have two drives in the DNS-323, it is going to be incorrect, it will need to be "mount /dev/sdc1", if you have only one internal disk, it might have to be "mount /dev/sdb1"
If you do any reading - you may discover that "sda" refers to the first SCSI disk, and sdb the second SCSI disk - this can be slightly confusing when you consider that you have no SCSI disks, but SATA and USB - don't let it confuse you, linux thinks SATA and USB are SCSI. If the drives are ATA, they will be hda, hdb and so on.
By the way - you can also do this interactively once you have telnet access and the necessary kernel modules loaded, before you create the script.
The heart of the script are these lines
===========================
insmod $DIR/lnx_bin/usb-storage.ko
dmesg > $DIR/lnx_bin/logs/dmesg.out
mkdir $DIR/usb_200
mount /dev/sdd1 $DIR/usb_200
===========================
Line 1 - insmod etc. is an instruction to install the usb-storage.ko kernel module
Line 2 - dmesg etc. is an instruction to output the device messages tp a log file called dmesg.out in a folder called /lnx_bin/logs/dmesg.out,
Line 3 - creates a directory or mount point called usb_200
Line 4 - mounts the first partition on the fourth disk to the previously created mount point.
Offline
Thanks, really appreciate it. I'm learning to fish, slowly but surely, thanks to the wiki, some net searching/reading, and help here from folks like you...thanks.
The sdd, sdb, etc., info is very helpful, appreciate the short primer on that.
Assuming I can get my kids through thier homework projects in a timely manner I'll give this a whirl a little later.
Oh - one question. I already have fun_plug installed (the one that is provided via the wiki...so I can't call this one by the same name, I presume. Can I call it usb_plug, or does this have to become a part of my existing fun_plug?
So what I'd end up using would be:
#
# fun_plug for sharing one 200 MB external USB Disc
#
DIR=/mnt/HD_a2
if [ ! -d lnx_bin ]
then
exit 0
fi
if [ -f $DIR/lnx_bin/usb-storage.ko ]
then
insmod $DIR/lnx_bin/usb-storage.ko
# Unclear if I need ntfs.ko or not, likely will try it first w/it commented out
# insmod $DIR/lnx_bin/ntfs.ko
dmesg > $DIR/lnx_bin/logs/dmesg.out
mkdir $DIR/usb_200
# Comment out second drive for now
# mkdir $DIR/usb_300
mount /dev/sdc1 $DIR/usb_200
# Comment out second drive for now
# mount /dev/sdd1 $DIR/usb_300
fi
Last edited by DNS-323 Talker (2007-05-24 05:30:04)
Offline
I'm guessing that the DNS-323 specifically looks for a script named fun_plug - but I could be wrong. Either incorporate the additional lines into the existing fun_plug or create a second script with a name of your choice and call it from fun_plug.
Offline
Ahhh...it's sinking in slowly...any file called fun_plug is run on boot...I guess I didn't realize that...I thought the original fun plug I had created had to keep running on each boot.
Off to do some testing...
Offline
Well, no joy. Tried running it via fun plug and that didn't work...tried typing the commands from the wiki manually in a telnet session and it seemed like the disc finally mounted, (had to insmod the ntfs.ko) but nothing ever showed up in My Comptuer...oh well...read more, try more...
Offline
You're actually working on something I was just thinking about - I got as far as clicking on the link to download the usb-storage.ko module, and getting a page not found error, I posted here and no -one responded - where did you find it? That and the the ntfs.ko kernel module?
Once I have those I'll take a stab at it and we'll see if we can help each other through - I can also tap my son as a source of additional linux expertise if/when needed.
Offline
fordem wrote:
where did you find it? That and the the ntfs.ko kernel module?
Offline
Thanks fonz
Offline
DNS-323 Talker - here's what I came up with so far - and I'm working interactively from the telnet prompt, with a USB flash drive.
insmod /mnt/HD_a2/lnx_bin/usb-storage.ko - this installs the kernal module
mkdir /mnt/HD_a2/lnx_bin/usb_test - this creates a folder in lnx_bin that serves as a mount point
mount /dev/sdc1 /mnt/HD_a2/lnx_bin/usb_test - this mounts the USB flash drive at the mount pointed created above
I then attempted to display the files on the flash drive
ls /mnt/HD_a2/lnx_bin/usb_test
and all were visible - I could also navigate to the usb_test folder using Windows Explorer and see my files and open them etc.
I did not use ntfs.ko which may just be because my flash drive is probably formated fat32 - I don't have a USB external drive hand to test with an NTFS formatted volume, perhaps in a day or two I'll get around to that.
If you compare my commands to yours , you'll realise that I skipped some of the shortcuts used - DIR=/mnt/HD_a2 - and typed the entire string in each command, and also did not perform some of the tests - if [ ! -d lnx_bin ] etc. - a properly written script will test to ensure specific conditions are met, where as I was just interested in a quick and dirty "proof of concept".
before disconnecting you need to issue an unmount command - for safety sake
umount /dev/sdc1
Hopefully my results will get you a little further in your quest - let me know how it goes.
Offline
Excellent...thanks. One big "aha" from above is that I shouldn't expect any icon to show up in my compute for the drive...I had assumed that maybe I'd see a new networked drive show up, and didn't get that I'd have to browse for the files via the mount point/folder.
Oh why, why, did I waste my youth in DOS, never to wander the rich fields of Linux... ;-)
I'll try your simplified steps and see what I can see in the mount folder...
Offline
Gave your short steps a quick try...didn't work, the mount fails for some reason. "Mounting /dev/sdc1 on /mnt/HD_a2/lnx_bin/usb_1 failed."
When I tried the insmod commands again this AM, it reported that the file already existed (I assume due to previous insmod commands). Tried rmmod to remove it to start over, but got a "REsource temporarily unavailable" response. don't know if this even matters...I presume once inserted I can leave those modules alone.
So: #1 below said it was already there...#2 worked fine (creating directory) and #3 failed.
fordem wrote:
1. insmod /mnt/HD_a2/lnx_bin/usb-storage.ko - this installs the kernal module
2. mkdir /mnt/HD_a2/lnx_bin/usb_test - this creates a folder in lnx_bin that serves as a mount point
3. mount /dev/sdc1 /mnt/HD_a2/lnx_bin/usb_test - this mounts the USB flash drive at the mount pointed created above
Next step is to format a drive in my USB enclosure to FAT32 so I can see if NTFS is the problem. My son took my only USB key to school recently and lost it, so the quick and easy way isn't availble at the moment...
Thanks for the help, I'll keep plugging away. Fonz...if you know whether the ntfs issue is the key reason, appreciate any comments. I got nfts.ko from http://dev.skcserver.de/dns323/
Offline
Start by rebooting the NAS - if you don't have the commands in the fun_plug, it won't install the kernel module, the folder created in step #2 will remain.
When my daughter gets home from work I'll borrow her USB external drive and let you know what happens.
Offline
I was looking at dmesg and found this noting maximum mount count reached...anything to worry about? Is each mount attempt failing because of this error? umount doesn't allow me to unmount anything...the /dev/sdc1 syntax above fails with error ("invalid argument"). A umount command pointed at the mount point rather than device tells me the mount point doesn't exist even though it does and I can do an "ls" on it...strange.
dmesg wrote:
BusyBox v1.5.0 (2007-05-06 16:42:17 CEST) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
/ # mount /dev/sdc1 /mnt/HD_a2/lnx_bin/usb_1
mount: mounting /dev/sdc1 on /mnt/HD_a2/lnx_bin/usb_1 failed
/ # dmesg
<snip>
raid1: raid set md0 active with 2 out of 2 mirrors
EXT2-fs warning: maximal mount count reached, running e2fsck is recommended
Link Layer Topology Discovery Protocol, version 1.05.1223.2005
dev is <NULL>
usb 1-1: new high speed USB device using ehci_platform and address 2
/ #
Mount is also failing w/a 15gig FAT 32 drive in the USB enclosure attached to the DNS-323....arghhhh
Offline
Just to be sure. Can you post contents of /proc/paritions when the usb stick/disk is attached? Have you had a look at this thread?
http://dns323.kood.org/forum/p3061-2007 … html#p3061
The DNS doesn't seem to recognize all types of USB devices. I have two usb sticks, one is recognized (the older one), and one is not (the newer one).
Offline
Fordem...thanks. I've rebooted to clear things out and start fresh. Commands are not in my fun_plug, as I'm still not quite sure how to add them to it...another path to figure out.
Fonz...I'll try proc/partitions now and see what I get.
With the USB drive off I get the following, the same as in the post you pointed me at:
proc/partitions wrote:
/ # cat /proc/partitions
major minor #blocks name
7 0 5120 loop0
31 0 64 mtdblock0
31 1 64 mtdblock1
31 2 1536 mtdblock2
31 3 6336 mtdblock3
31 4 192 mtdblock4
8 0 488386584 sda
8 1 530113 sda1
8 2 487853887 sda2
8 16 488386584 sdb
8 17 530113 sdb1
8 18 487853887 sdb2
When I insmod usb-storage.ko and ntfs.ko and then connect the usb drive the cat /proc/partitions adds two entries!!
8 32 78150744 sdc
8 33 78148161 sdc1
Yay!! Progress...
Trying mount command:
mount /dev/sdc1 /mnt/HD_a2/lnx_bin/usb_1
No error!!!
Uh oh...new problem. When I try to browse (from telnet or Windows GUI) I get errors.
- ls lnx_bin/usb_1 - I get "System Volume Information" in blue, but nothing else displays
- Browsing from Windows GUI: when I double-click on the usb_1 directory I get error message - "G:\lnx_bin\usb_1 is not accessible" Access is denied.
I checked properties and the usb_1 directory CHMOD is 500...read/execute for owner, no write for owner, no access for group or public. I tried to change properties using CHMOD (CHMOD a+wx usb_1) but got error message: CHMOD: usb_1: Read-only file system
I tried umoun to unmount and then created a new directory (usb_80) and mounted to that directory with the same results.
So I think I'm closer, but still no cigar....but at least I'm a little more optimistic now...
Offline
OK...a step further!!
Tried another USB enclosure/drive (same brand enclosure, 250 Gig drive) and mounted it successfully.
Entered the usb_80 directory and am able to use ls to see a list of files/direcories! Very nice.
Still can't get to anything from the Windows My Computer GUI...same access denied. Must be a permissions thing, and CHMOD won't let me change the attributes of the directory...
So, um, help!
Offline
Mounting ntfs is a bit tricky. Also, there's no ntfs write support until very recent linux kernels. Since I don't have any ntfs drives/sticks, I haven't tested the following (umount, first):
mount -o umask=0222 /dev/sdc1 /mnt/HD_a2/lnx_bin/usb_1
This should adjust permissions to dr-xr-xr-x.
Offline
Thanks. fonz...appreciate the additional info on NTFS support. I'll give that a shot later when I get home.
So are you saying that 1) The DNS-323 does not support writes to NTFS USB drives, or 2) That it may not, depending on what kernel the DNS-323 has, or 3) That it does support NTFS writes but since linux kernels just got this support recently that it may be a bit twitchy?
Offline
OK...that's good to know. Thanks.
Offline
I think, ntfs write support was added around 2.6.16. So either D-Link upgrades the kernel or someone else make a recent kernel work on the box... we'll see what happens first :-)
Offline
fonz wrote:
Mounting ntfs is a bit tricky. Also, there's no ntfs write support until very recent linux kernels. Since I don't have any ntfs drives/sticks, I haven't tested the following (umount, first):
Code:
mount -o umask=0222 /dev/sdc1 /mnt/HD_a2/lnx_bin/usb_1This should adjust permissions to dr-xr-xr-x.
You win the prize!! I used your modified mount statement above and am able to browse the directory from Windows Explorer!!!
Now if I could only have write capability so I can do what I planned, hang a USB drive off the DNS-323 to do a backup to an NTFS drive that I can then take to work to have an off-site backup of my data. Here's hoping kernel upgrades come along soon...
So if I want to have these mounts persist across reboots, can I just add the commands to the end of the fun_plug file (see below...bolded command would be added to existing fun_plug file.
modified fun_plug file wrote:
VOL1=/mnt/HD_a2
VOL2=/mnt/HD_b2
FUNPLUGTAR=${VOL1}/fun_plug.tar
FUNPLUGDIR=${VOL1}/fun_plug.d
ETCDIR=${FUNPLUGDIR}/etc
BINDIR=${FUNPLUGDIR}/bin
LOGDIR=${FUNPLUGDIR}/log
LOGFILE=${LOGDIR}/fun_plug.log
PATH=${BINDIR}:${PATH}
export VOL1
export VOL2
export FUNPLUGDIR
export ETCDIR
export BINDIR
export LOGDIR
export LOGFILE
export PATH
umask 022
mkdir -p ${FUNPLUGDIR} ${LOGDIR}
echo "**** fun_plug script for DNS-323 (2007.04.03 tp@fonz.de) ****" >>${LOGFILE}
date >>${LOGFILE}
if [ -r "${FUNPLUGTAR}" ]; then
echo "* Extracting ${FUNPLUGTAR}..." >>${LOGFILE}
/bin/tar -xv -f ${FUNPLUGTAR} -C ${FUNPLUGDIR} 1>>${LOGFILE} 2>&1
echo "* Deleting ${FUNPLUGTAR}..." >>${LOGFILE}
rm -f ${FUNPLUGTAR}
fi
if [ -d "${FUNPLUGDIR}/start" ]; then
for fun_plug_script in ${FUNPLUGDIR}/start/*.sh; do
if [ -x "${fun_plug_script}" ]; then
echo "* Running ${fun_plug_script}..." >>${LOGFILE}
${fun_plug_script} 1>>${LOGFILE} 2>&1
else
echo "* ${fun_plug_script} not executable..." >>${LOGFILE}
fi
done
else
echo "* ${FUNPLUGDIR}/start: Directory not found"
fi
mount -o umask=0222 /dev/sdc1 /mnt/HD_a2/lnx_bin/usb_80
echo "* Done" >>${LOGFILE}
Last edited by DNS-323 Talker (2007-05-25 01:22:56)
Offline
Better create a new script /mnt/HD_a2/fun_plug.d/start/mount-sdc1.sh:
#!/bin/sh insmod /..../usb-storage.ko insmod /..../ntfs.ko mount -o umask=0222 /dev/sdc1 /mnt/HD_a2/lnx_bin/usb_80
Though I don't think you want it this way....
- you need to umount the drive before you detach it from the dns323
- you don't want to reboot after re-attaching it, right?
Offline
fonz wrote:
Better create a new script /mnt/HD_a2/fun_plug.d/start/mount-sdc1.sh:
Code:
#!/bin/sh insmod /..../usb-storage.ko insmod /..../ntfs.ko mount -o umask=0222 /dev/sdc1 /mnt/HD_a2/lnx_bin/usb_80Though I don't think you want it this way....
- you need to umount the drive before you detach it from the dns323
- you don't want to reboot after re-attaching it, right?
Trying to think before I answer...hmmm
If I want to detatch it during a session, I'd use the umount command to do that
I'd also have to remember to umount before I do any reboots of the DNS-323.
In both cases it's a manual process that I'll have to remember to do, right? For now, since I only have read access to the drive, I would think (hope!) that I couldn't do much to the drive if I did forget to umount before restarting the DNS...
If there is a way to automatically umount before reboot, that's the only improvement I can think of. What (obvious) point am I missing here...sorry.
Last edited by DNS-323 Talker (2007-05-25 02:16:48)
Offline