DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#76 2009-05-24 18:27:16

Goldie
New member
Registered: 2009-05-21
Posts: 3

Re: Mount a USB disc...need just a little help to finish, please!

fonz wrote:

Edit options, disk and mountp (mountpoint). Uncomment ntfs if you need. It expects the kernel modules in fun_plug.d/bin/modules/ (instead of lnx_bin).

Since I don't have an external USB disk, I tested with a USB memory stick.

I would like to know if the modules should be placed somewhere else than lnx_bin ?
I have looked for fun_plug.d/bin/modules and can not find it.

I can find /mnt/HD_a2/ffp/   but nothing in any one of those directories under

Last edited by Goldie (2009-05-24 19:13:48)

Offline

 

#77 2010-01-13 10:12:56

mickwish
Member
Registered: 2010-01-13
Posts: 5

Re: Mount a USB disc...need just a little help to finish, please!

Hi guys

This is a great thread, and the mounting of an external HDD via a hub works great using the instructions. But I now have a problem that I hope someone can help me with. Up until now I had been using a Samsung 250GB HDD in an external case attached to a Logitech 4 port hub, and had no problems accessing files. I have upgraded to a Seagate External 1TB drive, and no matter how I have formatted the partitions (single 1TB partition, 4 250GB partitions) I am getting read errors, almost randomly, when accessing files, either locally or via smb. Partitions will mount, read and write files, but then seems to fail. If I unmount and remount I can access files again immediately, without an e2fsck even! I am wondering if it is because some Seagate drives will go into "sleep" mode.

Any ideas? I am loath to fork out another $100 for another 1TB external drive just because I can't get this one to work!

Thanks
Mick

Offline

 

#78 2010-01-16 12:34:30

mickwish
Member
Registered: 2010-01-13
Posts: 5

Re: Mount a USB disc...need just a little help to finish, please!

OK, I think I have this licked now. You have to use Seagate Manager (FreeAgent Tool) to set the sleep time to "Never". Must do this in Windows or Mac (no "nix version, thanks Seagate!) with the drive attached, then it should remember this setting and never put the drive to sleep. That should hopefully solve my problem - if it doesn't I will be back! smile

Cheers
Mick

Offline

 

#79 2010-02-24 23:33:15

caust1c
Member
Registered: 2010-01-03
Posts: 35

Re: Mount a USB disc...need just a little help to finish, please!

mickwish wrote:

OK, I think I have this licked now. You have to use Seagate Manager (FreeAgent Tool) to set the sleep time to "Never". Must do this in Windows or Mac (no "nix version, thanks Seagate!) with the drive attached, then it should remember this setting and never put the drive to sleep. That should hopefully solve my problem - if it doesn't I will be back! smile

Cheers
Mick

Hey I am using a Seagate 1.5TB external with fun_plug.  What file-system were you using?  I have formatted to a single ext3 partition and have had no problems reading or writing thus far (currently copying over a few hundred gigabytes).  I haven't noticed the drive 'sleep' but I can't really hear it where it is located anyways.

Did you find doing that sorted your issues incase I have to do the same?  Was the program making a modification to the firmware or the filesystem?

Offline

 

#80 2010-02-25 08:55:58

caust1c
Member
Registered: 2010-01-03
Posts: 35

Re: Mount a USB disc...need just a little help to finish, please!

I actually think I have a similar problem now.  When my Seagate USB goes to sleep, if I try to access it through samba it somehow gets changed to read-only.  If I kill smbd, umount the Usb and then remount it goes back to RW.  Start samba again and all is fine.

I'd like to keep letting the drive go to sleep but any idea how to let it spin-up without getting switched to read-only?

Offline

 

#81 2010-02-25 09:58:04

mickwish
Member
Registered: 2010-01-13
Posts: 5

Re: Mount a USB disc...need just a little help to finish, please!

Using the Seagate utility to write to the USB drives firmware worked for me to stop it going to sleep. I don't know if you are having the same issue or not. If it asleep you shouldn't be able to read the drive at all I wouldn't think.

Cheers
Mick

Offline

 

#82 2010-02-25 10:31:08

caust1c
Member
Registered: 2010-01-03
Posts: 35

Re: Mount a USB disc...need just a little help to finish, please!

mickwish wrote:

Using the Seagate utility to write to the USB drives firmware worked for me to stop it going to sleep. I don't know if you are having the same issue or not. If it asleep you shouldn't be able to read the drive at all I wouldn't think.

Cheers
Mick

No, when I attempt to access it, I hear it spin up but it has then become read-only.  I tried changing the mount option to "-o,users" to apparently allow any user to remount... just tried and it still changed drive to read-only after spin-up.

Offline

 

#83 2010-02-25 10:37:58

mickwish
Member
Registered: 2010-01-13
Posts: 5

Re: Mount a USB disc...need just a little help to finish, please!

Why not try and change it to not sleeping and see if it fixes it? You will need to plug it in to a windows box to do so, but it will at least show you why it is doing it if it fixes it. Then you could try and see if Samba can set some kind of pause before it accesses the drive to allow you to turn sleep mode back on. Maybe ask that question in a Samba forum somewhere.

Cheers
Mick

Offline

 

#84 2010-03-17 06:13:58

jalin2
Member
Registered: 2008-08-24
Posts: 6

Re: Mount a USB disc...need just a little help to finish, please!

Hi caust1c,

Just following up to see if you came up with a solution which works with the hard drive in sleep mode.


caust1c wrote:

mickwish wrote:

Using the Seagate utility to write to the USB drives firmware worked for me to stop it going to sleep. I don't know if you are having the same issue or not. If it asleep you shouldn't be able to read the drive at all I wouldn't think.

Cheers
Mick

No, when I attempt to access it, I hear it spin up but it has then become read-only.  I tried changing the mount option to "-o,users" to apparently allow any user to remount... just tried and it still changed drive to read-only after spin-up.

Offline

 

#85 2010-05-31 16:01:17

Okadz
Member
Registered: 2010-05-28
Posts: 11

Re: Mount a USB disc...need just a little help to finish, please!

Hi everyone, great thread with heaps of details and options to try, of which i have done most.

I'm having trouble connecting an external usb drive to my  DNS323.
I have followed the wiki post http://dns323.kood.org/howto:external_drive
I have read heaps and heaps of threads here  as well as many many others on other forums.
     
The main problem is I cannot mount my drive
  “mount -t vfat -o umask=0 /dev/sdc1 /mnt/HD_a2/usb_1” Failed: no such device or address.

It does not seem to get listed as /dev/sdc1 in “ cat /proc/partitions “   ***thus being my problem***
major minor  #blocks  name

   7     0       5744 loop0
  31     0         64 mtdblock0
  31     1         64 mtdblock1
  31     2       1536 mtdblock2
  31     3       6336 mtdblock3
  31     4        192 mtdblock4
   9     0 1415583424 md0
   8     0 1465138584 sda
   8     1     530113 sda1
   8     2 1415583540 sda2
   8     3   48508267 sda3
   8     4     514080 sda4
   8    16 1465138584 sdb
   8    17     530113 sdb1
   8    18 1415583540 sdb2
   8    19   48508267 sdb3
   8    20     514080 sdb4
   9     1   97016320 md1

insmod /mnt/HD_a2/lnx_bin/usb-storage.ko   seems to install fine and if I plug  and unplug my usb drive it is recorded in “ dmesg”.

I have tried 4 diff drives all fat32 , two - usb thumb drives, one - 2.5” 40gb caddy usb powered but secondary power plugged into diff external source.  One - 3.5” externally power 250gb caddy. All with the same results.

   
Initializing USB Mass Storage driver...
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
usb 1-1: USB disconnect, address 2
sxuptp: deregistered the interface dev-001/002/0
usb 1-1: new high speed USB device using ehci_platform and address 3
sxuptp_driver: VID:0x0951 PID:0x1603
sxuptp_driver: M(0x01): Kingston
sxuptp_driver: P(0x02): DataTraveler 2.0
sxuptp_driver: S(0x03): 811000000000000045B46335
sxuptp_driver: * If#=0 Alt=0 #EPs=2 Cls=0x08 SubCls=0x06 Prot=0x50
sxuptp: registered the new interface dev-001/003/0
usb 1-1: USB disconnect, address 3      ****** this is where i unplug and replug usb drive ****
sxuptp: deregistered the interface dev-001/003/0
usb 1-1: new high speed USB device using ehci_platform and address 4
sxuptp_driver: VID:0x0951 PID:0x1603
sxuptp_driver: M(0x01): Kingston
sxuptp_driver: P(0x02): DataTraveler 2.0
sxuptp_driver: S(0x03): 811000000000000045B46335
sxuptp_driver: * If#=0 Alt=0 #EPs=2 Cls=0x08 SubCls=0x06 Prot=0x50
sxuptp: registered the new interface dev-001/004/0


So I belive its detecting the drives but it never gets listed as a drive in “cat /proc/partitions “ so I cannot ever mount it.  Does this mean none of them are compatible?
If it can detect "Kingston - Datatraveler 2.0" does that not confirm it can read/recognise the device?

Im running  Fun_plug 0.5, firmware 1.08   Linux version 2.6.12.6-arm1 (tim@SWTEST2) (gcc version 3.3.3) #32 Wed Jun 24 15:19:48 CST 2009
CPU: ARM926EJ-Sid(wb) [41069260] revision 0 (ARMv5TEJ)

Im not sure if there needs to be a certain usb-storgae.ko module or not, I have tried ones with and without debugging!.

Some questions

1. Does it matter how I transfer the files to the NAS. I have been downloading – copy - paste via windows. Does this matter?
2. Is there a specific version of usb-storage.ko i need for my setup. i.e  firmware 1.08. i noticed not many are running this version, most point towards 1.03 or 1.06.

Any help would be great, im new to a DNS323 and have leanrt Linux code over the last two weeks I’ve been at this (yeah that long).

Please help….. please

Okadz


OMG  SUCCESS-----  well its such a good thread and it all seems so easy to do, so why not start again. Reset defaults, wiped my drives clean, re-formated again (backed up of course), followed instructions and SUCCESS  --   I now have sdc1. and i can mount it.

Cheers all

Last edited by Okadz (2010-06-01 09:45:32)

Offline

 

#86 2010-10-25 02:42:57

InBonobo
Member
From: Toronto
Registered: 2009-01-18
Posts: 34
Website

Re: Mount a USB disc...need just a little help to finish, please!

This is a good thread, indeed, though I have not had any problems mounting USB drives. I am surprised to see how many people seem to be having problems with Seagate..

I just had a RAID 0 fail on me and have yet to start recovering it - I may not even be able to. AAAARGH!

@sirshadow: Why do you need to look at the drive through the webpage?
My guess is that a USB connection is heavy on the resources of weak hardware and the box simply cannot service all requests well when USB is activated.

Also, why do you need to reboot? Have you tried rebooting from the prompt?


1 DNS-323, HW B1, 2 x 2TB WD Black (WD2001FASS), fw 1.09, fun_plug 0.5
1 DNS-321, HW A2, 2 x 1TB Seagate Barracuda 7200.11 (currently failed)
Here's my Hacking DNS-323 and DNS-321 NAS Guide smile

Offline

 

#87 2011-03-03 11:20:08

Gef
Member
Registered: 2009-06-15
Posts: 9

Re: Mount a USB disc...need just a little help to finish, please!

Well, I've been a troll for about 18 months here - followed the instructions, with help from a mate with telnet and linux knowledge way back then.  And all has been running smoothly thanks to Fonz and others in this thread!

Until a couple of nights ago.  Here is the story. I hope someone can help...

I have a WD ext HDD connected to the back of the Dlink-323 and mapped to ('mounted at') VideoLibrary on HD_a2.

MountHDD says:

   #!/bin/sh
      insmod /mnt/HD_a2/lnx_bin/usb-storage.ko
      sleep 15
      mount -t vfat -o umask=000 /dev/sdc1 /mnt/HD_a2/VideoLibrary

I've been having trouble getting files to copy to it, and found that if I turn off the Dlink, unplug the ext HDD and plug it into a desktop machine, I can copy files across.  So I've been doing that for months.

The trouble started a couple of nights ago.  It was late and I was in a hurry to copy some files onto the external HDD.  I think I must have been thinking Windows, not Unix.  I did not shutdown the Dlink before unplugging the ext HDD.  (And no, I didn't unmount it either.)

When I plugged the ext HDD into the desktop it was blank.  I powered down the Dlink, plugged it into it, and it was blank there too.  I solved the missing data with a boot sector recovery tool (for the curious, I used testdisk from www.cgsecurity.org), and the files are definitely there now.

Big phew, then I powered down the Dlink and plugged it back in.  I cannot see the contents at VideoLibrary.  That is the problem.  Turning the Dlink off and on doesn’t help.

I've gone to see whether all the relevant files are there, and tried the following:

  Telnet-ed in (via Putty).  Everything seems to be where it needs to be.  (I could not get "cd sdc1" to work from the dev folder, don't know whether that is normal.)

    Tried to unmount, using:  umount /dev/sdc1

      Response from Telnet:     umount: can't umount /dev/sdc1: Invalid argument

    Went to start folder and entered:    insmod /mnt/HD_a2/lnx_bin/usb-storage.ko

       Response from Telnet:    insmod: cannot insert '/mnt/HD_a2/lnx_bin/usb-storage.ko': File exists   (seemed to be a good sign)

    Then entered:   mount -t vfat -o umask=000 /dev/sdc1 /mnt/HD_a2/VideoLibrary

      Response from Telnet:    mount: mounting /dev/sdc1 on /mnt/HD_a2/VideoLibrary failed: Invalid argument


I don't know whether the restore process could have ‘changed’ either the fat type or changed the ‘drive label’ or however the drive is recognised by the Dlink.  Windows says the file system is FAT32, which I'm pretty sure is what it was before.

I'd be grateful for any help anyone can give here.  (Especially if you point out something obvious I have missed.)

...Geoff smile

Offline

 

#88 2011-03-04 11:07:38

nogi
Member
From: Heddesheim, Germany
Registered: 2010-03-31
Posts: 28

Re: Mount a USB disc...need just a little help to finish, please!

Gef wrote:

Tried to unmount, using:  umount /dev/sdc1

      Response from Telnet:     umount: can't umount /dev/sdc1: Invalid argument

    Went to start folder and entered:    insmod /mnt/HD_a2/lnx_bin/usb-storage.ko

       Response from Telnet:    insmod: cannot insert '/mnt/HD_a2/lnx_bin/usb-storage.ko': File exists   (seemed to be a good sign)

    Then entered:   mount -t vfat -o umask=000 /dev/sdc1 /mnt/HD_a2/VideoLibrary

      Response from Telnet:    mount: mounting /dev/sdc1 on /mnt/HD_a2/VideoLibrary failed: Invalid argument


I don't know whether the restore process could have ‘changed’ either the fat type or changed the ‘drive label’ or however the drive is recognised by the Dlink.  Windows says the file system is FAT32, which I'm pretty sure is what it was before.

I'd be grateful for any help anyone can give here.  (Especially if you point out something obvious I have missed.)

...Geoff smile

Telnet into the box and issue the command "fdisk -l" <-that's a small letter L for "list"
It will show you how linux sees the disks and partitions. It could be that
after the recovery of the partition table this disk is recognized as a superfloppy and then
it exists onlly /dev/sdc instead of /dev/sdc1.

- NoGi

Offline

 

#89 2011-03-04 12:09:00

dhub
Member
Registered: 2011-01-01
Posts: 112

Re: Mount a USB disc...need just a little help to finish, please!

Run a dmesg to see the kernel messages.  I find generally the kernel messages will at least give you some idea of the issue.

Offline

 

#90 2011-03-04 14:41:08

Gef
Member
Registered: 2009-06-15
Posts: 9

Re: Mount a USB disc...need just a little help to finish, please!

Awesome NoGi, thank-you for the tip.  "/dev/sdc1" had been changed to sdc5.  (sdc1 is still there, as Win95 Ext'd; and sdc5 is now there too, as Win95 FAT32.)  It's all working again.

(dhub, thanks for the tip.  I ran dmesg, and I couldn't make any sense of it, but since I got an outcome with sdc5, it's all good.)

...Geoff

Offline

 

#91 2011-05-19 15:52:13

RangaRich
New member
Registered: 2011-05-19
Posts: 4

Re: Mount a USB disc...need just a little help to finish, please!

Hi guys,

Just wondering if someone can help me, btw I have very limited knowledge of what I'm doing, so feel free to treat me as if I know nothing! I'm trying to mount the drive to my folder, however it keeps telling me my argument is invalid, and I can't work out why! I've added 'cat /proc/partitions' so you can see my usb drive is there ready to go. Thanks for the help!

root@dlink:~# cat /proc/partitions
major minor  #blocks  name

   7     0       5712 loop0
  31     0         64 mtdblock0
  31     1         64 mtdblock1
  31     2       1536 mtdblock2
  31     3       6336 mtdblock3
  31     4        192 mtdblock4
   9     0  973089024 md0
   8     0  488386584 sda
   8     1     530113 sda1
   8     2  486544590 sda2
   8     4     514080 sda4
   8    16  488385527 sdb
   8    17     530113 sdb1
   8    18  486544590 sdb2
   8    20     514080 sdb4
   8    32  293036184 sdc
   8    33  293033601 sdc1


root@dlink:~# mount -t vfat -o umask=0 /dev/sdc1 /mnt/HD_a2/usbdrive
mount: mounting /dev/sdc1 on /mnt/HD_a2/usbdrive failed: Invalid argument

Offline

 

#92 2011-05-19 17:21:57

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Mount a USB disc...need just a little help to finish, please!

What firmware are you using?

Can you post the output from "fdisk -l" so that we'll see if /dev/sbc1 has indeed a fat filesystem and also "cat /proc/filesystems" so that'll we could see that vfat is supported by the kernel.


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#93 2011-05-20 00:44:46

RangaRich
New member
Registered: 2011-05-19
Posts: 4

Re: Mount a USB disc...need just a little help to finish, please!

Thanks, here they are.


root@dlink:~# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               1          66      530113+ 82 Linux swap
/dev/sda2             131       60702   486544590  83 Linux
/dev/sda4              67         130      514080  83 Linux

Partition table entries are not in disk order

Disk /dev/sdb: 500.1 GB, 500106780160 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdb1               1          66      530113+ 82 Linux swap
/dev/sdb2             131       60702   486544590  83 Linux
/dev/sdb4              67         130      514080  83 Linux

Partition table entries are not in disk order

Disk /dev/sdc: 300.0 GB, 300069052416 bytes
255 heads, 63 sectors/track, 36481 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdc1               1       36481   293033601   7 HPFS/NTFS


root@dlink:~# cat /proc/filesystems
nodev   sysfs
nodev   rootfs
nodev   bdev
nodev   proc
nodev   sockfs
nodev   usbfs
nodev   pipefs
nodev   futexfs
nodev   tmpfs
nodev   eventpollfs
nodev   devpts
        ext3
        ext2
        cramfs
        squashfs
nodev   ramfs
        minix
        msdos
        vfat
nodev   nfs
nodev   autofs
nodev   rpc_pipefs

Offline

 

#94 2011-05-20 01:17:47

RangaRich
New member
Registered: 2011-05-19
Posts: 4

Re: Mount a USB disc...need just a little help to finish, please!

So....you were right, the file system wasn't fat32 it was exFat, my mistake. Converted to fat32 and all is working well, thanks for the help

Offline

 

#95 2011-05-20 06:24:04

RangaRich
New member
Registered: 2011-05-19
Posts: 4

Re: Mount a USB disc...need just a little help to finish, please!

So I'm now trying to create the script so the drives will mount when the dns boots. I've created the script and copied it to ffp/start but when i try to test the script it returns the following error. As you can see i also made sure its permissions were sorted. Any ideas?


root@dlink:~# cd /mnt/HD_a2/ffp/start
root@dlink:/mnt/HD_a2/ffp/start# ls
LOGIN.sh      kickwebs.sh   mount-usb.sh  portmap.sh    syslogd.sh
SERVERS.sh    lighttpd.sh   nfsd.sh       rsyncd.sh     telnetd.sh
inetd.sh      mediatomb.sh  ntpd.sh       sshd.sh       unfsd.sh
root@dlink:/mnt/HD_a2/ffp/start# ./mount-usb.sh
-sh: ./mount-usb.sh: not found
root@dlink:/mnt/HD_a2/ffp/start#


root@dlink:/mnt/HD_a2/ffp/start# ls -l
-rw-r--r--    1 root     root           52 Oct 25  2008 LOGIN.sh
-rw-r--r--    1 root     root           35 Oct 25  2008 SERVERS.sh
-rw-r--r--    1 root     root          203 Sep 30  2008 inetd.sh
-rw-r--r--    1 root     root          229 Apr 13  2009 kickwebs.sh
-rw-r--r--    1 root     root          223 Apr 13  2009 lighttpd.sh
-rw-r--r--    1 root     root          267 Apr 15  2008 mediatomb.sh
-rwsrwsrwt    1 root     root          127 May 20 09:04 mount-usb.sh
-rw-r--r--    1 root     root         1468 Apr 16  2008 nfsd.sh
-rw-r--r--    1 root     root          526 Mar  2  2009 ntpd.sh
-rw-r--r--    1 root     root          160 Apr 16  2008 portmap.sh
-rw-r--r--    1 root     root          224 Mar  3  2009 rsyncd.sh
-rwxr-xr-x    1 root     root          971 May 20  2009 sshd.sh
-rw-r--r--    1 root     root          383 Sep 30  2008 syslogd.sh
-rwxr-xr-x    1 root     root          169 Sep 30  2008 telnetd.sh
-rw-r--r--    1 root     root          998 Feb 27  2009 unfsd.sh

Offline

 

#96 2011-05-20 10:01:40

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Mount a USB disc...need just a little help to finish, please!

Permissions seems funky. Read about it here: http://linux.die.net/Intro-Linux/sect_03_04.html, especially the special modes (which makes little sense in this case, imho).

Last edited by scaramanga (2011-05-20 10:14:19)


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#97 2011-05-20 10:13:59

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Mount a USB disc...need just a little help to finish, please!

Updated the script. Previous script contained a serious flaw. See next post for details

btw, here's my usb mount script. I use it as my fun-plug.local script. Place in /ffp/etc/, which runs before the /ffp/start stuff so that it doesn't run into dependency issues, such as stuff running from /ffp/etc that need to access files on the USB drive. This can also be done in /ffp/start, but you need to manage the #PROVIDE #REQUIRE comments which is a chore especially if they get updated frequently (transmission, for example).

It has some nice(?) features:
1. Starts the kernel module (usb-storage.ko) if it hasn't already been started.
2. Wait till the usb-storage.ko finishes scanning for devices by monitoring the kernel message buffer, instead of simply waiting for 20 seconds. Will time-out after 120 seconds.
3. It finds a device that doesn't have any mounted partitions (from /dev/sda, /dev/sdb, /dev/sdc...), and mounts it's first partition. This has the benefit that the device isn't hard-coded. If you take out one of the HDDs and boot your NAS, /dev/sdc gets renamed to /dev/sdb. The script will still work.
4. The usual stuff you can find in my scripts: easy to change preferences such as ffp location, and other preferences (mount point, location of usb-storage.ko, etc), debug mode for a more verbose output if you run into problems.

Important: Since I formatted my USB drive as a single ext2 partition you'll probably need to make changes in the script for it to work

Code:

#!/bin/sh

# What this script does is load a kernel module that enables mouting USB HDDs.
# After the module was loaded, it searches for a device that hasn't been mounted
# and mounts it to on the designated location.
#
# It is safe to call this script multiple times: It checks if the kernel module
# has already been loaded before attempting to load it. If the device has already
# been mounted nothing will be done.
#
# IMPORTANT: This script makes several assumptions:
#            1. That there just one such device to mount.
#            2. That the device has one single partition.
#            3. That that partition is formated as an ext2 file-system.

############
# Settings #
############

# Set path to Fun_Plug files.
# Fun_Plug 3.0 or 4.0
# ffpPath=/mnt/HD_a2/fun_plug.d
# Fun_Plug 5.0
ffpPath=/ffp

usbMountPoint=/mnt/usb
usbMountFileSystemType=ext2
usbDeviceScanTimeOut=120

usbStorageKo="${ffpPath}/lib/modules/usb-storage.ko"

# Change this to true for verbose output
debug=false

#
# Commands
#
echoCmd="/bin/echo"
insmodCmd="/usr/sbin/insmod"
mkdirCmd="/bin/mkdir"
mountCmd="/bin/mount"
grepCmd="/bin/grep"
dmesgCmd="/bin/dmesg"
tailCmd="/bin/tail"
awkCmd="${ffpPath}/bin/awk"

# First, load the usb-storage.ko module, if it hasn't already been loaded.
if ! ${grepCmd} usb_storage /proc/modules > /dev/null ; then
    ${debug} && ${echoCmd} "installing kernel module usb-storage.ko"
    ${insmodCmd} ${usbStorageKo}

    # Poll dmesg output till the device scan is complete.
    ${debug} && ${echoCmd} -n "Waiting for device scan to complete."
    retryCount=${usbDeviceScanTimeOut}
    while [ ${retryCount} -gt 0 ]
    do
        ${dmesgCmd} | ${tailCmd} -n 5 | ${grepCmd} "usb-storage: device scan complete" > /dev/null
        if [ $? -eq 0 ]; then
            break;
        fi

        retryCount=$((${retryCount} - 1))
        sleep 1
        ${debug} && ${echoCmd} -n "."
    done
    if [ ${retryCount} -eq 0 ]; then
        ${echoCmd} "waiting for device scan aborted after ${usbDeviceScanTimeOut} seconds."
        exit 127
    fi
    ${debug} && ${echoCmd} " Done!"
else
    ${debug} && ${echoCmd} "Kernel module usb-storage.ko was already installed."
fi

# Second, find the device that has no mounted partitions. That is our USB device.
for device in $( ${awkCmd} '/sd[a-z]$/{print $4}' /proc/partitions )
do
    if ! ${grepCmd} /dev/${device} /proc/mounts > /dev/null ; then
        ${debug} && ${echoCmd} "Does /dev/${device} has any partitions mounted? No!"
        usbDevice=/dev/${device}
    else
        ${debug} && ${echoCmd} "Does /dev/${device} has any partitions mounted? Yes."
    fi
done

# Third, mount it.
if [ -n ${usbDevice} ] ; then
    usbPartition=${usbDevice}1
    ${mkdirCmd} -p ${usbMountPoint}

    ${debug} && ${echoCmd} "Mounting ${usbPartition} on ${usbMountPoint}"
    ${mountCmd} -t ${usbMountFileSystemType} ${usbPartition} ${usbMountPoint}
fi

Last edited by scaramanga (2011-06-04 21:52:04)


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#98 2011-06-04 16:18:56

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Mount a USB disc...need just a little help to finish, please!

It seems like the busybox implementation of tail was changed between firmware 1.08 and 1.10b7. This caused script I posted in the previous post to no longer works.
Even worst, because of bad programming on my part it is stuck in an infinite loop. Not only that: if you followed my example and used it as your /ffp/etc/fun_plug.local, this script never ends so ffp never gets to run the /ffp/start/ scripts, which means you're left without telnet/ssh access. That's pretty bad.

If that happens to you, to fix that, edit the fun_plug script:

Code:

# run fun_plug.local, if present
#if [ -x /ffp/etc/fun_plug.local ]; then
#    echo "* Running /ffp/etc/fun_plug.local ..."
#    /ffp/etc/fun_plug.local
#fi

and comment-out the lines of code the execute fun_plug.local.
Now reboot the unit and you'll gain telnet/ssh access again.

I've now replaced the script with a fixed version in the previous post.

Sorry about that.

Last edited by scaramanga (2011-06-04 21:54:19)


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB