HDsamba2

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 07:20, 2 September 2009 (edit)
Alvin (Talk | contribs)
m (Links - - multiple HDs on router)
← Previous diff
Revision as of 07:34, 2 September 2009 (edit) (undo)
Alvin (Talk | contribs)
m (Links)
Next diff →
Line 335: Line 335:
= Links = = Links =
 +* Use several HDs and HDsamba2 on a router. [http://www.dd-wrt.com/phpBB2/viewtopic.php?p=283184#283184 Forum post] with files. [http://www.dd-wrt.com/phpBB2/viewtopic.php?p=293105#293105 Forum post] with usage example.
 +
 +
 +Samba3 links:
* Steps to upgrade HDsamba2 from using Samba v2.x to Samba v3.x ([http://www.dd-wrt.com/phpBB2/viewtopic.php?p=334644#334644 forum post]) effectively making it HDsamba3 * Steps to upgrade HDsamba2 from using Samba v2.x to Samba v3.x ([http://www.dd-wrt.com/phpBB2/viewtopic.php?p=334644#334644 forum post]) effectively making it HDsamba3
-* Addition/steps to use several HDs on a router. [http://www.dd-wrt.com/phpBB2/viewtopic.php?p=283184#283184 Forum post] with files. [http://www.dd-wrt.com/phpBB2/viewtopic.php?p=293105#293105 Forum post] with usage example.+* Unslung (home of Optware) wiki on Samba3 [http://www.nslu2-linux.org/wiki/Optware/Samba]
 +* The Official Samba 3.2.x HOWTO and Reference Guide [http://us6.samba.org/samba/docs/man/Samba-HOWTO-Collection/]
[[Category:English documentation]] [[Category:English documentation]]

Revision as of 07:34, 2 September 2009

Contents

HDsamba2

Currently at version 3.0. (January 31st 2009)

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 successfull install reports with these routers and builds:

  • WRT600N v1.1 Eko BS-v24-preSP2 mini-usb - build 12387 using the -mini install parameter.
  • WRT600N Eko Mini_usb_ftp svn11487 using the -mini install parameter.
  • WRT600N v1.1 Eko Mega svn11482
  • WRT600N v1.1 Eko Mega svn11604
  • WRT350N Eko Mega svn11296
  • WRT600 Eko Mega svn11482 and a 1TB HD
  • WL-500gP v1 Eko Mega svn11218
  • WL-500W 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 /

HDsamba2 has been tested with Eko's 11218 and up mega builds. They work.

Keep in mind you will need 300-400 kb of free JFFS space 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 HDsamba2 core scripts...)
/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
( time.windows.com works fine )

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 300-400kb available. (You will need more than this however if you install with the -MINI parameter, as extra libraries will be installed.) 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/v3install.HDsamba2
$ sh /tmp/v3install.HDsamba2

Now follow the instructions on your screen, and answer some questions, after reboot the log files are HDsamba2's way of telling you what went right, and if anything went wrong. Enjoy your NAS.

Read the section HDsamba2 Log files for a guide to the .log files.

Read the section HDsamba2 boot system for an overview of the steps and tasks performede during the boot process of HDsamba2.


For Mini firmware builds run:

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

Now follow the instructions on your screen, and answer some questions, after reboot the log files are HDsamba2's way of telling you what went right, and if anything went wrong. Enjoy your NAS.

Read the section HDsamba2 Log files for a guide to the .log files.

Read the section HDsamba2 boot system for an overview of the steps and tasks performede during the boot process of HDsamba2.


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:
  • MULTIPLE 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 and briefly hold the SES button a SECOND TIME. This will remount the drive and restart Samba.


A firewall note

HDsamba2 (as of version 3) no longer requires dmesg output. This means there is no longer an issue with firewall logging.


Troubleshooting HDsamba2

If at anytime you experience problems: Take a look at the log files. The log files are HDsamba2's way of telling you what went right or wrong during the boot process. Groups of the log files are stored at three locations during the boot process:


The three locations of the log files:

/tmp/HDsamba/*.log (These will always be the most recent log files)
/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)


Log files created by HDsamba2:

  • install.log
  • summary.log
  • boot.log
  • mount.log
  • disk_health.log
  • disk_health_forced.log
  • shutdown.log


  • Record of your original installation of HDsamba2.
  • Overview of the HDsamba2 process, check here first for problems.
  • Output of init.startup, how did the system startup, is the disk ok?
  • Output of mount.usb, any problems with the NAS, or samba daemons?
  • Health report on your HD
  • Created when there are critical problems with your HD, refer to date stamp.
  • Created whenever the unmount scripts run, did everything shutdown ok?

Use command: cat /tmp/HDsamba/boot.log to read the boot.log file


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 right or wrong during the boot process.


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.

During and after execution of the boot scripts, the log files will contain information about performance of each of the tasks during execution of the init.startup and mount.usb scripts; what went right and what went wrong.


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.
Now also does the same for swat config, using the subnet your specify to restrict access.
Requires a reboot when completed, or a manual restart of HDsamba2.

/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

/mnt/HDsamba/scripts/forcecheck.usb

Simulates a bad shutdown... the advantage to this, is if you want to force a full disk check on your partitions, running this will force such a check on your next boot. Good for the data paranoid, like me...


HDsamba2 Shutdown System

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.


Advanced - adding load and kill of more packages

There are now two other scripts installed with HDsamba2:

  • daemon.kill
  • daemon.load

You can find these scripts at /mnt/HDsamba/scripts.

These are for advanced users, who want to load other optware daemons, and want to control how they are integrated into the HDsamba2 system. This is also an ideal place to load other openwrt packages from JFFS if you so choose.

There is no automation of these files - their contents and configuration is totally up to you. I have included an example of AtMi's code for the Transmission daemon here.

These scripts are already called by the HDsamba2 startup and shutdown scripts, and as such are your perfect customization point for daemon control.

Remember, for every daemon you start in daemon.load, you should have a corresponding kill command in daemon.kill to create your best chance for a clean unmount each and every time.

It's not for all of us, but it does give the more advanced users out there the opportunity to customize their HDsamba2 setup.


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


Links


Samba3 links:

  • Steps to upgrade HDsamba2 from using Samba v2.x to Samba v3.x (forum post) effectively making it HDsamba3
  • Unslung (home of Optware) wiki on Samba3 [1]
  • The Official Samba 3.2.x HOWTO and Reference Guide [2]