Moving fonz’s fun_plug (ffp) to USB

After running the D-Link DNS-320 for a while, I decided to shift fonz’s fun_plug (ffp) to run off the USB drive instead of the hard disk. Some benefits of doing so are:

  • Reduce mechanical wear and tear – I frequently access the DNS-320 via ssh and by doing so, the disk spins up. By shifting the ffp onto the USB drive, the disks do not spin up as much and hence lesser mechanical wear and  tear
  • Power saving – I assume lesser disk spinups translate to marginal power savings in the long run

Shifting ffp to run off the USB drive for the D-Link DNS-320 is quite straight forward as the DNS-320 support USB drives out of the box. There is not a need to install kernel module (usb-storage.ko) like the D-Link DNS-323 days. However, the DNS-320, besides auto-mounting the USB drive, it also change the permission of all the files to 777 (chmod 777). This is undesirable as it will mess up the auto-start scripts (/ffp/start/*). Fortunately, KyleK came up with a package to intercept the chmod command for DNS-325 so we will make use of the package and modify it a little for D-Link DNS-320 usage.

 

Prerequisites

  • D-Link DNS-320
  • USB drive of at least 512MB
  • Some Linux knowledge (using vi to edit files)

 

The procedure of shifting ffp onto USB drive is:

  1. Make sure the DNS-320 is running ffp off its disk
  2. Install KyleK’s dns325-chmod-fix package and modify it for DNS-320 usage
  3. Format the USB drive to Ext2 File System
  4. Copy the current ffp folder to USB
  5. Download the updated fun_plug file and modifying the contents
  6. Reboot and enjoy running ffp off USB drive

 

Make sure the DNS-320 is running ffp off its disk

We will be using the DNS-320 to do some of the preparation work so make sure your DNS-320 is running fun_plug. If it is not running fun_plug, check the post on DNS-320 – making fun_plug and old packages work to set it up.

 

Install Kylek’s dns325-chmod-fix package and modify it for DNS-320 usage

Kylek has put together a package to address the chmod 777 issue on the DNS-325. It happens to address the issue we face in the DNS-320, a little script changing is what is required for it to work on the DNS-320.

So telnet to your DNS-320 and do the following:

  1. Navigate to Volume_1 by typing “cd /mnt/HD/HD_a2
  2. Download Kylek’s package by typing “wget http://kylek.is-a-geek.org:31337/files/ffp/0.5/dns325-chmod-fix-0.1-1.tgz
  3. Install the package by typing “funpkg -i dns325-chmod-fix-0.1-1.tgz
  4. Check that suppress_args is applied for /mnt/USB/HD_c1 by typing “cat /usr/local/config/chmod_usb.sh | grep 777
  5. Update it to suppress HD_c instead of HD_c1 by typing “cat /usr/local/config/chmod_usb.sh | sed -e ‘s/\/HD_c1\”/\/HD_c\”/’ >> /usr/local/config/chmod_usb.sh
  6. Ensure that suppress_args is now applied for /mnt/USB/HD_c by typing “cat /usr/local/config/chmod_usb.sh | grep 777

 

Format the USB drive to Ext2 File System
WARNING: We will be formatting the USB drive so make sure you have backed up the things you need on the USB drive.

Plug in your USB drive to the D-Link DNS-320 and wait 30 seconds, it should be mounted. You can check if it is mounted by using the command “mount | grep /dev/sdc“. It should return that there is something mounted (e.g. /dev/sdc on /mnt/USB/HD_c type ext2 (rw)). Once it is mounted proceed with the following commands:

  1. Unmount the USB drive by typing “umount /dev/sdc
  2. Format the USB drive by typing “mke2fs /dev/sdc
  3. After formatting, remount the USB drive by typing “mount /dev/sdc /mnt/USB/HD_c

 

Copy the current ffp folder to USB

We will be shifting the current ffp installation on your disk to the USB drive and it will take a while before the copy completes so sit back and enjoy a can of coke or a cup of Starbucks.

  1. Copy the current ffp installation to USB by typing “cp -a /mnt/HD/HD_a2/ffp /mnt/USB/HD_c/

 

Download the updated fun_plug file and modifying its contents

I modified an old copy of fun_plug script I dug out from my old DNS-323, modified it a little and it appears to work. Basically it will run fun_plug from USB drive if it is correct USB drive. It does this by matching the USB drive’s UUID.

  1. Back up the current fun_plug by typing “mv /mnt/HD/HD_a2/fun_plug /mnt/HD/HD_a2/fun_plug.hdd
  2. Download the new fun_plug file by typing “wget -O /mnt/HD/HD_a2/fun_plug http://www.shadowandy.net/wp/wp-content/uploads/fun_plug.dns320.usb
  3. Locate your USB drive UUID by typing “blkid /dev/sdc
  4. Replace the value of variable USB_DEV_UUID in /mnt/HD/HD_a2/fun_plug with the UUID you got in Step 3. You can use vi to do this.
  5. Once this is done, reboot the DNS-320 via web admin

 

How do I know if fun_plug is running off the USB drive?

You can check the ffp.log file in Volume_1 and see if says “* Found FFP on USB device”. If it does, it is running off the USB drive.

 

Treat shadowandy!

If these step-by-step guides have been very helpful to you and saved you a lot of time, please consider treating shadowandy to a cup of Starbucks.  

11 thoughts on “Moving fonz’s fun_plug (ffp) to USB

  • December 15, 2011 at 1:39 am
    Permalink

    Thanks for the info. I had not tried this out yet. But this command caught my eye:
    “cat /usr/local/config/chmod_usb.sh | sed -e ‘s/\/HD_c1\”/\/HD_c\”/’ >> /usr/local/config/chmod_usb.sh“

    This doesn’t look very safe… Isn’t it safer to use “-i.bak” for sed instead?

  • December 16, 2011 at 9:27 am
    Permalink

    WL,

    It is to simplify the editing of HD_c1 to HD_c. Alternatively you can manually vi the file. Can you share on the -i.bak method?

  • December 22, 2011 at 9:13 pm
    Permalink

    This is good info, thanks.

    The harddrives stays mostly quiet. I just have two questions:

    Any simple way to have the ffp.log file updated on the USB device as well?

    Is the .boostrap folder, which you haven’t mentioned, on Volume_1 nessesary?

    Any point making a swap file on the USB with the dns-325?

    Filename Type Size Used Priority
    /dev/md0 partition 530040 0 -1
    /mnt/USB/HD_c/swapfile1 file 524280 0 0

    And for others, beware. The qoutes “” are broken using Safari, making the copy/paste function unreliable. And also, many guides are using HD_c1 instead of HD_c

  • December 22, 2011 at 9:36 pm
    Permalink

    I think I figured out the log file, just edit the fun_plug file on Volume_1 to:

    FFP_LOG=$USB_MOUNTP/ffp.log

    Looks like the setup.sh from the .bootstrap folder is not in my fun_plug file, so the folder seems unnecessary 🙂

  • January 11, 2012 at 7:31 am
    Permalink

    Hello,

    I’m trying to get this to work on my DNS-320, having just done a clean install following the instructions: http://www.shadowandy.net/wp/2010/11/dns-320-making-fun_plug-and-old-packages-work.htm and then this page.

    Having followed the instructions above, I don’t seem to be able to get it to stop resetting the permissions on the usb key

    cat /usr/local/config/chmod_usb.sh | grep 777 returns:

    suppress_args=”777 -R /mnt/USB/HD_c1″
    suppress_args=”777 -R /mnt/USB/HD_c”

    mount gives me the following details:
    /dev/sdc on /mnt/USB/HD_c type ext2 (rw)

    so it’s formatted correctly.

    in the ffp.log, it shows that I’ve matched the UUID correctly:
    /dev/sdc: UUID=”554c8d86-36e9-4673-b4a3-82e3bc9cb5ec” TYPE=”ext2″
    Success. Found 554c8d86-36e9-4673-b4a3-82e3bc9cb5ec.

    …. however, then it goes on to complain that:

    * /ffp/start/sshd.sh …
    Starting /ffp/sbin/sshd
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @ WARNING: UNPROTECTED PRIVATE KEY FILE! @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0777 for ‘/ffp/etc/ssh/ssh_host_rsa_key’ are too open.
    It is recommended that your private key files are NOT accessible by others.
    This private key will be ignored.
    bad permissions: ignore key: /ffp/etc/ssh/ssh_host_rsa_key
    Could not load host key: /ffp/etc/ssh/ssh_host_rsa_key
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @ WARNING: UNPROTECTED PRIVATE KEY FILE! @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0777 for ‘/ffp/etc/ssh/ssh_host_dsa_key’ are too open.
    It is recommended that your private key files are NOT accessible by others.
    This private key will be ignored.
    bad permissions: ignore key: /ffp/etc/ssh/ssh_host_dsa_key
    Could not load host key: /ffp/etc/ssh/ssh_host_dsa_key
    Disabling protocol version 2. Could not load host key
    sshd: no hostkeys available — exiting.

    Any ideas?
    Cheers
    Chris

  • January 13, 2012 at 8:31 am
    Permalink

    chris,

    Can you manually edit the file to comment off the suppress_args for HD_c1? Reboot the DNS-320 and see if it helps

  • January 14, 2012 at 7:44 pm
    Permalink

    Cheers…. that’s done the trick! Many thanks for your guides!

  • January 15, 2012 at 10:17 pm
    Permalink

    chris,

    Glad to hear that! Happy to hear that your USB mounting is also on HD_c. A couple of people had their mounting on HD_c1.

  • January 18, 2012 at 2:25 am
    Permalink

    Hi,
    Your site is great!
    I have a couple of questions if you dont mind.
    Is transmission working the same way? Is that possible that i move the whole ffp incl. Transmission to usb and downloading / seeding to/from volume one? If i dont want transmission running on startup, then i just turn on nas without usb?
    Thanks for your help.

    Szegavara

Comments are closed.