DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2008-09-08 20:23:50

rcblackwell
Member
From: Pickering, ON
Registered: 2008-05-19
Posts: 204
Website

ffp 0.5 and FFP_SETUP_SCRIPT for USB

fonz et' all

An entry in the Change Log (http://www.inreto.de/dns323/fun-plug/0.5/ChangeLog.txt/) under August 20th indicates one of fun_plugs various improvements as being "better support for ffp on USB stick (see FFP_SETUP_SCRIPT)". For practice roll I'm reinstalling fun_plug and would like to investigate this feature further however I'm unable to find any detail on the FFP_SETUP_SCRIPT that's refered to.


The fun_plug install script has the following entery;

# setup script (used for ffp on USB disk)
FFP_SETUP_SCRIPT=/mnt/HD_a2/.bootstrap/setup.sh

I'm unable to locate the /.bootstrap directory or the setup.sh file within fun_plug.tgz or packages available from http://www.inreto.de/dns323/fun-plug/0.5/.

Any pointers would be greatly appreciated.


Bob Blackwell
Pickering, ON

Offline

 

#2 2008-09-08 20:27:23

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

rcblackwell wrote:

I'm unable to locate the /.bootstrap directory or the setup.sh file within fun_plug.tgz or packages available from http://www.inreto.de/dns323/fun-plug/0.5/.

It's not included. The idea is that you can place ffp wherever you like, and create your custom .bootstrap/setup.sh to locate and mount it.

Offline

 

#3 2008-09-11 03:45:48

rcblackwell
Member
From: Pickering, ON
Registered: 2008-05-19
Posts: 204
Website

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

fonz wrote:

rcblackwell wrote:

I'm unable to locate the /.bootstrap directory or the setup.sh file within fun_plug.tgz or packages available from http://www.inreto.de/dns323/fun-plug/0.5/.

It's not included. The idea is that you can place ffp wherever you like, and create your custom .bootstrap/setup.sh to locate and mount it.

I'm pleading insanity sad

Try as I may I can't seem to get my setup.sh script to work properly. As indicated by the following error the problem appears to be with the grep command

Wed Sep 10 20:38:59 GMT 2008
* Running /mnt/HD_a2/.bootstrap/setup.sh ...
grep: illegal option -- w
BusyBox v1.00-pre1 (2007.12.10-08:03+0000) multi-call binary

Usage: grep [-ihHnqvs] PATTERN [FILEs...]


Here's my setup.sh script.

Code:

#!/bin/sh

usbdisk_mount_options="-t auto"
usbdisk_dev="sdc1"
usbdisk_name="USB"
usbdisk_mountp="/mnt/HD_a2/$usbdisk_name"

insmod /mnt/HD_a2/ffp/lib/modules/$(uname -r)/usb-storage.ko #2>/dev/null
sleep 2
lsmod | grep -w usb_storage #>/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
    echo "Success - usb-storage.ko module loaded."

    # wait for disk...
    grep -w $usbdisk_dev /proc/partitions #>/dev/null 2>/dev/null
    if [ $? -ne 0 ]; then
        let timeout=90
        echo "Waiting for $usbdisk_dev (up to $timeout seconds) ..."
        while [ $timeout -gt 0 ]; do
            grep -w $usbdisk_dev /proc/partitions #>/dev/null 2>/dev/null
            [ $? -eq 0 ] && break
            sleep 2
            let timeout=${timeout}-2
            echo $timeout
        done
        grep -w $usbdisk_dev /proc/partitions #>/dev/null 2>/dev/null
        if [ $? -ne 0 ]; then
            echo "Failed. Did not find $usbdisk_dev in /proc/partitions."
    #        exit 1
        fi
    fi

    # mount it
    mkdir -p $usbdisk_mountp
    echo "Mounting /dev/$usbdisk_dev on $usbdisk_mountp"
    mount $usbdisk_mount_options /dev/$usbdisk_dev $usbdisk_mountp >$usbdisk_mountp/mount-error.txt 2>&1
    if [ $? -ne 0 ]; then
        echo "Failed"
        cat $usbdisk_mountp/mount-error.txt
    fi
else
    echo "Warning - usb-storage.ko module failed to load!"
fi

Any assistance that's offered would be greatly appreciated.

Last edited by rcblackwell (2008-09-11 03:46:59)


Bob Blackwell
Pickering, ON

Offline

 

#4 2008-09-11 04:31:07

luusac
Member
Registered: 2008-04-29
Posts: 360

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

rcblackwell wrote:

BusyBox v1.00-pre1 (2007.12.10-08:03+0000) multi-call binary

Can it be that you are using an old version of busybox that does not support the -w option, i.e. the fun_plug is not finding the later version on disk?  I am running BusyBox v1.10.1 (2008-04-19 12:53:41 CEST).  I haven't used the new .bootstrap feature so I may be wrong ...

In the fun_plug I use I have "$FFP_PREFIX/bin/sh $FFP_PREFIX/start/usbmount.sh start" to fire up the usb stick and run ffp from it.  Doesn't the $FFP_PREFIX/bin/sh prefix mean that the usbmount.sh is executed using the ffp busybox?

Does changing the shebang to #!/pathto_ffp_on_hdd/bin/sh in your setup.sh, or prefixing the line where you call setup.sh on the fun_plug make any difference?

Hth, but as I say I haven't tried this myself, so I may be quite wrong.
lu

Offline

 

#5 2008-09-11 09:30:03

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

luusac wrote:

Can it be that you are using an old version of busybox that does not support the -w option, i.e. the fun_plug is not finding the later version on disk?

Of course, he is. setup.sh is run very early, and PATH doesn't include /ffp/sbin or /ffp/bin. Bob, your options: a) only use commands that work with the unmodified firmware, b) add 'PATH=/ffp/sbin:/ffp/bin:$PATH' to your script. From then on, you'll have the ffp versions of the commands available.

Offline

 

#6 2008-09-11 09:37:39

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

rcblackwell wrote:

Code:

#!/bin/sh

usbdisk_mount_options="-t auto"
usbdisk_dev="sdc1"
usbdisk_name="USB"
usbdisk_mountp="/mnt/HD_a2/$usbdisk_name"

insmod /mnt/HD_a2/ffp/lib/modules/$(uname -r)/usb-storage.ko #2>/dev/null
sleep 2
lsmod | grep -w usb_storage #>/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
    echo "Success - usb-storage.ko module loaded."

    # wait for disk...
    grep -w $usbdisk_dev /proc/partitions #>/dev/null 2>/dev/null
    if [ $? -ne 0 ]; then
        let timeout=90
        echo "Waiting for $usbdisk_dev (up to $timeout seconds) ..."
        while [ $timeout -gt 0 ]; do
            grep -w $usbdisk_dev /proc/partitions #>/dev/null 2>/dev/null
            [ $? -eq 0 ] && break
            sleep 2
            let timeout=${timeout}-2
            echo $timeout
        done
        grep -w $usbdisk_dev /proc/partitions #>/dev/null 2>/dev/null
        if [ $? -ne 0 ]; then
            echo "Failed. Did not find $usbdisk_dev in /proc/partitions."
    #        exit 1
        fi
    fi

    # mount it
    mkdir -p $usbdisk_mountp
    echo "Mounting /dev/$usbdisk_dev on $usbdisk_mountp"
    mount $usbdisk_mount_options /dev/$usbdisk_dev $usbdisk_mountp >$usbdisk_mountp/mount-error.txt 2>&1
    if [ $? -ne 0 ]; then
        echo "Failed"
        cat $usbdisk_mountp/mount-error.txt
    fi
else
    echo "Warning - usb-storage.ko module failed to load!"
fi

- consider mounting the usb disk to /mnt/xyz instead of /mnt/HD_a2/xyz (which might prevent proper unmounting of /mnt/HD_a2 on shutdown)
- after successful mount, you should update FFP_PATH to point to the ffp on usb-disk, so fun_plug creates the correct /ffp link

Offline

 

#7 2008-09-11 14:09:27

rcblackwell
Member
From: Pickering, ON
Registered: 2008-05-19
Posts: 204
Website

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

fonz wrote:

luusac wrote:

Can it be that you are using an old version of busybox that does not support the -w option, i.e. the fun_plug is not finding the later version on disk?

Of course, he is. setup.sh is run very early, and PATH doesn't include /ffp/sbin or /ffp/bin.

That explains why the script runs fine from the command line but fails when called from fun_plug during boot. I didn't realize the DNS had a different version of BusyBox. Armed with this information I did an Internet search for BusyBox. Low and behold I found the BusyBox website as well as many others dedicated to this tiny exec. All commands and switches are listed thus making it easier for me to see what's available.

I tried option a) but for some reason the script ended up in a loop complaining about not being able to find file paths for some of the other commands. Perhaps I messed something else up when I tried this so I'll give it another whirl!

I learned something new today. Appreciated.

Last edited by rcblackwell (2008-09-11 14:14:14)


Bob Blackwell
Pickering, ON

Offline

 

#8 2008-09-11 14:21:22

luusac
Member
Registered: 2008-04-29
Posts: 360

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

rcblackwell wrote:

All commands and switches are listed thus making it easier for me to see what's available.

From what I remember though the site does not say which switches/options are available for the various version of busybox.  e.g. the grep -w you are using will be listed there even though your 'default' version does not support it.
lu

Offline

 

#9 2008-09-11 14:33:40

rcblackwell
Member
From: Pickering, ON
Registered: 2008-05-19
Posts: 204
Website

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

fonz wrote:

- consider mounting the usb disk to /mnt/xyz instead of /mnt/HD_a2/xyz (which might prevent proper unmounting of /mnt/HD_a2 on shutdown)
- after successful mount, you should update FFP_PATH to point to the ffp on usb-disk, so fun_plug creates the correct /ffp link

Thank you for the tip on mount location. My old installation of ffp mounted the USB key to /mnt/USB. Since I was modelling this installation on the script provided in /ffp/etc/examples I assumed /mnt/HD_a2/USB would be okay.

In respect to item 2; Thank you; once the script problem was resolved I intended to update FFP_PATH accordingly. In reviewing the fun_plug script I see the ffp symlink is created after calling setup.sh. In my mind it would be better to create this link before calling the setup script then have setup.sh update the link as deemed appropriate.

Sample fun_plug code follows;

Code:

....

# create /ffp link
echo "ln -snf $FFP_PATH /ffp"
ln -snf $FFP_PATH /ffp

# check for setup script. an example use for this is to load USB
# kernel modules and mount a USB storage device. The script is
# sourced, that means you can change variables, e.g. FFP_PATH to point
# to the USB device.
if [ -x $FFP_SETUP_SCRIPT ]; then
    echo "* Running $FFP_SETUP_SCRIPT ..."
    . $FFP_SETUP_SCRIPT
fi

....

Sample setup.sh script code follows;

Code:

...

# Test for existence of ffp on USB drive
if [ -d /USB/path/to/ffp/exists ]; then
   FFP_PATH="USB/path"
   echo "ln -snf $FFP_PATH /ffp"
   ln -snf $FFP_PATH /ffp
fi

...

# return to fun_plug script

Bob Blackwell
Pickering, ON

Offline

 

#10 2008-09-11 14:35:25

rcblackwell
Member
From: Pickering, ON
Registered: 2008-05-19
Posts: 204
Website

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

luusac wrote:

rcblackwell wrote:

All commands and switches are listed thus making it easier for me to see what's available.

From what I remember though the site does not say which switches/options are available for the various version of busybox.  e.g. the grep -w you are using will be listed there even though your 'default' version does not support it.
lu

That's true but if I do a /bin/grep at the command line I can see which switches are available in the DNS installed BusyBox and adjust accordingly.


Bob Blackwell
Pickering, ON

Offline

 

#11 2008-09-11 15:18:27

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

rcblackwell wrote:

I intended to update FFP_PATH accordingly. In reviewing the fun_plug script I see the ffp symlink is created after calling setup.sh. In my mind it would be better to create this link before calling the setup script then have setup.sh update the link as deemed appropriate.

What if there's no ffp at $FFP_PATH? The whole purpose of setup.sh is to locate your ffp installation, so that the correct /ffp link can be created. Note that setup.sh is also run before a fun_plug.tgz tarball is installed. So using setup.sh you can even redirect the initial installation to a usb drive. Ideally, setup.sh doesn't use anything beside firmware tools. In that sense, my suggestion to add /ffp/sbin and /ffp/bin to $PATH in setup.sh was, of course, wrong.

Offline

 

#12 2008-09-12 03:57:46

rcblackwell
Member
From: Pickering, ON
Registered: 2008-05-19
Posts: 204
Website

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

fonz wrote:

What if there's no ffp at $FFP_PATH? The whole purpose of setup.sh is to locate your ffp installation, so that the correct /ffp link can be created.

Agreed. The reason for reversing the order in which the symlink and the setup.sh script executed should address this. Prior to calling setup.sh the fun_plug script creates the ffp symlink. In my case if setup.sh script fails to mount the USB drive then the symlink would remain unchanged; it was set by the fun_plug script. If the USB drive mounts and ffp is found then setup.sh would create the symlink and it point to the correct ffp location. For all other scenarios the ffp symlink is set before the setup.sh script is called. Would this be problematic?


fonz wrote:

Ideally, setup.sh doesn't use anything beside firmware tools. In that sense, my suggestion to add /ffp/sbin and /ffp/bin to $PATH in setup.sh was, of course, wrong.

I managed to get around this with the following;

Code:

#!/bin/sh

usbdisk_mount_options="-t auto"
usbdisk_dev="sdc1"
usbdisk_name="USB"
usbdisk_mountp="/mnt/$usbdisk_name"

# Load usb-storage module
insmod /mnt/HD_a2/ffp/lib/modules/$(uname -r)/usb-storage.ko

# Test to see if usb-storage module loaded.
/bin/grep -q usb_storage /proc/modules
if [ $? -eq 0 ]; then
    # Announce Successful load of usb-storage.ko
    echo "Success - usb-storage.ko module loaded."

    #  Wait for disk to initialize.
    let timeout=90
    while [ $timeout -gt 0 ]; do
    echo "Waiting $timeout seconds for $usbdisk_dev to initialize."
        /bin/grep -q $usbdisk_dev /proc/partitions
        [ $? -eq 0 ] && break
        sleep 2
        let timeout=${timeout}-2
    done
    /bin/grep -q $usbdisk_dev /proc/partitions
    if [ $? -eq 0 ]; then
        # Disk found. Attempt to create mount point.
        mkdir -p $usbdisk_mountp
        echo "Mounting /dev/$usbdisk_dev on $usbdisk_mountp"
        mount $usbdisk_mount_options /dev/$usbdisk_dev $usbdisk_mountp >$usbdisk_mountp/mount-error.txt 2>&1
        if [ $? -eq 0 ]; then
            echo "Success - /dev/$usbdisk_dev mounted as $usbdisk_mountp."






------------------------- > Here's where I'd test for ffp and set the symlink < -------------------------------------

            # Test for existence of ffp on USB drive
            if [ -d usbdisk_mountp/ffp ]; then

                # Establish symlink
                FFP_PATH="$usbdisk_mountp/ffp"
                echo "Creating ffp symlink"
                ln -snf $FFP_PATH /ffp
            fi






        else
            echo "Warning - failed to mount /dev/$usbdisk_dev!"
            cat $usbdisk_mountp/mount-error.txt
        fi
    else
        echo "Warning - failed to mount /dev/$usbdisk_dev. Did not find $usbdisk_dev in /proc/partitions!"        
    fi
else
    # Storage module failed to load. Write error to ffp.log.
    echo "Warning - failed to load usb-storage.ko module!"
fi

Last edited by rcblackwell (2008-09-12 13:45:06)


Bob Blackwell
Pickering, ON

Offline

 

#13 2008-09-14 03:36:28

rcblackwell
Member
From: Pickering, ON
Registered: 2008-05-19
Posts: 204
Website

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

rcblackwell wrote:

fonz wrote:

What if there's no ffp at $FFP_PATH? The whole purpose of setup.sh is to locate your ffp installation, so that the correct /ffp link can be created.

Agreed. The reason for reversing the order in which the symlink and the setup.sh script executed should address this.

Having completed a working script I know see that I originally misunderstood the approach. Using the following code (setup.sh) I'm able to mount a USB drive, set the FFP_PATH then start ffp from the USB drive.

Code:

#!/bin/sh

usbdisk_mount_options="-t auto"
usbdisk_dev="sdc1"
usbdisk_name="USB"
usbdisk_mountp="/mnt/$usbdisk_name"

# Load usb-storage module
insmod /mnt/HD_a2/ffp/lib/modules/$(uname -r)/usb-storage.ko

# Test to see if usb-storage module loaded.
/bin/grep -q usb_storage /proc/modules
if [ $? -eq 0 ]; then
    # Announce Successful load of usb-storage.ko
    echo "Success - usb-storage.ko module loaded."

    #  Wait for disk to initialize.
    let timeout=60
    while [ $timeout -gt 0 ]; do
    echo "Waiting $timeout seconds for $usbdisk_dev to initialize."
        /bin/grep -q $usbdisk_dev /proc/partitions
        [ $? -eq 0 ] && break
        sleep 2
        let timeout=${timeout}-2
    done
    /bin/grep -q $usbdisk_dev /proc/partitions
    if [ $? -eq 0 ]; then
        # Disk found. Attempt to create mount point.
        mkdir -p $usbdisk_mountp
        echo "Mounting /dev/$usbdisk_dev on $usbdisk_mountp"
        mount $usbdisk_mount_options /dev/$usbdisk_dev $usbdisk_mountp >$usbdisk_mountp/mount-error.txt 2>&1
        if [ $? -eq 0 ]; then
            echo "Success - /dev/$usbdisk_dev mounted as $usbdisk_mountp."
            # Test for existence of ffp on USB drive
            if [ -d $usbdisk_mountp/ffp ]; then
                # Establish path to symlink
                FFP_PATH="$usbdisk_mountp/ffp"
            fi            
        else
            echo "Warning - failed to mount /dev/$usbdisk_dev!"
            cat $usbdisk_mountp/mount-error.txt
        fi
    else
        echo "Warning - failed to mount /dev/$usbdisk_dev. Did not find $usbdisk_dev in /proc/partitions!"        
    fi
else
    # Storage module failed to load. Write error to ffp.log.
    echo "Warning - failed to load usb-storage.ko module!"
fi

With this script if the USB drive fails to initialize operation of ffp falls back to /mnt/HD_a2/ffp.  To ensure file synchronization between /mnt/USB/ffp and /mnt/HD_a2/ffp a cronjob that runs rsync at 5:55 am each day has been added to crontab. The cron job is added to crontab through addition of the following to the fun_plug.local file;

Code:

##################################
#  Add required jobs to crontab  #
##################################
CRONTXT=/mnt/HD_a2/crontab.txt

# start with existing crontab
/bin/crontab -l > $CRONTXT

# add Rsync job; keep ffp on USB drive in sync with ffp on HD_a2
# /bin/echo "55 5 * * * /ffp/bin/rsync -av --delete /mnt/USB/ffp /mnt/HD_a2" >> $CRONTXT

# install the new crontab
/bin/crontab $CRONTXT

# clean up
/bin/rm $CRONTXT
##################################

Last edited by rcblackwell (2008-09-14 03:38:52)


Bob Blackwell
Pickering, ON

Offline

 

#14 2009-05-30 21:22:30

krimb1
Member
Registered: 2008-01-05
Posts: 65

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

Great script rcblackwell! Two questions:

(1) Though my disk shows when I run 'mount', under 'df' I don't see the mounted drive listed. Is this normal?

(2) Would it be possible to mount via UUID instead? I've attached my (pathetic smile) attempt, but it hangs on:

root@dlink-EE65AE:/mnt/HD_a2# ./start_kb.sh
insmod: cannot insert '/mnt/HD_a2/ffp/lib/modules/2.6.12.6-arm1/usb-storage.ko': File exists
Success - usb-storage.ko module loaded.
Waiting 7 seconds for  to initialize.

Thanks very much.

Code:

#!/ffp/bin/sh

usbdisk_mount_options="-t auto"
usbdisk_UUID="40f657e3-fbb1-6dc9-b8c5-93978c5266ec"
usbdisk_name="freebird"
usbdisk_mountp="/mnt/$usbdisk_name"

# Load usb-storage module
insmod /mnt/HD_a2/ffp/lib/modules/$(uname -r)/usb-storage.ko

# Test to see if usb-storage module loaded.
/bin/grep -q usb_storage /proc/modules
if [ $? -eq 0 ]; then
    # Announce Successful load of usb-storage.ko
    echo "Success - usb-storage.ko module loaded."

    # KB modification for parsing UUID
    # retreives device info and stores to /tmp/blkid
    blkid -t UUID=$usbdisk_UUID >/tmp/blkid
    # temp variable, e.g. "/dev/sdc1"
    USB_DEV=`cut -d ":" -f 1 </tmp/blkid`
    # remove first 5 characters, e.g."sdc1"
    usbdisk_dev=`echo $USB_DEV |sed 's/.\(.*\)/\1/' |sed 's/.\(.*\)/\1/' |sed 's/.\(.*\)/\1/' |sed 's/.\(.*\)/\1/' |sed 's/.\(.*\)/\1/'`


    #  Wait for disk to initialize.
    let timeout=7
    while [ $timeout -gt 0 ]; do
    echo "Waiting $timeout seconds for $usbdisk_dev to initialize."
        /bin/grep -q $usbdisk_dev /proc/partitions
        [ $? -eq 0 ] && break
        sleep 2
        let timeout=${timeout}-2
    done
    /bin/grep -q $usbdisk_dev /proc/partitions
    if [ $? -eq 0 ]; then
        # Disk found. Attempt to create mount point.
        mkdir -p $usbdisk_mountp
        echo "Mounting /dev/$usbdisk_dev on $usbdisk_mountp"
        mount $usbdisk_mount_options /dev/$usbdisk_dev $usbdisk_mountp >$usbdisk_mountp/mount-error.txt 2>&1
        if [ $? -eq 0 ]; then
            echo "Success - /dev/$usbdisk_dev mounted as $usbdisk_mountp."
            # Test for existence of ffp on USB drive
            if [ -d $usbdisk_mountp/ffp ]; then
                # Establish path to symlink
                FFP_PATH="$usbdisk_mountp/ffp"
            fi            
        else
            echo "Warning - failed to mount /dev/$usbdisk_dev!"
            cat $usbdisk_mountp/mount-error.txt
        fi
    else
        echo "Warning - failed to mount /dev/$usbdisk_dev. Did not find $usbdisk_dev in /proc/partitions!"        
    fi
else
    # Storage module failed to load. Write error to ffp.log.
    echo "Warning - failed to load usb-storage.ko module!"
fi

Last edited by krimb1 (2009-05-30 21:57:43)

Offline

 

#15 2009-05-30 22:46:20

rcblackwell
Member
From: Pickering, ON
Registered: 2008-05-19
Posts: 204
Website

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

krimb1 wrote:

Though my disk shows when I run 'mount', under 'df' I don't see the mounted drive listed. Is this normal?

I don't think so as "df" on my machine shows the USB drive

Code:

df
Filesystem           1k-blocks      Used Available Use% Mounted on
rootfs                    9911      7478      1921  80% /
/dev/root                 9911      7478      1921  80% /
/dev/loop0                5760      5760         0 100% /sys/crfs
/dev/sda2            306636052 235418216  71217836  77% /mnt/HD_a2
/dev/sdb2            960404324 404405596 555998728  42% /mnt/HD_b2
/dev/sda4               497861      1369    496492   0% /mnt/HD_a4
/dev/sdb4               497861         5    497856   0% /mnt/HD_b4
/dev/sdc1              1982064    388100   1493280  21% /mnt/USB

krimb1 wrote:

Would it be possible to mount via UUID instead? I've attached my (pathetic smile) attempt, but it hangs on:

Don't be so hard on yourself. There's nothing pathetic about your script.

I think it would be possible to use UUID. I seem to recall trying UUID however it was so long ago I don't recall what the the results were.

krimb1 wrote:

Code:

#!/ffp/bin/sh

I see you've referenced ffp in your script. I do recall having an issue with used

Code:

!/bin/sh

At this point in the boot process the ffp links hasn't been established thus

Code:

#!/ffp/bin/sh

isn't available.

Last edited by rcblackwell (2009-05-30 22:50:01)


Bob Blackwell
Pickering, ON

Offline

 

#16 2009-05-31 00:06:36

krimb1
Member
Registered: 2008-01-05
Posts: 65

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

Thanks a lot rcblackwell. You're quite right.

I've now have changed the script to utilize

#!/bin/sh

but unfortunately the script still hangs.

Success - usb-storage.ko module loaded.
Waiting 7 seconds for  to initialize.

Is it in how I am parsing the UUID string to yield the device name? I'm stumped. smile

Offline

 

#17 2009-05-31 06:43:20

krimb1
Member
Registered: 2008-01-05
Posts: 65

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

rcblackwell wrote:

To ensure file synchronization between /mnt/USB/ffp and /mnt/HD_a2/ffp a cronjob that runs rsync at 5:55 am each day has been added to crontab.
...

As I'm trying to troubleshoot my UUID script, I was looking at your very nice rsync script in the meantime. I tried reading the rsync manpage but I was left a little confused. hmm

My question is: which directory is the primary (source) and which is the secondary (backup destination)? Is (a) /mnt/HD_a2/ffp backed up to /mnt/USB/ffp nightly, or (b) vice-versa, or (c) are they somehow backed up equally??

Offline

 

#18 2009-05-31 15:15:37

rcblackwell
Member
From: Pickering, ON
Registered: 2008-05-19
Posts: 204
Website

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

krimb1 wrote:

Is it in how I am parsing the UUID string to yield the device name? I'm stumped. smile

I will admit my knowledge of Linux is minimal thus I may not be able to assist with this issue. What are you are trying to establish via the parse function? Is it the full path for use with the mount command?

While reviewing your script again I noticed that a low value has been used for "timeout". My experiences revealed anything less than 15 seconds resulted in unfavourable results. My original script had a value of 60. I've since changed that to 120. If the drive mounts in less time then specified by "timeout" the && break command within the "while" loop will be executed causing the script to move onto the next section.

Having said that, your current problem doesn't appear related to the "timeout" value used as it seems the script never gets beyond the first step in the "while" loop. Sometimes when developing scripts I find it necessary to log all events. More often then not log entries lead me in a direction of resolution. To enable logging enable the execute attribute of the syslogd.sh script then from the /ffp/start directory start logging services with ./syslogd.sh start. The logs output will be found in the file named /var/log/messages


Bob Blackwell
Pickering, ON

Offline

 

#19 2009-12-30 13:44:58

Opperpanter
Member
From: Eindhoven, Netherlands.
Registered: 2008-08-11
Posts: 89

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

Thanks for all the sharing of scripts, bu tboth of them don't work for me. I keep getting errors on the grep and blkid commands, probably because they are not yet available from setup.sh.

rcblackwell script:

/bin/grep: illegal option -- o

This is proboable because of the PATH thing fonz talks about.

krimb1 script:

/mnt/HD_a2/.bootstrap/setup.sh: /mnt/HD_a2/ffp/sbin/blkid: No such file or directory


Maybe same reason.

Adding /ffp/sbin and /ffp/bin to path (or /mnt/HD_a2/ffp/bin and /mnt/HD_a2/sbin) didn't help. Using hardcoded paths in the script didn't help either.

How did manage to solve this?

Offline

 

#20 2009-12-30 13:46:02

Opperpanter
Member
From: Eindhoven, Netherlands.
Registered: 2008-08-11
Posts: 89

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

At the moment I am using this scripts, which just loads the usb module, waits 10 seconds and mounts /dev/sdb1. So it's a little hardcoded at the moment.

Code:

#!/mnt/HD_a2/ffp/bin/sh

# variables
USB_MOUNTP=/mnt/usb
#USB_DEV_UUID=eed7f5d4-c801-4dbe-b65c-5574b3b7f1c8
USB_DEV=sdb1
FFP_HD=/mnt/HD_a2/ffp
FFP_USB=$USB_MOUNTP/ffp
HD_MOUNTP=/mnt/HD_a2
PROPER_MOUNTP=$HD_MOUNTP
HD_PREFIX=/hd1
USB_PREFIX=/usb
FFP_PATH=$FFP_HD
FFP_PREFIX=/ffp

usbmod_loaded=no
#copy usb-storage module
if [ -e $FFP_HD/lib/modules/$(uname -r)/usb-storage.ko ]; then
    echo "Found usb-storage.ko module. Copying..."
    mkdir -p /lib/modules/$(uname -r)/
    cp $FFP_HD/lib/modules/$(uname -r)/usb-storage.ko /lib/modules/$(uname -r)/
    #load usb-storage module
    insmod /lib/modules/$(uname -r)/usb-storage.ko
    echo "insmod usb-storage.ko"
    sleep 2
    usbmod_loaded=yes
    
    # wait for device to initialize
    sleep 10
    
    mkdir -p $USB_MOUNTP
    chmod 777 $USB_MOUNTP
    echo "Mounting $USB_DEV on $USB_MOUNTP"
    mount -t auto /dev/$USB_DEV $USB_MOUNTP >$HD_MOUNTP/mount-error.txt 2>&1
    if [ $? -ne 0 ]; then
        echo "Failed"
        cat $HD_MOUNTP/mount-error.txt
    else
        echo "USB stick mounted"
    fi

fi

if [ -d $FFP_USB ]; then
    echo "* Found FFP on USB device"
    FFP_PATH=$FFP_USB
    PROPER_MOUNTP=$USB_MOUNTP

    # suid busybox on USB
    if [ -x $FFP_USB/bin/busybox ]; then
        chown root.root $FFP_HD/bin/busybox
        chmod 0755 $FFP_HD/bin/busybox
        chmod u+s $FFP_HD/bin/busybox
    fi
    
    # create FFP_PREFIX link
    echo "ln -snf $FFP_PATH $FFP_PREFIX"
    ln -snf $FFP_PATH $FFP_PREFIX
else
    echo "* FFP was not found on a USB device. Reverting back to HDD-based FFP"
    FFP_PATH=$FFP_HD
    PROPER_MOUNTP=$HD_MOUNTP
fi

# end

Offline

 

#21 2010-08-21 07:46:08

mike7
Member
Registered: 2009-06-12
Posts: 10

Re: ffp 0.5 and FFP_SETUP_SCRIPT for USB

Opperpanter wrote:

krimb1 script:

/mnt/HD_a2/.bootstrap/setup.sh: /mnt/HD_a2/ffp/sbin/blkid: No such file or directory
.....
How did manage to solve this?

Regarding http://dns323.kood.org/forum/viewtopic. … 573#p14573 (thanks SilentException) you need to add something like this:

Code:

ln -snf $FFP_PATH /ffp

before blkid call

PS. You need ffp installed on HDD.

Last edited by mike7 (2010-08-21 07:54:19)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB