HDsamba2

From DD-WRT Wiki

Revision as of 00:06, 29 January 2009 by Alvin (Talk | contribs)
Jump to: navigation, search

Contents

HDsamba2

Currently at version 2.0.

An install and boot script system that will allow you to easily install Optware Samba2 and use your DD-WRT router as a Samba2 USB HD NAS device.

All you need to do is to setup a few pre-install details, run the install script and HDsamba2 will do the rest for you.

Notice

Important Note: (Thanks to AtMi)

There is an issue with the Reboot Button in the dd-wrt web-GUI.

This issue affects HDsamba, and all other script based methods of unmounting USB devices. Testing has shown that the Reboot Button in web-GUI DOES NOT RUN THE USB UNMOUNT SCRIPT.

Soft reboots (that are made after changing and pressing Apply Settings Button ) does however run the USB unmount scripts and thus cleanly unmount the drive... but the Reboot Button under Administration, DOES NOT UNMOUNT THE USB DRIVE before reboot happens.

At this time, I'm suggesting people use putty to reboot the router with the "reboot" command.
This will call the unmount script naturally.

Better still, configure the SESbutton, and simply unmount your HD manually before you reboot.

A bug has been listed in the tracker, and I hope this minor change can be made to avoid confusion for those wanting a simple USB storage solution.


Background

The Goal:

A quick, painless method of installing and setting up NAS on a broadcom router.The scripts are designed to be intelligent in the sense that they can detect bad web-GUI settings, improperly partitioned disks, errors on disks, unmount problems, processes that fail to execute or terminate, and other unexpected failures.

The golden rule with HDsamba, is that every command issued has at least one verification stage. If something fails, the log files (see /tmp/HSsamba/*.log) should contain everything you need to identify the problem.

HDsamba2 will:

  • Installs e2fsprogs and swap-utils to /jffs to address disk integrity and memory swap
  • Installs Optware to /opt
  • Installs Samba2 with an initial configuration file that works out of the box
  • Installs xinetd to provide SWAT for Samba that works out of the box
  • Mounts your Optware partition for you
  • Mounts your Swap partition for you
  • Mounts your NAS partition for you
  • Allows you to configure the Routers (ez)sesbutton to unmount the disk drive on press

AND IF SOMETHING GOES WRONG, HDSAMBA2 WILL TELL YOU WHAT HAPPENED


HDsamba2 Pre-requisites

HDsamba2 has successfully been testet with these routers and builds:

  • WRT600N Eko Mini_usb_ftp svn11487 using the -mini install parameter.
  • WRT600N v1.1 Eko Mega svn11482
  • WRT350N Eko Mega svn11296
  • WRT600 Eko Mega svn11482 and a 1TB HD
  • WL-500gP v1 Eko Mega svn11218

Install a DD-WRT version with USB support

To make your life easy; install a firmware that already has USB support...
You can find these here http://www.dd-wrt.com/dd-wrtv3/dd-wrt/downloads.html"
Try under / others / eko / V24_TNG /

This version 2.0 of HDsamba2 was tested with Eko's 11218 and up mega builds. They work.

Keep in mind you will need 750kb of JFFS to run some utilities, so this may influence which build you choose.

Partition you HD

Please make sure your Hard Drive is partitioned as follows, the install, boot and many of the support scripts need your HD to be partitioned this way:

/part1 - ext3 (Optware and extra software...)
/part2 - linux swap (Swap partition for the router)
/part3 - ext3 (NAS data, this is the space that Samba will share)
I used a knoppix live cd to partition mine.
I was generous and provided 256MB to /part1 & /part2
I like cats.

Config a Time server

Point your browser to 192.168.1.1, or whatever your router's IP is...

web-GUI -> tab: Setup -> tab: Basic setup -> section: Time Settings

Set a Time Server

This helps stop e2fsck from running disc checks when there is no reason.
It may seem like a small detail, but it's important!

  • Set a Time Server* (The install script will detect if you are lazy...)

http://www.pool.ntp.org/ can help

Configure JFFS support

We need a small JFFS to run disc checks from, as repairs are best run on unmounted disks. Again you probably want around 750kb available. See Jffs for a guide of how to enable a jffs drive on your router

Config USB support

Under Services -> USB in the web-GUI, enable the following

  • Core USB Support
  • USB Storage Support
  • USB 2.0 (or the version your HD supports)
  • ext2/ext3 Support

NO NEED to specify an AUTOMOUNT, or startup script, as HDsamba2 boot script automatically runs when dd-wrt boots. And part of the boot script is to check for USB drive integrity, which is best done on an unmounted drive!

Safe shutdown script

HDsamba2 will automatically configure your router with a shutdown script to unmount USB drives cleanly on reboot (and thus save your HD wear and tear). The shutdown script is automatically integrated with the dd-wrt .rc_shutdown system.


Ok, that's it. You have met all the prerequisites. You are ready to run the install script.

Time to install

Putty into your router. Connect your Hard Disk to the router.

For Mega firmware builds run:

$ cd /tmp
$ wget http://www.3iii.dk/linux/optware/v2install.HDsamba2
$ sh /tmp/v2install.HDsamba2

Now follow the instructions on your screen, and answer some questions, and enjoy your NAS.

From here on, the log files are HDsamba2's way of telling you what went right, and if anything went wrong.
Read the section HDsamba2 Log files for a guide to the .log files.


For Mini firmware builds run:

$ cd /tmp
$ wget http://www.3iii.dk/linux/optware/v2install.HDsamba2
$ sh /tmp/v2install.HDsamba2 -mini

Now follow the instructions on your screen, and answer some questions, and enjoy your NAS.

From here on, the log files are HDsamba2's way of telling you what went right, and if anything went wrong.
Read the section HDsamba2 Log files for a guide to the .log files.

NOTES about Mini:

The -mini parameter will install additional OpenWRT libraries from the whiterussian build, and config the OpenWRT-wrapper to load these libraries correctly for running the Swap utilities.
Also note: This addition is still under development and is thus still in beta testing
UPDATE on -mini parameter:
  • reports of success using -mini parameter with WRT600N and mini_usb_ftp svn11487

Notes and information

Notes on SES / AOSS / EZ-SETUP / WPS Button Function

If you enable this feature:

  • press and hold the button for a couple of seconds.
  • Your Hardrive LED should flicker.
  • Release button and wait (no more than 30 seconds)
  • Unplug HD safely.

There is no feedback feature implemented at this time, sorry.

If you don't trust it, putty in and run a mount command the first couple of times you try using the SES button. IT DOES UNMOUNT THE DRIVE, you just need to give it 30 seconds max (see below as to why...)

To remount your drive you have 2 options:

1) Plug the drive back in, reboot your router. Or alternatively, reboot your router, plug drive in later, as the HDsamba2 boot script will continue to look (indefinitely) for a USB partition until it finds one.

2) Plug the drive back in, and press the SES button a SECOND TIME. This will remount the drive and restart Samba.

A firewall note

If you have extensive firewall logging enabled in the web gui, there is a chance it can interfere with how HDsamba2 detects hard drives... as it can corrupt dmesg output.

If you enable firewall logging there is NO GUARANTEE OF COMPATIBILLITY WITH HDSAMBA2.

If you MUST have firewall logging, I suggest you use a modest amount log detail for best results with HDsamba2.

HDsamba2 Log files

If at anytime you experience problems, you have 3 sets of HDsamba logs to take a look at:

/tmp/HDsamba/*.log (These will always be the most recent)
/mnt/HDsamba/logs/*.log (These are copied from /tmp in the event of a successful init.startup)
/mnt/data/Logs (These are copied from /tmp when Samba is started)

The log files are your friend, if you're having problems, post the log files in the dd-wrt forum.HDsamba2 uses the log files to tell you what went wrong.

Do ls /tmp/HDsamba to see the names of the log files

Do cat /tmp/HDsamba/boot.log to read the boot.log file


HDsamba2 boot system

HDsamba2 is automatically initialized on router startup from files stored in /jffs/etc/config:

init.startup executes first

Task 1: checks for /jffs and waits 30 seconds or until it appears
Task 2: checks for a time sever and waits 30 seconds or until it appears
Task 3: waits for HD to be plugged in, if it isn't already, infinite wait
Task 4: mounts the swap partition
Task 5: runs a check on paritions 1 and 3, may take time if there are problems
Task 6: mounts /mnt

Passes execution to /mnt/HDsamba/scripts/mount.usb

NOTE: If you partition your HD with a Linux boot CD that doesn't use a time server it is likely your HD will read it was created in 1970. This date will cause e2fsck to force a check of disk partitions created this far in the past,
as a result EXPECT DELAYS ON YOUR FIRST BOOT OF HDSAMBA2.


mount.usb executes next

Task 1: mounts the /mnt/opt to /opt to allow optware to function
Task 2: mounts the NAS partition to /mnt/data
Task 3: starts Samba, waits for it to start, or 30 seconds whatever happens first
Task 4: starts Proftp*, waits for it to start, or 30 seconds whatever happens first
*This only occurs if ProFTP is enabled in the web GUI

Finally, it copies all log files to /mnt/HDsamba/logs/ for easy viewing later.


Utilities

/mnt/HDsamba/scripts/network.usb

Simple question based method of quickly setting up smb.conf
Stores a backup of your smb.conf config file.


/mnt/HDsamba/scripts/jffs.repair

Re-installs files to /jffs if you had to wipe /jffs or do a firmware upgrade

NOTE for Mini builds: can also be run as /mnt/HDsamba/scripts/jffs.repair -mini
This enables library support on smaller builds that don't support open-wrt (As mentioned the Mini build support is still under development and must thus be considered in beta stage)


The /mnt/HDsamba/scripts/jffs.repair script will:

  • install e2fsprogs to jffs
  • install swap-utils to jffs
  • configure the open-wrt wrapper
  • install the HDsamba2 startup scripts

It also configures the SESbutton.


/mnt/HDsamba/scripts/unmount.sesbutton

Allows the sesbutton to mount and unmount your Hard drive. The install script copies this file to /jffs/etc/config/ to enable this feature You can copy this file yourself to enable it. You can also rm /jffs/etc/config/unmount.sesbutton to deactivate this feature


The unmount scripts work this way:

1. Kills samba processes - gives them up to 30 seconds to report a clean termination - usually this is instant unless there is a problem

2. Turns off the Swap Parition - gives it up to 30 seconds to report a clean stop - usually this is instant unless there is a problem

3. Turn off ProFTP - gives it up to 30 seconds to report a clean stop - usually this is instant unless there is a problem

4. Saves permanent logs to /mnt/HDsamba/logs I want to avoid writing to /jffs as much as possible so the rest of the script is not logged

5. Attempts to unmount the HDs in 'normal' mode. Gives 15 seconds for this to happen. This usually completes in 5 - 10 seconds. This will shut down the drives 95-98% of the time.

6. Check if the HD is still mounted. If so, try unmounting again in 'lazy' unmount mode. 99.9999% of the time this solves any lingering HD reads/writes, and shuts the drive down cleanly. The script provides another 15 seconds to complete this process, or as much of that time that is needed.

7. Last check, are the drives still mounted? I have never encountered this problem to date but I admit it's a possibillity due to other processes or unforseen modifications. Just in case, a small file bad_shutdown.flag is saved to /jffs to tell HDsamba2 on it's next start that the drives didn't shut down properly, and that it should check the disks aggressively.

8. Script is finished.


A note from the developer

Bug reports, issues, reports of success and failure on various builds are always welcome.
Suggestions are also most welcome in this forum thread
Together is how we continue to make DD-WRT stay the best router firmware out there.

Enjoy, Amorphis