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

#26 2008-05-11 06:54:56

SuperInsanity
Member
Registered: 2008-05-10
Posts: 11

Re: Modified fun_plug for disk maintenance

Swapping 36 & 37 seems have done the trick. So it went from this:

36 cp -f /mnt/HD_a2/ffp/share/e2fsck/libext2fs.so.2.4 /lib
37 rm -r /lib/libext2fs.so*


to this:

36 rm -r /lib/libext2fs.so*
37 cp -f /mnt/HD_a2/ffp/share/e2fsck/libext2fs.so.2.4 /lib


Now the badblock checking is working...

Thanks for the script, and the help on the small fix too!!

big_smile

Of course now I look at that, it makes sense, we were copying it, then immediately removing it...oops!!

So for anyone who might want this script here it is in it's modified form:

Code:

#!/bin/sh

## This is for ffp (Fonz' Fun_Plug) 0.5 modified by SilentException
# write a log, in case sth goes wrong
FFP_LOG=/mnt/HD_a2/ffp.log
exec >>$FFP_LOG 2>&1

# Prepare terminal (simplified fun_plug, based on 0.4)
# maybe not needed, cannot do any harm tho :)
if [ ! -e "/dev/ptmx" ]; then
mknod -m 0666 /dev/ptmx c 5 2
fi
if [ ! -d "/dev/pts" ]; then
mkdir -p /dev/pts
fi
mount | grep devpts 1>/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
mount -t devpts devpts /dev/pts
fi

# Replace busybox
cp -f /mnt/HD_a2/ffp/share/e2fsck/busybox /bin

# Set up telnetd
ln -snf /bin/busybox /sbin/telnetd

# Start telnetd
/sbin/telnetd -l /bin/sh

# Create killall for choking smbd and nmbd
ln -s /bin/busybox /bin/killall
ln -s /bin/busybox /sbin/fdisk

# Copy newer version of e2fsck
cp -f /mnt/HD_a2/ffp/share/e2fsck/e2fsck /sbin
cp -f /mnt/HD_a2/ffp/share/e2fsck/badblocks /sbin
rm -r /lib/libext2fs.so*
cp -f /mnt/HD_a2/ffp/share/e2fsck/libext2fs.so.2.4 /lib
ln -s /lib/libext2fs.so.2.4 /lib/libext2fs.so
ln -s /lib/libext2fs.so.2.4 /lib/libext2fs.so.2
cp -f /mnt/HD_a2/ffp/share/e2fsck/libcom_err.so.2.1 /lib/
ln -s /lib/libcom_err.so.2.1 /lib/libcom_err.so.2
ln -s /lib/libcom_err.so.2.1 /lib/libcom_err.so

# Run this manually from the command line
# Do not ever kill samba in fun plug
#
# killall smbd
# killall nmbd
# umount /dev/md0
# e2fsck /dev/md0
#
# or
#
# umount /dev/md0
# e2fsck -v -f -c /dev/md0
# you could also add the -y flag to answer yes to any questions, but you might not want that...
# or
# badblocks -v -s -n /dev/md0

You'll still need to download the package from SilentException from here http://dns323.kood.org/forum/p14563-Tod … tml#p14563
but replace the fun_plug.disk_check with this one. Place them in /mnt/HD_a2 as instructed there and manually unpack the e2fsck....tgz and so forth.

This script is generally for temporary use to create a modified environment to allow for the disk check, so likely you'll want to do something like this

Code:

cd /mnt/HD_a2
mv fun_plug fun_plug.normal
cp fun_plug.disk_check fun_plug
chmod a+x fun_plug
reboot

You'll now have a minimal environment with only a telnet shell. Login via telnet and run the 2 killall commands listed, and the umount. Then choose one of the e2fsck or badblocks commands you want to run...then wait, and wait, and wait, etc...

When it's done you can remount your drive like so:

Code:

mount /dev/md0 /mnt/HD_a2
cd /mnt/HD_a2

## swap your fun_plug scripts
mv fun_plug fun_plug.disk_check

## or if you did a "cp fun_plug.disk_check fun_plug" previously
# rm fun_plug

cp fun_plug.normal fun_plug

## make sure fun_plug is executable
chmod a+x fun_plug

## reboot to get back to your normal environment
reboot

big_smile

Last edited by SuperInsanity (2008-05-11 23:11:22)

Offline

 

#27 2008-05-13 22:18:10

gartylad
Member
Registered: 2007-01-15
Posts: 30

Re: Modified fun_plug for disk maintenance

Please help

Really wanted to run the full test as I know I have errors.

Following all above:

killall smbd
killall nmbd
umount /dev/md0
e2fsck /dev/md0

but then got the following message

***********************************************
e2fsck: Invalid argument while trying to open /dev/md0

The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
***********************************************

Unable to mount the drive, due to following error

***********************************************
/ # mount /dev/md0 /mnt/HD_a2
/dev/md0: Invalid argument
mount: /dev/md0: can't read superblock
***********************************************

and I dont want to reboot incase it all goes pear shaped!!

Is there anyway to fix a superblock error???

What are the chances of the DNS returning to its normal state if I reboot (as I have not changed any files on the disk)???

Last edited by gartylad (2008-05-14 00:26:03)

Offline

 

#28 2008-05-14 00:56:27

gartylad
Member
Registered: 2007-01-15
Posts: 30

Re: Modified fun_plug for disk maintenance

UPDATE from post above

Took the plundge and rebooted the DNS, all started fine.

just running a `cp` copy from one drive to the other, may give a full reformat and start fresh. (always nice)

A shame that theres no CheckDisk function built in to the DNS, I read in the forum about a firmware that had scandisk built in (1.05b3 I think) did that ever happen?? Would be nice to perform regular maintenance on the file system.

Food for thought, as my mum always says

Offline

 

#29 2008-07-11 15:20:48

thomaskunze
Member
Registered: 2008-06-03
Posts: 14

Re: Modified fun_plug for disk maintenance

Can someone please re-upload SilentException's package?
TNX!

Last edited by thomaskunze (2008-07-11 18:38:47)

Offline

 

#30 2008-07-19 11:32:17

sunnyboy
New member
Registered: 2008-07-19
Posts: 1

Re: Modified fun_plug for disk maintenance

Hallo,
i also need this package, is it possibe to re-upload or send me this file?

thx very much.

Patrick

Offline

 

#31 2008-07-19 15:15:09

SilentException
Member
From: Island of Krk, Croatia
Registered: 2008-05-04
Posts: 148

Re: Modified fun_plug for disk maintenance

here you go mates. better and improved version i'm currently using

put the archive in HD_a2 (samba, ftp, whatever)

telnet in, remove old files
# rm -rf /ffp/share/e2fsck

position yourself in HD_a2
# cd /mnt/HD_a2

unpack the archive
# tar xvzf e2fsck.tgz

the directory /ffp/share/e2fsck should be recreated and there should be fun_plug.disk_check in HD_a2

rename your current fun_plug to fun_plug.original
# mv fun_plug fun_plug.original

rename fun_plug.disk_check to fun_plug
# mv fun_plug.disk_check fun_plug

restart, telnet in, and you have disk check environment (follow the instructions at the end of the fun_plug.disk_check)
upon boot, the script automatically restores your old .original fun_plug so you dont have to take care of it

i hope i didnt forget anything, let me know how it goes wink

http://rapidshare.com/files/130858488/e2fsck.tgz.html

enjoy!

Last edited by SilentException (2008-07-19 15:16:37)


D-Link DNS-323 v1.05 fun_plug-ed + many mods,  2 x 320GB Seagate Barracuda 7200.10 RAID0, Cat6 Gigabit Network, 9k Jumbo Frames, Average (WRITE): 19,32 MB/sec, Average (READ): 28,6 MB/sec

Offline

 

#32 2008-07-19 16:37:20

thomaskunze
Member
Registered: 2008-06-03
Posts: 14

Re: Modified fun_plug for disk maintenance

SilentException wrote:

i hope i didnt forget anything, let me know how it goes wink

Hi, thank you very much for sharing!

Unfortunately, I did not get it to work:

/mnt/HD_a2 # umount /dev/md0
umount: /mnt/HD_a2: device is busy
umount: /mnt/HD_a2: device is busy

I killed nearly every daemon but the error persists sad

/mnt/HD_a2 # ps
PID   USER     COMMAND
    1 root     init
    2 root     [ksoftirqd/0]
    3 root     [events/0]
    4 root     [khelper]
    5 root     [kthread]
   11 root     [kblockd/0]
   14 root     [khubd]
   50 root     [pdflush]
   51 root     [pdflush]
   53 root     [aio/0]
   52 root     [kswapd0]
  190 root     [scsi_eh_0]
  191 root     [scsi_eh_1]
  201 root     [mtdblockd]
  219 root     [kcryptd/0]
  220 root     [kmirrord/0]
  232 root     [loop0]
1107 root     [md0_raid1]
1379 root     SyncMms
1380 root     getMsg
1392 root     -sh
1500 root     /sbin/telnetd -l /bin/sh
1511 root     /bin/sh
1551 root     ps

Any ideas?

Offline

 

#33 2008-07-19 17:13:12

SilentException
Member
From: Island of Krk, Croatia
Registered: 2008-05-04
Posts: 148

Re: Modified fun_plug for disk maintenance

lol

try to do cd .. wink


D-Link DNS-323 v1.05 fun_plug-ed + many mods,  2 x 320GB Seagate Barracuda 7200.10 RAID0, Cat6 Gigabit Network, 9k Jumbo Frames, Average (WRITE): 19,32 MB/sec, Average (READ): 28,6 MB/sec

Offline

 

#34 2008-07-20 03:56:03

thomaskunze
Member
Registered: 2008-06-03
Posts: 14

Re: Modified fun_plug for disk maintenance

SilentException wrote:

try to do cd .. wink

Sorry, I don't get it (I'm a linux noob!)... cd .. where to? Even cd / did not work...
I tried fuser -m /dev/md0 (the only option that seems reasonable) to check on used files etc. but there was no return either.

Offline

 

#35 2008-07-20 11:46:26

silversurfer
Member
Registered: 2008-07-20
Posts: 95

Re: Modified fun_plug for disk maintenance

Thomas,

try to use:

lsof | grep HD

Offline

 

#36 2008-07-20 16:52:11

thomaskunze
Member
Registered: 2008-06-03
Posts: 14

Re: Modified fun_plug for disk maintenance

silversurfer wrote:

lsof | grep HD

Silversurfer,

thank you very much for your hint! I tracked down the "bugger":

/ # lsof | grep HD
telnetd   1500 root  cwd       DIR        9,0   4096         2 /mnt/HD_a2

This is strange, since telnetd seems to be the run from /sbin:

1500 root     /sbin/telnetd -l /bin/sh


I'm still stuck.

Offline

 

#37 2008-07-20 19:11:04

silversurfer
Member
Registered: 2008-07-20
Posts: 95

Re: Modified fun_plug for disk maintenance

I believe that I know what is causing your problem. Your telnet was started from /mnt/HD_a2. The ps command will only show you the path and the executable ( /sbin/telnetd ) as well as the shell it was started with ( /bin/sh ) but not from where.
The script which started telnet was run from /mnt/HD_a2, probably the modified funplug.

Maybe it helps to change the start of telnet a bit. In the funplug change:

Code:

# Start telnetd
/sbin/telnetd -l /bin/sh

to

Code:

# Start telnetd
cd /
/sbin/telnetd -l /bin/sh

Good luck!

Offline

 

#38 2008-07-20 19:49:28

thomaskunze
Member
Registered: 2008-06-03
Posts: 14

Re: Modified fun_plug for disk maintenance

silversurfer wrote:

Maybe it helps to change the start of telnet a bit. In the funplug change:

Code:

# Start telnetd
/sbin/telnetd -l /bin/sh

to

Code:

# Start telnetd
cd /
/sbin/telnetd -l /bin/sh

Good luck!

Thank you very much, your valuable hints helpt me out to get it working finally!

Last edited by thomaskunze (2008-07-20 19:49:49)

Offline

 

#39 2008-07-31 11:05:30

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

Re: Modified fun_plug for disk maintenance

skydreamer wrote:

# Do not ever kill samba in fun plug

What's the problem with killing samba in fun_plug?

Offline

 

#40 2008-07-31 12:07:48

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

Re: Modified fun_plug for disk maintenance

I had a small idea recently how this approach might become simpler to use.

You're copying busybox, e2fsck and libs to/over the firmware files in /sbin, /lib, etc. You're clearly restricted in how much you copy by the remaining free space in the ramdisk (2M on my box). Also, you need to swap fun_plug scripts, and a reboot to enter the filesystem check mode.

I think it's possible to increase the ramdisk size, and to switch to the fsck tools in ramdisk without swapping fun_plug scripts and without reboot. Here's the idea.

Instead of adding/replacing files in the firmware ramdisk, create a separate, ram-based, tree using tmpfs:

Code:

mkdir /fsck
mount -t tmpfs tmpfs /fsck

I don't know the exact limits, but in a quick test, I could easily put 30MB into /fsck before getting out of space errors. Of course, the more you put in /fsck the less RAM you will have to run programs - but there's pleanty of swap, and speed isn't that important for fsck.

Next step is to populate /fsck with the filesystem check tools. For simplicity of the description, I'll use my filesystem check ramdisk archive ( http://www.inreto.de/dns323/fsck/fsck-initramfs.gz ), but this can easily be replaced with something different. To unpack the archive, you need the cpio-2.9 package (busybox's cpio doesn't support the 'newc' cpio archive format).

Code:

cd /fsck
zcat /ffp/fsck/fsck-initramfs.gz | cpio -id

fsck-initramfs.gz is actually ffp again. It contains an ffp directory where all the programs are installed. This way, we can later relink  /ffp to /fsck/ffp to switch to the filesystem check tools in RAM.

Approach 1 Using the above simple steps, and a slightly modified fun_plug can already be sufficient. Some Linux distributions allow the user the set a flag (by creating some special file, e.g. /ffp/etc/run-fsck) to trigger a filesystem check after reboot. A modified fun_plug script could check for such a flag file, and if found, do the steps above, link /ffp to /fsck/ffp (instead of /mnt/HD_a2/ffp) and proceed as normal (i.e. run /ffp/etc/rc). The ffp installed in fsck-initramfs.gz will start a telnet server. You should then be able to log in as usual and do your filesystem check after killing samba. The modified fun_plug script should remove the special flag file, so the next boot will be back to normal.

Approach 2 A little more tricky approach is needed to switch to /fsck/ffp on demand, without reboot and flag file. We need to stop all processes that keep the disks busy. Unfortunately, this includes killing the telnet/ssh server that we're connected to. Here's a sketch of a bash script ( http://www.inreto.de/dns323/fun-plug/0. … .html#bash ):

Before killing processes, we need to detach so killing the telnet server won't kill the script, too:

Code:

cd /tmp
exec >/dev/console 2>&1 </dev/null
trap 'echo HUP' HUP

We cd to /tmp to ensure that the current working directory is on the ramdisk. The 'exec' command will redirect script output to the console (serial port), detaching from the telnet session. 'trap' will catch the 'hangup signal' that, if not trap'ped, would terminate the script when the telnet/ssh server dies.

Now stop the currently running ffp:

Code:

reverse_list()
{
        _list=
        while [ $# -gt 0 ]; do
                _list="$1 $_list"
                shift
        done
        echo $_list
}
files=$(reverse_list $(rcorder /ffp/start/*.sh))
for f in $files; do
        if [ -x "$f" ]; then
                echo "$f stop"
                $f stop
        fi
done

'reverse_list' is a simple helper function to reverse the order of the start scripts. It's used to run the scripts in /ffp/start in reverse order.

If desired/necessary, we can now kill everything that's left:

Code:

killall5 -TERM
sleep 2
killall5 -KILL
sleep 1

'killall5' is an oldish, but useful utility, that kills everything except us.

The remainder is straight forward: unmount disks, relink /ffp, start it

Code:

sync
for f in /mnt/HD_*; do
        umount $f
done

ln -snf /fsck/ffp /ffp
/ffp/etc/rc

What do you think?

Offline

 

#41 2008-09-19 18:50:16

waal70
Member
Registered: 2008-09-19
Posts: 7

Re: Modified fun_plug for disk maintenance

fonz wrote:

What do you think?

Works like a charm for me (I am on a CH3SNAS, ffp 0.5, firmware 1.04rc5). I went with the on-line flip-flopping of the ffp-runtime (no reboot required).

Did not do the umount in the script, though. I wanted to experience the joy of unmounting /dev/sda2 myself smile

After fs-check is complete, I created a script to flip-flop back to the original situation.

Fonz, great script, good idea, thanks for helping me get underway!

Offline

 

#42 2008-09-20 17:25:01

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

Re: Modified fun_plug for disk maintenance

waal70 wrote:

Works like a charm for me (I am on a CH3SNAS, ffp 0.5, firmware 1.04rc5). I went with the on-line flip-flopping of the ffp-runtime (no reboot required).

Thanks for confirming that it actually works. Mind sharing your scripts?

Offline

 

#43 2008-09-21 02:46:11

waal70
Member
Registered: 2008-09-19
Posts: 7

Re: Modified fun_plug for disk maintenance

fonz wrote:

Mind sharing your scripts?

Nope, not at all...

These scripts are all in a JMIW-stage, so be warned: these could do with some beautify-ing smile

Here goes:

First of all, to start disk maintenance, I SSH to the device and manually start filecheck.sh, which looks like this:

Code:

#!/bin/sh

# set variables for logfile and bin-dirs:
log=/mnt/HD_a2/prepareFS.log
bindir=/ffp/bin

# first, kill memory hoggers:
$bindir/killall twonkymedia
$bindir/killall ntpd

# then, prepare the temporary fs:
mkdir /fsck
$bindir/mount -t tmpfs tmpfs /fsck

# then, populate the temporary fs:
cd /fsck
zcat /ffp/fsck/fsck-initramfs.gz | cpio -id

# Not forgetting our restore-script (TODO: add to fs-zip)
cp /mnt/HD_a2/restore.sh /fsck/ffp/bin/

# Also, BASH is not in the image (TODO: add to fs-zip)
cp /ffp/bin/bash /fsck/ffp/bin/

# Not sure if BASHBUG is needed, copy anyway...
cp /ffp/bin/bashbug /fsck/ffp/bin/

# Before we die, save a current crontab copy:
/bin/crontab -l > /mnt/HD_a2/crontab_fs.txt

# now, call bash script for the magic:

/ffp/bin/bash /mnt/HD_a2/swap.sh

As you can see, this calls swap.sh, which looks like:

Code:

#!/ffp/bin/bash

# Gratuitous debug-notice:
echo "in the bash script now: " $SHELL

# make sure we are on the memory-part of the fs:
cd /tmp
# detach the script output from the shell it's started in:
exec >/dev/console 2>&1 </dev/null
# ignore the HangUP-signal to keep this script running
# after the shell was killed
trap 'echo HUP' HUP

reverse_list()
{
        _list=
        while [ $# -gt 0 ]; do
                _list="$1 $_list"
                shift
        done
        echo $_list
}
files=$(reverse_list $(rcorder /ffp/start/*.sh))
for f in $files; do
        if [ -x "$f" ]; then
                echo "$f stop"
                $f stop
        fi
done

# try an umount. check this after logging in again
# (telnet only). use 'fuser -m /mnt/HD_a2/ffp.log'
sync
for f in /mnt/HD_*; do
        umount $f
done

# replace the link to /ffp to the memory drive...
ln -snf /fsck/ffp /ffp
/ffp/etc/rc

So far so good. On my device, however, most of the times the umount /mnt/HD_a2 command needs to be repeated. Right now I lost the SSH-session, so I can only use less secure telnet to go the device. For me this is okay, luckily, e2fsck is not necessary all that often and right now I could not really be bothered with changing the temp fs to also do the SSH-thing. Still, it could be considered a TO-DO...

Anyway, now is the time to do the magic. Call all your favourite fs-check tools. I usually just stick with the e2fsck one. Wait the fs-check programs out patiently...

Then, it gets time to restore the device to its old glory, which I do by manually calling the restore.sh script, which looks like:

Code:

#!/ffp/bin/bash

# this is the RESTORE SCRIPT:

echo "in the bash script now: " $SHELL

# make sure we are on the memory-part of the fs:
cd /tmp
# detach the script output from the shell it's started in:
exec >/dev/console 2>&1 </dev/null
# ignore the HangUP-signal to keep this script running
# after the shell was killed
trap 'echo HUP' HUP

reverse_list()
{
        _list=
        while [ $# -gt 0 ]; do
                _list="$1 $_list"
                shift
        done
        echo $_list
}
files=$(reverse_list $(rcorder /ffp/start/*.sh))
for f in $files; do
        if [ -x "$f" ]; then
                echo "$f stop"
                $f stop
        fi
done

# No good at creating lists yet, so perform a 'manual' mount of the devices:
mount -t ext2 /dev/sda2 /mnt/HD_a2
mount -t ext2 /dev/sda4 /mnt/HD_a4
mount -t ext2 /dev/sdb2 /mnt/HD_b2
mount -t ext2 /dev/sdb4 /mnt/HD_b4

# replace the link to /ffp back to the actual drive...
ln -snf /mnt/HD_a2/ffp /ffp

#And kick-start the original ffp:
/mnt/HD_a2/fun_plug

# now restore the crontab:
/bin/crontab /mnt/HD_a2/crontab_fs.txt
/bin/rm /mnt/HD_a2/crontab_fs.txt

# Let's hope all went well, and umount the temp fs:
umount /fsck
rmdir /fsck

Now, the whole process is reversed. You are kicked out of the telnet session and it's swapping back to HD_a2.
For me, that means I can login through SSH again. Only action left after that is checking some stuff:
Try 'mount' to see what is mounted. Make sure the tempfs is unmounted. The umount at the end of the restore-script seemed to not always be (correctly) executed, in which case I'd do the umount myself. Also, if you have the editcron.sh-script to modify your cron-jobs, check 'crontab -l' to see whether there are no duplicate entries. The script provides for a mechanism to prevent this, but check and confirm!

Note to RAID-config-users: I have two disks that are not configured in a RAID-array. I'm not sure if just the remounting alone will also restore the array, so be careful applying this to a device with a RAID-config.

Happy FS-checking, and thanks again fonz for putting me on the right track!

Last edited by waal70 (2008-09-21 03:21:16)

Offline

 

#44 2008-09-22 00:29:23

puterboy
Member
Registered: 2008-09-18
Posts: 306

Re: Modified fun_plug for disk maintenance

Well this may be cheating, but one way to avoid all this is to use a cheap USB stick and run fun_plug from there. Then you can unmount the drives at will and have the full power of the fun_plug add-ins.

I use the following version of setup.sh which must be placed in /mnt/HD_a2/.bootstrap (unless you modify the location defined in the default fun_plug script). The goal here was to write a script that requires no modification of fun_plug.
Note the section on redirecting the logging to a log directory is optional -- I only do it to clean up the root directory of HD_a2.

All you need to do is format a usb disk in ext2 and make sure that the shell variable USBPART is set correctly. You also need the module usb-storage.ko which I place in the directory /mnt/HD_a2/.bootstrap but can be changed using the shell variable USBMODULE

To boot from the usb disk, just "touch" (i.e. create) the file .usb-boot in the root directory of the usb disk. To go back to "standard" booting from the hard drive either remove the file .usb-boot or remove the usb disk

Note that I *purposely* formatted an ext2 partition on /dev/sdc5 since that will avoid confusion/conflicts with standard default vfat-formatted usb disks that usually used /dev/sdc1. But you can choose any partition number if you change the variable USBPART.

[NOTE I would have *loved* to use mount -U <UUID> but the version of mount on the dns-323 doesn't support it]

NOTE: most of the script consists of sanity tests.


#!/bin/sh
### setup.sh - Custom initialization script
USBMODULE=/mnt/HD_a2/.bootstrap/usb-storage.ko
USBPART=/dev/sdc5
USBMOUNT=/mnt/usb
LOGDIR=/mnt/HD_a2/log

# Redirect boot logging
[ -z $FFP_LOG ] && FFP_LOG=/mnt/HD_a2/ffp.log
OLDFFP_LOG=$FFP_LOG
FFP_LOG=$LOGDIR/ffp.log
touch $FFP_LOG 2> /dev/nul
if [ -d $LOGDIR -a -w $FFP_LOG ] ; then
     cp $FFP_LOG ${FFP_LOG}.bak
     [ -r $OLDFFP_LOG ] && cat $OLDFFP_LOG >> $FFP_LOG
     exec >>$FFP_LOG 2>&1
     [ -w $OLDFFP_LOG ] && rm -f $OLDFFP_LOG
fi

# Install usb module
( /usr/sbin/lsmod | grep -q usb_storage )
RETVAL=$?
if [ "$RETVAL" -eq 1 ] ; then
    /usr/sbin/insmod $USBMODULE
    sleep 60  # Wait for disk to be recognized
fi

mkdir -p -m 755 $USBMOUNT
( /bin/mount | grep -q $USBPART ) || \
  /bin/mount $USBPART -t ext2 $USBMOUNT 2>/dev/null
RETVAL=$?
if [ "$RETVAL" -eq 1 ] ;then
    echo "Failed to mount $USBPART on $USBMOUNT"
    exit
fi

/bin/mount | grep -q "$USBPART on $USBMOUNT type ext2 (rw)" 2>/dev/null
RETVAL=$?
if [ "$RETVAL" -eq 0 -a -f $USBMOUNT/.usb-boot -a -d $USBMOUNT/ffp ] ; then
    echo Booting from usb...
    FFP_PATH=$USBMOUNT/ffp
else
    echo Booting from /mnt/HD_a2/ffp...
fi

Offline

 

#45 2008-09-22 01:01:52

waal70
Member
Registered: 2008-09-19
Posts: 7

Re: Modified fun_plug for disk maintenance

Maybe that is a bit cheating, yes smile

Nice script, though I think it has a separate purpose.
The whole flip-flopping exercise, in my case, was meant to be able to unmount the disks without rebooting the unit and without editing the fun_plug script.

If I understand your script correctly, it always requires a re-boot, or, always booting with the USB-stick.

Offline

 

#46 2008-09-22 05:21:51

puterboy
Member
Registered: 2008-09-18
Posts: 306

Re: Modified fun_plug for disk maintenance

waal70 - you are correct - but it is still a safe and easy alternative to allowing user to unmount the main disk partitions.

Offline

 

#47 2008-10-23 08:23:53

sarge_in
Member
Registered: 2008-10-09
Posts: 16

Re: Modified fun_plug for disk maintenance

SilentException wrote:

here you go mates. better and improved version i'm currently using

put the archive in HD_a2 (samba, ftp, whatever)

telnet in, remove old files
# rm -rf /ffp/share/e2fsck

position yourself in HD_a2
# cd /mnt/HD_a2

unpack the archive
# tar xvzf e2fsck.tgz

the directory /ffp/share/e2fsck should be recreated and there should be fun_plug.disk_check in HD_a2

rename your current fun_plug to fun_plug.original
# mv fun_plug fun_plug.original

rename fun_plug.disk_check to fun_plug
# mv fun_plug.disk_check fun_plug

restart, telnet in, and you have disk check environment (follow the instructions at the end of the fun_plug.disk_check)
upon boot, the script automatically restores your old .original fun_plug so you dont have to take care of it

i hope i didnt forget anything, let me know how it goes wink

http://rapidshare.com/files/130858488/e2fsck.tgz.html

enjoy!

Hello,

I recently saw "running e2fsck is recommended" messages in my syslog messages. So followed this thread and did the above. However, I am getting the same errors as gartylad reported above:


***********************************************
e2fsck: Invalid argument while trying to open /dev/md0

The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
***********************************************

Unable to mount the drive, due to following error

***********************************************
/ # mount /dev/md0 /mnt/HD_a2
/dev/md0: Invalid argument
mount: /dev/md0: can't read superblock
***********************************************

Please help!

Don't know if it matters that my volumes are setup in standard mode?!

TIA!

UPDATE:
I re-did the above, but now:

------------
/ # umount /dev/sda1
umount: /dev/sda1: not mounted
/ # e2fsck /dev/sda1
e2fsck 1.40.6 (09-Feb-2008)
/dev/sda1 is mounted.

WARNING!!!  Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.

Do you really want to continue (y/n)? no

check aborted.
--------------

Should I go ahead with the check anyways?!

Last edited by sarge_in (2008-10-23 08:46:19)

Offline

 

#48 2008-10-23 10:49:03

waal70
Member
Registered: 2008-09-19
Posts: 7

Re: Modified fun_plug for disk maintenance

sarge_in wrote:

e2fsck 1.40.6 (09-Feb-2008)
/dev/sda1 is mounted.

WARNING!!!  Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.

Do you really want to continue (y/n)? no

check aborted.
--------------

Should I go ahead with the check anyways?!

Hi sarge_in,
Never ever ever ever run e2fsck on a mounted filesystem, unless you're a super-expert and know exactly what you are doing. You could seriously damage your filesystem by running it on an mounted FS! The warning is there for a good reason.
Unmounting should always be possible (...), no matter what difficulty you have in doing the actual unmount. It's just a matter of troubleshooting up to the point of finding what is preventing an unmount. So that's where we're at with your situation right now...

You say you've followed the thread and used the replace/move of the original fun_plug. A bit later in the thread there is a suggestion on how to do this without actually replacing your fun_plug (that's where I start meddling in the thread as well). Could you also try this method to see what happens?

Hang on in there, chances are the "e2fsck is recommended" is not indicative of a serious problem (yet). I guess there are literally 1000s of people running their NAS'es with this (unseen) message. So take your time in figuring it out (for example try the alternative unmount suggested above) and resist the temptation of running e2fsck on a mounted volume!

Cheers!

Last edited by waal70 (2008-10-23 10:50:59)

Offline

 

#49 2008-10-24 02:32:26

sarge_in
Member
Registered: 2008-10-09
Posts: 16

Re: Modified fun_plug for disk maintenance

Hi waal70,

I gave your method a shot but ran into errors. Something about /ffp/bin/bash not being available (I think, but not 100% sure).

I then got here: http://www.inreto.de/dns323/fsck/  and decided to give this a shot. This turned out to be fairly straighforward (esp for a n00b like me smile), and ran e2fsck on sda2 and sdb2. Got 4-5 errors on each and said Yes to fix. But when I rebooted, I still got 'e2fsck recommended' messages for sda4 and sdb4. So ran on them again and those got cleared as well this time. However, I am still getting one more 'e2fsck recommneded' message here:

----------------------------------------------
.
.
RedBoot partition parsing not available
Using physmap partition definition
Creating 5 MTD partitions on "phys_mapped_flash":
0x00000000-0x00010000 : "MTD1"
0x00010000-0x00020000 : "MTD2"
0x00020000-0x001a0000 : "Linux Kernel"
0x001a0000-0x007d0000 : "File System"
0x007d0000-0x00800000 : "u-boot"
ehci_platform ehci_platform.20865: EHCI Host Controller
ehci_platform ehci_platform.20865: new USB bus registered, assigned bus number 1
ehci_platform ehci_platform.20865: irq 17, io mem 0x00000000
ehci_platform ehci_platform.20865: park 0
ehci_platform ehci_platform.20865: USB 0.0 initialized, EHCI 1.00, driver 10 Dec 2004
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
ohci_hcd: 2004 Nov 08 USB 1.1 'Open' Host Controller (OHCI) Driver (PCI)
mice: PS/2 mouse device common for all mice
md: linear personality registered as nr 1
md: raid0 personality registered as nr 2
md: raid1 personality registered as nr 3
md: md driver 0.90.1 MAX_MD_DEVS=256, MD_SB_DISKS=27
device-mapper: 4.4.0-ioctl (2005-01-12) initialised: dm-devel@redhat.com
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
NET: Registered protocol family 1
NET: Registered protocol family 17
md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.
RAMDISK: Compressed image found at block 0
EXT2-fs warning: maximal mount count reached, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem).
Freeing init memory: 112K
SCSI device sda: 1953525168 512-byte hdwr sectors (1000205 MB)
SCSI device sda: drive cache: write back
SCSI device sda: 1953525168 512-byte hdwr sectors (1000205 MB)
SCSI device sda: drive cache: write back
sda: sda1 sda2 sda4
.
.
----------------------------------------------

So, the question I now have is:
1. Is having sda4 and sdb4 'normal'? None of the posts I have seen here seem to reference them.
2. I also see a sda1 and sdb1 in log messages. Is that normal, and do I need to run e2fsck on them as well?
3. Will (2) take care of the 1 last e2fsck message I am getting? And if not, what am I missing?!

Thanks!!

Last edited by sarge_in (2008-10-24 02:33:55)

Offline

 

#50 2008-10-24 14:56:11

waal70
Member
Registered: 2008-09-19
Posts: 7

Re: Modified fun_plug for disk maintenance

sarge_in wrote:

RAMDISK: Compressed image found at block 0
EXT2-fs warning: maximal mount count reached, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem).

So, the question I now have is:
1. Is having sda4 and sdb4 'normal'? None of the posts I have seen here seem to reference them.
2. I also see a sda1 and sdb1 in log messages. Is that normal, and do I need to run e2fsck on them as well?
3. Will (2) take care of the 1 last e2fsck message I am getting? And if not, what am I missing?!

Thanks!!

Hi sarge_in,

Looks like you did a nice job troubleshooting your situation. The BASH-error may be related to not having the actual BASH (shell) available on your system. To do this, you should get the bash-package (http://www.inreto.de/dns323/fun-plug/0. … -3.2-3.tgz) from Fonz's site and install it. 'My' script will then take care of putting it in the right location.
Anyway, this for future reference, as you already seemed to manage quite well with an alternative.

Now for your questions:
1. Yes, having sda4 and sdb4 is quite normal (they're also on my system). I believe these devices have the swap volumes for the drives configured on them. e2fsck'ing them is also perfectly normal.

2. I don't think I have those, I certainly never ran an e2fsck on them. If they are proper drive-devices (like sdb2 and sdb4), e2fsck will inform you whether it is safe to run on there and there is no harm in doing so.

3. The answer is no, but OK, bear with me on this one, as it requires a little more text and could be a tough read:
I think the last e2fsck message you're getting is related to a volume that gets mounted from a fixed image.
Allow me to elaborate: Think of an .ISO file for CDs. The .ISO actually represents a whole filesystem, which is pretty obvious to see after you've burned this image.
The DNS-323's so-called 'root volume' gets loaded from your device's firmware (like from an .ISO). So there is a 'whole filesystem' somewhere in the firmware image, which on device boot-up gets loaded ("burned") into the device's memory. If you shut down the device, power will be lost on the memory and therefore the 'burned filesystem' will be lost from memory.
After you reboot the device, the cycle starts again, putting the root volume image back into memory again. The OS, Linux, doesn't really care if the filesystem it's using is on a HDD, or is actually more like a RAM-drive. As far as the OS is concerned, it is a proper volume.
If you were to create a file on this root-volume, you would notice that it would disappear after powerdown. This is due to the fact that the file you created is actually not in the filesystem image (it's not in the ISO, it's not in the firmware), and therefore on a reload of this image it will not return. This is also the reason why the things like Fonz's fun plug are based on an 'actual' drive, ensuring any changes you make will be kept after powerdown (this is I think core business for any HDD wink ).
So the thing to remember is that any change to this filesystem will be canceled upon reboot.

Now here is the catch: as you would with creating an ISO, this volume was probably created using another system and the developers probably went through several cycles in improving the image. In doing so, they could have affected things like mount-count, filesystem integrity, e2fsck status etc. If they then went on and created the image from this system without first running e2fsck, these things would get imprinted into the image. You could go ahead and fix those errors, but on every reboot, the image would be reloaded and since all changes to this volume are canceled upon reboot, also the filesystem-fix changes would be canceled.

So in short, it looks like the error is coming from the root volume (check the neighboring lines for the last e2fsck-message in your logfile), but since this is a fixed image (embedded somewhere in the firmware), there is no way to permanently fix this, unless you would create your own firmware and/or we are provided with a new firmware without these FS-errors.

To re-cap: I don't think this last e2fsck is coming from the sda1/sdb1 devices, but rather from the device's firmware, so e2fsck'ing them will not clear the error. e2fsck'ing the root volume is quite an arduous task I think, and any effort you put in, will be lost on reboot, so I think you'll have to live with this error. The good part is that the errors cannot lead to any permanent damage, as you start off with a brand new root-volume every time. This could also be the reason the firmware-guys left it in: if it is not in any way degrading functionality now, it will never 'grow' to be a bigger problem and therefore safe to keep in.

That's a long story, hope it helped clear things up a little.

Cheers

Last edited by waal70 (2008-10-24 15:06:37)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB