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 2012-06-29 19:10:20

GiannisAth
Member
Registered: 2012-04-30
Posts: 9

boot debian from USB memory

Hi

I am trying to boot debian from USB memory, this becaouse  from HDD do not hibernate it.
I have combining two fun_plug scripts and the following is created

#!/bin/sh
USB_MOUNTP=/mnt/sdc1
USB_DEV=sdc1
FFP_HD=/mnt/HD_a2/ffp
FFP_USB=$USB_MOUNTP/ffp
# write a log, in case sth goes wrong
FFP_LOG=/mnt/HD_a2/ffp.log
exec >>$FFP_LOG 2>&1

# real path to ffp
FFP_PATH=$FFP_HD

# prefix used to compile ffp packages
FFP_PREFIX=/ffp

# rc file path
FFP_RC=$FFP_PREFIX/etc/rc

echo "**** fun_plug script for DNS-323 (2008-04-13 tp@fonz.de) ****"
date

usbmod_loaded=no
#copy usb-storage module
if [ -e $FFP_HD/lib/modules/kernel/2.6.12.6-arm1/usb-storage.ko ]; then
    echo "Found usb-storage.ko module. Copying..."
    cp $FFP_HD/lib/modules/kernel/2.6.12.6-arm1/usb-storage.ko /lib/modules/
    #load usb-storage module
    insmod /lib/modules/usb-storage.ko
    echo "insmod usb-storage.ko"
    sleep 2
    usbmod_loaded=yes
fi

# find usb device
if test $usbmod_loaded = yes; then
    usb_found=no
    grep $USB_DEV /proc/partitions >/dev/null 2>/dev/null
    if [ $? -ne 0 ]; then
        # wait for disk...
        let timeout=30
        echo "Waiting for $USB_DEV (up to $timeout seconds) ..."
        while [ $timeout -gt 0 ]; do
            grep $USB_DEV /proc/partitions >/dev/null 2>/dev/null
            [ $? -eq 0 ] && break
            sleep 3
            let timeout=${timeout}-5
        done
        grep $USB_DEV /proc/partitions >/dev/null 2>/dev/null
        if [ $? -ne 0 ]; then
            echo "Failed. Did not find $USB_DEV in /proc/partitions."
            usb_found=no
        else
            echo "Found $USB_DEV in /proc/partitions"
            usb_found=yes
        fi
    else
        usb_found=yes
    fi

    # mount usb device
    if test $usb_found = yes; then
        mkdir -p $USB_MOUNTP
        echo -n "Mounting /dev/$USB_DEV on $USB_MOUNTP ..."
        mount /dev/$USB_DEV $USB_MOUNTP
        if [ $? -ne 0 ]; then
            echo "Failed"
        else
            echo "Success"
        fi
    fi
fi

# First DISK1
export DISK1=/mnt/HD_a2
# Second disk
export DISK2=/mnt/HD_b2
# Root disk

export DISK3=/mnt/sdc1


export PATH=$PATH:$DISK3/lnx_bin:

cd $DISK3

# Check for lnx_bin  - updated busybox - from KRH
if [ ! -d lnx_bin ]
then
    exit 0
fi

# Start Telnet - from KRH
if [ -f starttelnet.sh ]
then
    ./starttelnet.sh
fi

# Unpack etch base if it exists
if [ ! -d etch ]
then
        if [ -f etch.tar ]
        then
                busybox3 tar -xf etch.tar
        else
                exit 0
        fi
fi
# Bind mount disk3
mkdir etch/$DISK3
mount --bind $DISK3 etch/$DISK3

# Bind mount disk1
mkdir etch/$DISK1
mount --bind $DISK1 etch/$DISK1

# Bind mount disk2
mkdir etch/$DISK2
mount --bind $DISK2 etch/$DISK2

# Bind mount rootfs
mkdir etch/mnt/root
mount --bind / etch/mnt/root

# Bind mount etch/dev
mkdir etch/dev
mount --bind /dev etch/dev

# Bind mount etch/sys
mkdir etch/sys
mkdir etch/sys/crfs
mount --bind /sys  etch/sys
mount --bind /sys/crfs etch/sys/crfs

# Bind mount etch/web
mkdir etch/web
mount --bind /web etch/web

# Bind mount etch/proc
mkdir etch/proc
mount --bind /proc etch/proc
#
# Mounts
cp -f /proc/mounts etch/etc/mtab

busybox3 rm -f etch/etc/fstab
busybox3 touch etch/etc/fstab

# Copy resolv.conf
busybox3 cp -f /etc/resolv.conf etch/etc

# Set hostname to disk
busybox3 hostname disk
busybox3 hostname >etch/etc/hostname

# Copy hosts
busybox3 cp -f /etc/hosts etch/etc

busybox3 chroot $DISK3/etch ./linuxrc



After reboot the following log message is written

**** fun_plug script for DNS-323 (2008-04-13 tp@fonz.de) ****
Fri Jun 29 17:50:36 GMT 2012
Found usb-storage.ko module. Copying...
insmod usb-storage.ko
Waiting for sdc1 (up to 30 seconds) ...
Found sdc1 in /proc/partitions
Mounting /dev/sdc1 on /mnt/sdc1 ...Success


But the debian does not start..
There is any errot to fun_plug script

Offline

 

#2 2012-07-05 06:25:56

bjby
Member
Registered: 2009-02-22
Posts: 265

Re: boot debian from USB memory

Run the commands manually instead of as part of boot. This way will probably spot where it fails.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB