D-Link Forums

The Graveyard - Products No Longer Supported => D-Link Storage => ShareCenter® Add-on Applications => Topic started by: Schnaaa on February 15, 2013, 12:32:01 AM

Title: Tutorial: fun_plug 0.7 running off usb stick
Post by: Schnaaa on February 15, 2013, 12:32:01 AM
Since i spend a few hours to figure this one out because i couldn't find a guide specifically for the DNS-320L i decided to write up this little tutorial on how to get fun_plug running off an usb stick.

I hope it is ok to post this here since it is not really officially supported by D-Link and you will probably void your warranty by installing fun_plug. I decided to go with the DNS-320L because i found out about fun plug. Otherwise i probably would have bought something different and more expensive. So if you ask me fun_plug is really a great addition like the open source firmwares are to many compatible routers.

When i was looking for help to make it work this forum came up quite often in my search so maybe it will help some folks in the future and save them some time.
Before you start i must point out that i will probably not be able to help you out with any problems you may encounter during the process. I just registered here to post this guide. If you haven't done anything with unix or terminal in your life before you might want to ask someone to help you but then again you would probably not bother installing fun_plug anyway.

I would also recommend to install nano or midnight commander via slacker to make editing files easier. I always struggled with vi.


I tested this guide with a friend and it worked for him, so i hope it also does for you.

Anyway enough blahblah - let's go:

First of all you have to follow the standard fun_plug to hdd installation guide which can be found here: http://nas-tweaks.net/371/hdd-installation-of-the-fun_plug-0-7-on-nas-devices/ (http://nas-tweaks.net/371/hdd-installation-of-the-fun_plug-0-7-on-nas-devices/)

On the DNS-320L the ssh server is a bit tricky
you will have to add these lines in /ffp/start/sshd.sh just before the line “proc_start $command”:

chmod 700 /ffp/var/lib/sshd/
chmod 700 /ffp/etc/ssh/ssh_*

(this is probably not the best sshd practice but it works)

Make sure you have everything working properly before proceeding because you will just clone your installation to the usb stick.
The good thing ist that you will still have a working fun_plug installation on your harddrive in case your usb drive fails or your sneaky cat steals it.


I mostly copied and pasted a guide i found on the internet and made changes to make it work on the DNS-320L.
So the main credit goes to this great step by step tutorial: http://bernaerts.dyndns.org/dns325/242-dns325-ffp7-move-usb-key (http://bernaerts.dyndns.org/dns325/242-dns325-ffp7-move-usb-key) with the awesome bootstrapping script!


The main differences are:
- location of the usb device is different on the DNS-320L
- used file system (ext3)
- result: different location and filesystem in the bootstrapping script

IMPORTANT: Depending on your harddrive configuration the location of your usb stick and harddisk can be different.
I currently only have one harddrive installed.

commands to be entered in the terminal start with a "#" the other lines are output from the terminal for better orientation.

to start log in via ssh into your nas

1.1 Get Texteditor
# slacker -U
wait
# slacker -i
choose a nano package or mc package and install it - hit space to mark it and enter to install it


1.2. FORMAT THE USB KEY
# df
Filesystem 1K-blocks Used Available Use% Mounted on
%root% 9911 4490 4909 48% /
/dev/ram0 9911 4490 4909 48% /
...
/dev/sdb1 982096 926308 55788 95% /mnt/USB/USB1_b1 <- this is the line we are looking for.

so now we know that /dev/sdb is were the usb device is which gets automounted to /mnt/USB/USB1_b1

# umount /dev/sdb
# fdisk /dev/sdb

show commands: m
show partitions: p
delete partitions: d
make new partition: n
3x Enter
partion ID: t
partion ID: 83 for Linux
write table: w
.
.
# mke2fs –j /dev/sdb1 (creates ext 3 partition)
# reboot

check if usb gets automounted:
# df
/dev/sdb1 982096 926308 55788 95% /mnt/USB/USB1_b1


copy ffp directory:
# cp -a /mnt/HD/HD_a2/ffp /mnt/USB/USB1_b1

2.2. BOOTSTRAP /MNT/HD/HD_A2/.BOOTSTRAP/SETUP.SH
# mkdir /mnt/HD/HD_a2/.bootstrap
# chmod 777 /mnt/HD/HD_a2/.bootstrap
# nano -e /mnt/HD/HD_a2/.bootstrap/setup.sh
# chmod +x /mnt/HD/HD_a2/.bootstrap/setup.sh
# nano /mnt/HD/HD_a2/.bootstrap/setup.sh





the stuff below has to be copied inside -> /mnt/HD/HD_a2/.bootstrap/setup.sh:



Code: [Select]
#!/bin/sh
#
# Script .bootstrap/setup.sh
#
# Called by fun_plug to prepare USB key execution environment
# If everything is ok, fun_plug will run from the USB key
#
# 08/09/2012 - V1.0 by Nicolas Bernaerts

# Set default path
PATH=/usr/sbin:/sbin:/usr/bin:/bin
CONTINUE=1

# Environment variables. You may adjust them
FFP_HD="/mnt/HD/HD_a2"
FFP_USB="/mnt/USB/USB1_b1"
BCK_FLAG=${FFP_USB}/ffp/home/root/backup.do

# Check if a USB removable disk has been detected. If not, exit
if [ "$CONTINUE" -eq 1 ]; then
  # get the USB key partition
  USB_PARTITION=`df | grep "${FFP_USB}" | sed 's/^\([a-z0-9\/]*\).*$/\1/g'`

  # if partition has been mounted, remount it with noatime, else exit
  if [ -z "${USB_PARTITION}" ]; then
    CONTINUE=0
    echo "ERROR - USB device has not been detected as Mass Storage"
  else
    umount ${USB_PARTITION}
    mount ${USB_PARTITION} -t ext3 ${FFP_USB} -o noatime 2>/dev/null
    echo "USB - USB disk mounted under ${FFP_USB}"
  fi
fi

# Check presence of ffp directory at the USB key root. If not present, exit
if [ "$CONTINUE" -eq 1 ]; then
  if [ ! -d "${FFP_USB}/ffp" ] ; then
    CONTINUE=0
    echo "ERROR - Directory ${FFP_PATH} doesn't exist"
  else
    echo "USB - Directory ${FFP_PATH} present"
  fi
fi

# Check if a backup of USB key ffp directory is needed
if [ "$CONTINUE" -eq 1 ]; then
  if [ -f ${BCK_FLAG} ] ; then
    echo "USB - Backup of ${FFP_USB}/ffp needed. Target is ${FFP_HD}/ffp"
    rm -r ${FFP_HD}/ffp
    cp -a ${FFP_USB}/ffp ${FFP_HD}/ffp
    rm ${BCK_FLAG}
    echo "USB - Backup of ${FFP_USB}/ffp done. Backup flag deleted"
  fi
fi

# Declare USB key ffp directory as ffp root
if [ "$CONTINUE" -eq 1 ]; then
  FFP_PATH=${FFP_USB}/ffp
  echo "USB - Fun_Plug is running from USB key under ${FFP_PATH}, accessible thru /ffp"
else
  echo "ERROR - Fun_Plug root can't be moved to USB Key"
fi



ctrl + x and save the file

# reboot


# ls -la /ffp
lrwxrwxrwx 1 root root 16 Sep 6 22:36 /ffp -> /mnt/USB/USB1_b1/ffp (fun_plug is running off the usb key)
Every package you install will also be installed on the usb stick


If you want to keep your fun_plug on usb and the one on the harddrive synced create the file backup.do in root folder

# touch /ffp/home/root/backup.do
# reboot


booting will take a bit longer because the usb installation is copied back to your harddrive

Done!
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: fourfourfun on February 15, 2013, 03:32:43 AM
Curious, what exactly does fun_plug offer me as a user?
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: marse on February 15, 2013, 03:36:55 AM
Curious, what exactly does fun_plug offer me as a user?

From google.

http://nas-tweaks.net/371/hdd-installation-of-the-fun_plug-0-7-on-nas-devices/
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: tharos on August 16, 2013, 05:40:01 AM
Hello, i have a DNS320L and i have been using fun_plug for 6 months. I very happy with it. It works great, but it would be even greater if i could run fun_plug from an USB. I have followed all the steps above, but ssh doesn't work. i can access using telnet, but i am not able to access using ssh. I can't solve the permission problem. The same configuration works well from HD, but not in USB.

thanks.
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: dansdec on January 03, 2014, 07:05:36 AM
Hello, i have a DNS320L and i have been using fun_plug for 6 months. I very happy with it. It works great, but it would be even greater if i could run fun_plug from an USB. I have followed all the steps above, but ssh doesn't work. i can access using telnet, but i am not able to access using ssh. I can't solve the permission problem. The same configuration works well from HD, but not in USB.

thanks.

Same problem for me
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: pizzaking on January 03, 2014, 08:47:52 AM
The problem is, that the NAS makes all mounts world writable (chmod 777) by default. Therefor you need to suppress this command on startup, because the ssh sever won't accept world writeable private keys.

Fortunately there is a simple solution to the problem. Log in using telnet. Type:

Code: [Select]
chmod -R 700 /ffp/etc/ssh
Now you should be able to log ind using SSH, but if you do nothing, the directory will be world writeable again after next boot. To disable this "feature" install the uwchmod from Uli's repository by typing:

Code: [Select]
slacker -UaA uli:uwchmod
That should do the trick
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: pierre.huybens on January 04, 2014, 06:12:44 AM
Hi ,

I have follow all the steps but after reboot ffp is still on hard disk.
How can I know that the script  .bootstrap/setup.sh  is executed. Where is the output of the echo command ?
What could be my error ?


root@NasMapi:/mnt/USB/USB1_b1# df -k

Filesystem                1K-blocks      Used  Available Use% Mounted on
%root%                         8919      5436       3023  65% /
/dev/ram0                      8919      5436       3023  65% /
mdev                         124208         0     124208   0% /dev
/usr/local/tmp/image.cfs      42752     42752          0 100% /usr/local/modules
/dev/mtdblock5                 5120       480       4640  10% /usr/local/config
none                           2048       408       1640  20% /mydlink
/dev/sda4                    982936     34108     948828   4% /mnt/HD_a4
/dev/sda2                2881702700 614379668 2267323032  22% /mnt/HD/HD_a2
/dev/sdb1                   3847808    264488    3387856   8% /mnt/USB/USB1_b1


root@mynas:/mnt/USB/USB1_b1# ls -la /ffp
lrwxrwxrwx 1 root root 17 Feb 24  2013 /ffp -> /mnt/HD/HD_a2/ffp


root@mynas:/mnt/USB/USB1_b1# ls /mnt/USB/USB1_b1

ffp  lost+found


Thanks a lot

Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: pizzaking on January 04, 2014, 01:11:05 PM
Fun_plug i supposed to be on both the hard disk and the USB drive.

The fun_plug script, which is placed in the root of your hard disk, calls the script from /mnt/HD/HD_a2/.bootstrap/setup.sh (line 24).

Every echo output from this script should therefor be placed in the ffp.log in the root of your hard drive.

Which tutorial did you follow in your first attempt to install fun_plug? The part where the fun_plug script is being called my not be included in your version. For reference you can see mine here: http://pastebin.com/dfcaiNFf (http://pastebin.com/dfcaiNFf)

Could you maybe upload your ffp.log, so we can see what is going on? Are you sure the .bootstrap/setup.sh script is executable (chmod +x setup.sh)?
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: pierre.huybens on January 06, 2014, 11:24:31 PM
I found the following information in the log file :
Sat Jan  4 14:52:59 CET 2014

* Running /mnt/HD/HD_a2/.bootstrap/setup.sh ...
ERROR - USB device has not been detected as Mass Storage
ERROR - Fun_Plug root can't be moved to USB Key

The usb was properly inserted, and I run the script manually without error ; so I reboot the NAS and the ffp  was on the USB. Nice

Thanks
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: JavaLawyer on January 08, 2014, 08:24:09 AM
Call for support...  :)

I would like to create a Fun_Plug sticky post on our FAQ describing (1) purpose/functionality of Fun_Plug; (2) supported ShareCenter models; (3) Links to the official dev/support sites. Although D-Link does not officially support Fun_Plug, we can at least point ShareCenter to the correct third-party location for more information.

Are there any forum members who would like to take a stab at drafting the text for the FAQ entry?  ???
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: JavaLawyer on April 04, 2014, 07:01:37 AM
FAQ Entry: DNS ShareCenter - Fonz Fun_Plug (FFP) (http://forums.dlink.com/index.php?topic=58479.0)
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: Morphic on September 05, 2014, 05:36:58 AM
The problem is, that the NAS makes all mounts world writable (chmod 777) by default. Therefor you need to suppress this command on startup, because the ssh sever won't accept world writeable private keys.

Fortunately there is a simple solution to the problem. Log in using telnet. Type:

Code: [Select]
chmod -R 700 /ffp/etc/ssh
Now you should be able to log ind using SSH, but if you do nothing, the directory will be world writeable again after next boot. To disable this "feature" install the uwchmod from Uli's repository by typing:

Code: [Select]
slacker -UaA uli:uwchmod

That should do the trick

I can't get SSH to work after doing this and if I run via telnet:
Code: [Select]
slacker -UaA uli:uwchmod
I get
Code: [Select]
Updating package lists...
fetch: rsync -q 'rsync://ffp.inreto.de/ffp/0.7/arm/packages/CHECKSUMS.md5' '/ffp/funpkg/cache/s'
No packages found (status Iiu, pattern (^uli:.*uwchmod))

Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: Morphic on September 05, 2014, 10:12:08 AM
Ok so I figured out I had to install uli into slacker:

Code: [Select]
wget http://wolf-u.li/u/441 -O /ffp/bin/uwsiteloader.sh
chmod a+x /ffp/bin/uwsiteloader.sh
uwsiteloader.sh
Then select uli from the sites listed.

I can get ffp running off usb but debian is running but struggling with the chmod so cant access via SSH still.
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: Grosvenor on September 13, 2014, 04:56:08 AM
I can get ffp running off usb but debian is running but struggling with the chmod so cant access via SSH still.

If you enable remote backup server, you can SSH to the box without need for fun plug.
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: k1kfr3sh on February 08, 2015, 06:18:47 PM
It seems that the uwchmod hack does not work for the DNS-320l. At least with firmware 1.04b012
the script /usr/local/config/rc.init.sh is not executed at startup. Therefore the hook into this script and the exchange
of chmod with uwchmod is not executed.

The solution of chmod'ing sshd and its keys is not satisfying from my point of view e.g. all the scripts in /ffp/start/ are
executed because all are executed.

I therefore propose the following solution:
Changing .bootstrap/setup.sh to copy ffp to the USB drive. Although several 100M it is only done at startup.
Change your setup.sh to look like this:
Code: [Select]
#!/bin/sh
#
# Script .bootstrap/setup.sh
#
# Called by fun_plug to prepare USB key execution environment
# If everything is ok, fun_plug will run from the USB key
#
# 08/09/2012 - V1.0 by Nicolas Bernaerts

# Set default path
PATH=/usr/sbin:/sbin:/usr/bin:/bin
CONTINUE=1

# Environment variables. You may adjust them
FFP_HD="/mnt/HD/HD_a2"
FFP_USB="/mnt/USB/USB1_c1"


# Check if a USB removable disk has been detected. If not, exit
if [ "$CONTINUE" -eq 1 ]; then
  # get the USB key partition
  USB_PARTITION=`df | grep "${FFP_USB}" | sed 's/^\([a-z0-9\/]*\).*$/\1/g'`

  # if partition has been mounted, remount it with noatime, else exit
  if [ -z "${USB_PARTITION}" ]; then
    CONTINUE=0
    echo "ERROR - USB device has not been detected as Mass Storage"
  else
    echo "Unmounting usb partition: ${USB_PARTITION}"
    umount ${USB_PARTITION}
    mount ${USB_PARTITION} -t ext3 ${FFP_USB} -o noatime 2>/dev/null
    echo "USB - USB disk mounted under ${FFP_USB}"
  fi
fi

# Check presence of ffp directory at the USB key root. If not present, exit
if [ "$CONTINUE" -eq 1 ]; then
  if [ ! -d "${FFP_USB}/ffp" ] ; then
    CONTINUE=0
    echo "ERROR - Directory ${FFP_USB}/ffp doesn't exist"
  else
    echo "USB - Directory ${FFP_PATH} present"
  fi
fi

# Check presence of ffp directory at the HD root. If not present, exit
if [ "$CONTINUE" -eq 1 ]; then
  if [ ! -d "${FFP_HD}/ffp" ] ; then
    CONTINUE=0
    echo "ERROR - Directory ${FFP_PATH} doesn't exist"
  else
    echo "HD - Directory ${FFP_PATH} present"
    rm -rf ${FFP_USB}/ffp 2>/dev/null
    cp -a ${FFP_HD}/ffp ${FFP_USB}/
    echo "HD -> USB | Files copied to USB"
  fi
fi

# Declare USB key ffp directory as ffp root
if [ "$CONTINUE" -eq 1 ]; then
    FFP_PATH=${FFP_USB}/ffp
    # Move tmp to the usb stick, such that there is enough temp space
    rm -rf ${FFP_USB}/tmp
    mkdir ${FFP_USB}/tmp
    cp -a /tmp/* ${FFP_USB}/tmp
    rm -rf /tmp 2>/dev/null
    ln -s ${FFP_USB}/tmp /tmp
    echo "USB - Fun_Plug is running from USB key under ${FFP_PATH}, accessible thru /ffp"
else
    echo "ERROR - Fun_Plug root can't be moved to USB Key"
fi

 Further add the script to /ffp/bin/sync_ffp.sh and make it executable:
Code: [Select]
#!/bin/sh
#
# /ffp/bin/sync_ffp.sh
#
# Sync all changes from the usb drive back to the HD.
# All changes on the USB key will be removed after reboot.
#
# V 0.1 - Thomas Preindl


CONTINUE=1

# Environment variables. You may adjust them
FFP_HD="/mnt/HD/HD_a2"
FFP_USB="/mnt/USB/USB1_c1"

# Check presence of ffp directory at the USB key root. If not present, exit
if [ "$CONTINUE" -eq 1 ]; then
  if [ ! -d "${FFP_USB}/ffp" ] ; then
    CONTINUE=0
    echo "ERROR - Directory ${FFP_USB}/ffp doesn't exist"
  else
    echo "USB - Directory ${FFP_PATH} present"
  fi
fi

# Check presence of ffp directory at the HD root. If not present, exit
if [ "$CONTINUE" -eq 1 ]; then
  if [ ! -d "${FFP_HD}/ffp" ] ; then
    CONTINUE=0
    echo "ERROR - Directory ${FFP_PATH} doesn't exist"
  else
    echo "USB - Directory ${FFP_PATH} present"
    rsync --delete -av ${FFP_USB}/ffp/ ${FFP_HD}/ffp
    echo "USB -> HD | Files synced to HD"
  fi
fi

You will have to call this script whenever you change something on your setup. This is the only drawback of this approach.
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: sparomba on March 31, 2015, 03:19:20 AM
Thanks for the scripts and the idea k1kfr3sh! The uwchmod didn't work for me either. I'm now using your script with a few changes.

Quote from: k1kfr3sh
Changing .bootstrap/setup.sh to copy ffp to the USB drive. Although several 100M it is only done at startup.

Instead of copying the entire ffp directory on every boot to usb, you can also use rsync. This fixes the 777 permission problem with the files and directories on the usb drive without needing to copy them over again.
I also added a 30s delay because the setup.sh got executed before the dns-320l even mounted the usb drive (at least on my device).

This is the setup.sh I'm using:
Code: (setup.sh) [Select]
#!/bin/sh
#
# Script .bootstrap/setup.sh
#
# Called by fun_plug to prepare USB key execution environment
# If everything is ok, fun_plug will run from the USB key
#
# 08/09/2012 - V1.0 by Nicolas Bernaerts

# Set default path
PATH=/usr/sbin:/sbin:/usr/bin:/bin
CONTINUE=1

# Environment variables. You may adjust them
FFP_HD="/mnt/HD/HD_a2"
FFP_USB="/mnt/USB/USB1_c1"

# Check if a USB removable disk has been detected. If not, exit
if [ "$CONTINUE" -eq 1 ]; then
  # get the USB key partition
  sleep 30
  USB_PARTITION=`df | grep "${FFP_USB}" | sed 's/^\([a-z0-9\/]*\).*$/\1/g'`
  # if partition has been mounted, remount it with noatime, else exit
  if [ -z "${USB_PARTITION}" ]; then
    CONTINUE=0
    echo "ERROR - USB device has not been detected as Mass Storage"
  else
    echo "Unmounting usb partition: ${USB_PARTITION}"
    umount ${USB_PARTITION}
    mount ${USB_PARTITION} -t ext3 ${FFP_USB} -o noatime 2>/dev/null
    echo "USB - USB disk mounted under ${FFP_USB}"
  fi
fi

# Check presence of ffp directory at the USB key root. If not present, exit
if [ "$CONTINUE" -eq 1 ]; then
  if [ ! -d "${FFP_USB}/ffp" ] ; then
    CONTINUE=0
    echo "ERROR - Directory ${FFP_USB}/ffp doesn't exist"
  else
    echo "USB - Directory ${FFP_PATH} present"
  fi
fi

# Check presence of ffp directory at the HD root. If not present, exit
if [ "$CONTINUE" -eq 1 ]; then
  if [ ! -d "${FFP_HD}/ffp" ] ; then
    CONTINUE=0
    echo "ERROR - Directory ${FFP_PATH} doesn't exist"
  else
     rsync --delete -aqv ${FFP_HD}/ffp/ ${FFP_USB}/ffp
echo "HD -> USB | Files synced to USB"
  fi
fi

# Declare USB key ffp directory as ffp root
if [ "$CONTINUE" -eq 1 ]; then
    FFP_PATH=${FFP_USB}/ffp
    # Move tmp to the usb stick, such that there is enough temp space
    rm -rf ${FFP_USB}/tmp
    mkdir ${FFP_USB}/tmp
    cp -a /tmp/* ${FFP_USB}/tmp
    rm -rf /tmp 2>/dev/null
    ln -s ${FFP_USB}/tmp /tmp
    echo "USB - Fun_Plug is running from USB key under ${FFP_PATH}, accessible thru /ffp"
else
    echo "ERROR - Fun_Plug root can't be moved to USB Key"
fi
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: slevin7 on March 21, 2016, 09:02:21 AM
Please, do not ask why or how.
but i managed to partitioned my second harddrive in my nas.
I just blind copy and paste this show commands: m
show partitions: p
delete partitions: d
make new partition: n
3x Enter
partion ID: t
partion ID: 83 for Linux
write table: w

normalies this would not happend to me but after several beers, this great idea came in my mind.
is there any way to parted my drive back?


thanks for any advice and please dont laugh to loud

some information, I hade raid0, I tried recovery with testdisk but i have no idea with partition I should write.

Sorry for bad English
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: sbrbot on August 17, 2016, 12:08:17 PM
For those that haven't already read about it, fun_plug does not work any more in Dlink DNS-320L since firmware version 1.06. I've been using it successfully for several years but it seems that fun_plug is now obsolete. New mechanism with add-ons has been established and it's good.
Title: Re: Tutorial: fun_plug 0.7 running off usb stick
Post by: chbong on September 04, 2016, 03:04:17 AM
I just upgraded to 1.07 and discovered that fun_plug not longer work. I just realized it was obsolete. Is there any way to control the fan speed? I used to use a script to control the fan speed.