Wednesday, June 25, 2008

Moving ffp to a USB stick

Ok, I finally got down to moving ffp to a cheap 1GB USB stick. The motivation for doing so are:

  1. Power saving - When there are little to no activities in the box, I do not want the hard disks to spin up unnecessarily.
  2. Clean HD_a2 file system - I still haven't figure out why cleanboot is not working on my box hence I rather risk a corrupted USB stick containing only ffp than my precious 500GB of real data.

Here are the steps I took to get it working on my box: [Edit: The instructions below is no longer valid for ffp 0.5 dated Aug 20th and later. Please look here for the latest instructions.]

  1. Get a cheap 1GB USB stick and plug it into the USB port behind the device. (duh!)
  2. Download the necessary module (i.e. usb-storage.ko) from here and put it in the folder /ffp/lib/modules/[kernel_version]/. Note that this is a new directory that you will need to create. (TIP: run 'uname -r' on the command line first to get the kernel version and then substitute it in the path above)
  3. Test the compatibility of the USB stick by running the usb mounting script that came with the ffp v0.5 package.
    1. Note: you may need to edit the script var usbdisk_dev if you have a second HDD as the default value is sdb1.
    2. run the script using the command ". ./usbdisk.sh"
    3. If everything is ok, you should see the message "Mounting /dev/sdc1 on /mnt/HD_a2/sdc1". You may also want to run df to confirm that it is properly mounted.
  4. Now that you are sure your USB stick works in the DNS-323, its time to format the stick in ext2. To do this, unmount the stick and run "mke2fs /dev/sdc1".
  5. Now, mount the new fs and copy the entire ffp folder to the stick. i.e. run "mount /dev/sdc1 /mnt/HD_a2/sdc1", followed by "cp -a /mnt/HD_a2/ffp /mnt/HD_a2/sdc1/".
  6. When we get here, we are now ready to replace the stock fun_plug script with one that will run ffp from the USB stick. There are a couple of variants floating about in the forum. Personally, I like the one by SilentException best as it identifies the stick via its UUID hence making sure it grabs the right stick for our mount point even if you have multiple USB sticks attached to the box.
    1. Backup your original fun_plug script. (This is always a good idea)
    2. Grab the script from here and put it in the root directory of /mnt/HD_a2.
    3. Locate your device's UUID by running the command blkid /dev/sdc1.
    4. Copy the UUID and replace the value in the variable USB_DEV_UUID in the script.
    5. You may also want to edit/remove the portion after #MS (but before # run commands!)
    6. Reboot the box and when it comes back up, check the log /mnt/HD_a2/ffp.log to make sure that you are now running ffp off the USB stick instead of the HDD.
Note that for convenience, this script also defines the shortcuts /hd and /usb to refer to /mnt/HD_a2 and /mnt/USB respectively.

9 comments:

w00blyn said...

Hey this is really cool, thanks for the post.

I'm having a bit of trouble though, perhaps you can help. I can't copy the usb-storage.ko file into the /ffp/lib/modules/2.6.12.6-arm1/ folder. Is there something that must be done to the folder first to allow write access?
Thanks :D

Sidney said...

Erm... its abit tough to help you troubleshoot just based on that info alone. Can you tell me how you created the directory and the command you used to copy as well as the exact error message that is shown when you try to copy the file into it?

w00blyn said...

I connected through SSH, then used the following commands:
cd /ffp/lib/
mkdir modules
cd /modules
mkdir 2.6.12.6-arm1

And then I tried to copy the file over with FTP. Is there a command line file copy that I could use?

Thanks very much for the reply,
ps: xbmc rules, with dvd2xbox it makes it an awesome media box

w00blyn said...

Cool I think I've got it. With your setup, is your transmission download folder on your usb stick? Then when it's finished it gets copied to the hard drive?

Would that mean the hard drives don't spin up at all while transmission is running?

Sidney said...

No, transmission is still running off the harddisk as my USB drive is only 1GB in size which is rather small for holding torrents.

DarkKnight said...

hi sidney,

I'm having a small issue here. I moved everything to the USB stick and it successfully boots from the usb (the ffp.log file shows the info). however when i login to ssh it says 'Server refused to allocate pty' and im unable to continue after that. any help is appreciated

Unknown said...

Hey Sidney,

Thanks for the tutorial. It's a cood suppliment to the one they have posted here: http://wiki.dns323.info/howto:external_drive . Yours is a little out of date but I got it to work with the latest version regardless. I am having the same issue as the above poster('Server refused to allocate pty'). The other thing is, I am not totally sure how SilentException's script works yet but I can't telnet in either. I had telnet disabled earlier but reenabled it and was able to use it with the original fun_plug script. However, the server closes the connection right away when I try to telnet in now...

Looks like the script is being loaded too. Check out the log:

**** fun_plug script for DNS-323 (2008-04-13 tp@fonz.de) ****
Sat Nov 15 18:31:48 GMT 2008
Found usb-storage.ko module. Copying...
insmod usb-storage.ko
ln -snf /mnt/HD_a2/ffp /ffp
Waiting for 50423b5c-2cbc-4f20-8f5b-93d5d7805dfd (up to 30 seconds) ...
/dev/sdc1: UUID="50423b5c-2cbc-4f20-8f5b-93d5d7805dfd" TYPE="ext2"
/dev/sdc1: UUID="50423b5c-2cbc-4f20-8f5b-93d5d7805dfd" TYPE="ext2"
Success. Found 50423b5c-2cbc-4f20-8f5b-93d5d7805dfd.
Mounting /dev/sdc1 on /mnt/USB
USB stick mounted
* Found FFP on USB device
ln -snf /mnt/USB/ffp /ffp
* Running /ffp/etc/rc ...
* /ffp/start/syslogd.sh inactive
* /ffp/start/SERVERS.sh inactive
* /ffp/start/portmap.sh inactive
* /ffp/start/unfsd.sh inactive
* /ffp/start/nfsd.sh inactive
* /ffp/start/ntpd.sh inactive
* /ffp/start/LOGIN.sh inactive
* /ffp/start/telnetd.sh ...
Starting /ffp/sbin/telnetd
* /ffp/start/sshd.sh ...
Starting /ffp/sbin/sshd
* /ffp/start/rsyncd.sh inactive
* /ffp/start/mediatomb.sh inactive
* /ffp/start/kickwebs.sh inactive
* /ffp/start/lighttpd.sh inactive
* /ffp/start/inetd.sh inactive
* OK

If you have any idea what might help here, I would be be grateful to hear it. Otherwise, I'll keep on digging!

Unknown said...

Found the solution! I used the same script as you but had to add a couple lines:

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

# 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

# run commands
..

explained here:

http://forum.dsmg600.info/t3213-funplug-issue.html

Cirip said...

hi Sidney!

At first your tutorial is great!

I am a totally newbie so sorry for my stupid questions.

I have a DNS-323 with two 1TB Samsung drive.
I use the device mostly for torrent with Transmission and I store my video/music in the device too. I use funplug.

I store them only the second drive becasuse sometimes the system crash and the data loss. For the bigger store place I am not use the RAID function so the samsung's run as two single drive.

So the task:

I would like to run all my system from a 2GB Kingston traveller USB what is allways plugged on. So the to hard drives contains only the downloaded data.


I tried your tutorial but please help some row:

"Note: you may need to edit the script var usbdisk_dev if you have a second HDD as the default value is sdb1. " Where is this file? and what can I modified to?

That was the point where I stopped.
Thanks for your help!

Best regards!

C.