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.

#1 2008-02-20 01:48:57

skydreamer
Member
From: At the Atlantic Coast
Registered: 2007-01-06
Posts: 232

Modified fun_plug for disk maintenance

I was curious if my 1TB 70% full RAID1 has developed any file system errors and perhaps there are a few members on this forum with the same interests?

So where to start: We all well know the fantastic fun_plug now in version 0.4 that makes our D-link devices so much better storage boxes.
Unfortunately, since it runs most of the programs from the mounted hard disks it prevents them from being unmounted cleanly.

Hence the idea of creating a much simplified version, that will overcome this issue and will allow manipulation of the disks from the command line.

The script is in the second post and expects the fun_plug 0.4 to be installed in the default directory.

I suppose that the script can be used for much more than just file system checks, you can cleanly reassemble your disk arrays and do all sorts of operations on them.

Well good luck and do not break anything ;-)

SD

Last edited by skydreamer (2008-02-20 01:50:45)

Offline

 

#2 2008-02-20 01:50:11

skydreamer
Member
From: At the Atlantic Coast
Registered: 2007-01-06
Posts: 232

Re: Modified fun_plug for disk maintenance

#!/bin/sh

# Revision 080219 by Skydreamer                       
# You must have installed funplug 0.4                 
                                                     
# Prepare terminal (simplified fun_plug, based on 0.4)
                               
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                                             
                                             
# Copy telnet                                 
                                             
cp -f /mnt/HD_a2/fun_plug.d/sbin/telnetd /sbin
                                             
# Replace busybox                           
                                             
cp -f /mnt/HD_a2/fun_plug.d/bin/busybox /bin
                                             
# Start telnet                               
                                             
/sbin/telnetd -l /bin/sh                     
                                             
# Create killall for choking smbd and nmbd   
                                             
ln -s /bin/busybox /bin/killall             
                                             
# Copy newer version of e2fsck                             
                                             
cp -f /mnt/HD_a2/fun_plug.d/sbin/e2fsck /sbin
                                   
# Run manually from the command line
# Do not ever kill samba in fun plug
#               
# killall smbd   
# killall nmbd   
# umount /dev/md0
# e2fsck /dev/md0

Offline

 

#3 2008-02-20 08:13:57

mig
Member
From: Seattle, WA
Registered: 2006-12-21
Posts: 532

Re: Modified fun_plug for disk maintenance

Here is a handy command you can use to check your filesystems, to see if there are problems
which need to be fixed.  This command can be run on a mounted filesystem, since the "-n" option
opens the filesystem read-only, and assume an answer of 'no' to all questions.

Code:

# e2fsck -nv /dev/md0

Last edited by mig (2008-02-20 08:21:47)


DNS-323 2x Seagate Barracuda ES 7200.10 ST3250620NS 250GB SATAII (3.0Gb/s) 7200RPM 16MB RAID1 FW1.03 ext2 
Fonz's v0.3 fun_plug http://www.inreto.de/dns323/fun-plug

Offline

 

#4 2008-02-20 10:43:34

skydreamer
Member
From: At the Atlantic Coast
Registered: 2007-01-06
Posts: 232

Re: Modified fun_plug for disk maintenance

mig wrote:

Here is a handy command you can use to check your filesystems, to see if there are problems
which need to be fixed.  This command can be run on a mounted filesystem, since the "-n" option
opens the filesystem read-only, and assume an answer of 'no' to all questions.

Code:

# e2fsck -nv /dev/md0

Would this not report false positives on open files?

Offline

 

#5 2008-02-20 11:26:46

skydreamer
Member
From: At the Atlantic Coast
Registered: 2007-01-06
Posts: 232

Re: Modified fun_plug for disk maintenance

Hmm, just tested e2fsck on the mounted fs and got two scenarios- one FS appears fine, the other has issues. Actually it reports errors on both partitions but I think it is the second example that I need to worry about.

Fortunately I can just kill off samba and fix the second disk, as it is not being used by the fun_plug

/ # e2fsck -nv /dev/sda2
e2fsck 1.40.2 (12-Jul-2007)
Warning!  /dev/sda2 is mounted.
/dev/sda2 was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found.  Create? no

Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/sda2: ********** WARNING: Filesystem still has errors **********


   40181 inodes used (0.13%)
    5861 non-contiguous inodes (14.6%)
         # of inodes with ind/dind/tind blocks: 34822/21724/0
49522731 blocks used (81.16%)
       0 bad blocks
       0 large files

   36576 regular files
    3323 directories
       0 character device files
       0 block device files
       0 fifos
       0 links
     273 symbolic links (273 fast symbolic links)
       0 sockets
--------
   40172 files

/ # e2fsck -nv /dev/sdb2
e2fsck 1.40.2 (12-Jul-2007)
Warning!  /dev/sdb2 is mounted.
/dev/sdb2 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found.  Create? no

Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong (51172393, counted=51121591).
Fix? no

Free inodes count wrong (30509696, counted=30509653).
Fix? no


/dev/sdb2: ********** WARNING: Filesystem still has errors **********


   13696 inodes used (0.04%)
    4119 non-contiguous inodes (30.1%)
         # of inodes with ind/dind/tind blocks: 12608/376/0
9844485 blocks used (16.13%)
       0 bad blocks
       0 large files

   13482 regular files
     248 directories
       0 character device files
       0 block device files
       0 fifos
       0 links
       0 symbolic links (0 fast symbolic links)
       0 sockets
--------
   13730 files

Offline

 

#6 2008-02-20 11:45:39

skydreamer
Member
From: At the Atlantic Coast
Registered: 2007-01-06
Posts: 232

Re: Modified fun_plug for disk maintenance

skydreamer wrote:

Would this not report false positives on open files?

I can answer myself- it does detect false positives, I ran e2fsck on the unmounted FS and it has not detected any errors.

/ # killall smbd
/ # killall nmbd
/ # df         
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/ram0                 9911      7382      2017  79% /
/dev/sda2            240236224 194259636  45976588  81% /mnt/HD_a2
/dev/sdb2            240236224  35749860 204486364  15% /mnt/HD_b2
/dev/sda4               497861         7    497854   0% /mnt/HD_a4
/dev/sdb4               497861         3    497858   0% /mnt/HD_b4
/ # umount /dev/sdb2
/ # e2fsck -v /dev/sdb2
e2fsck 1.40.2 (12-Jul-2007)
Adding dirhash hint to filesystem.

/dev/sdb2 was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found.  Create<y>? yes

Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/sdb2: ***** FILE SYSTEM WAS MODIFIED *****

   13740 inodes used (0.05%)
    4119 non-contiguous inodes (30.0%)
         # of inodes with ind/dind/tind blocks: 12608/376/0
9895302 blocks used (16.22%)
       0 bad blocks
       0 large files

   13482 regular files
     248 directories
       0 character device files
       0 block device files
       0 fifos
       0 links
       0 symbolic links (0 fast symbolic links)
       0 sockets
--------
   13730 files
/ #

Offline

 

#7 2008-03-12 21:34:03

pof
Member
From: Barcelona
Registered: 2008-03-07
Posts: 28
Website

Re: Modified fun_plug for disk maintenance

A suggested change to the script, if you want to check the hard drives for bad blocks (e2fsck -c) is adding this at the end:

Code:

# Copy newer version of e2fsck
cp -f /mnt/HD_a2/fun_plug.d/sbin/e2fsck /sbin
cp -f /mnt/HD_a2/fun_plug.d/sbin/badblocks /sbin
cp -f /mnt/HD_a2/fun_plug.d/lib/libext2fs.so.2.4 /lib
rm -r /lib/libext2fs.so*      
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/fun_plug.d/lib/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

So you can now do:

# umount /dev/md0
# e2fsck -v -f -c /dev/md0
or
# badblocks -v -s -n /dev/md0

Last edited by pof (2008-03-13 01:39:11)

Offline

 

#8 2008-03-25 19:29:25

bfg100k
Member
Registered: 2007-09-15
Posts: 55

Re: Modified fun_plug for disk maintenance

I just tried this and ran e2fsck on my /dev/sda2 (i couldn't find /dev/md0). When the check completes (it shows a message SYSTEM WAS MODIFIED) it ends with an ERROR/ prompt. When I reboot (by issuing the command reboot on the prompt), I get a warning about the fs not being unmounted cleanly again. Any ideas?

Offline

 

#9 2008-03-25 20:46:37

bfg100k
Member
Registered: 2007-09-15
Posts: 55

Re: Modified fun_plug for disk maintenance

ok. i just found out why.. its the reboot cmd that is causing the problem. FYI, rebooting via the web console seems to ensure that the file systems are cleanly unmounted.

Offline

 

#10 2008-03-26 01:09:45

HaydnH
Member
Registered: 2007-09-28
Posts: 187

Re: Modified fun_plug for disk maintenance

bfg100k wrote:

FYI, rebooting via the web console seems to ensure that the file systems are cleanly unmounted.

I'd be interested to know how you know this for sure, it may not give you errors but that doesn't mean much!

Offline

 

#11 2008-03-26 11:55:10

jayas
Member
Registered: 2008-01-24
Posts: 151

Re: Modified fun_plug for disk maintenance

Hi Skydreamer,

skydreamer wrote:

#!/bin/sh

# Revision 080219 by Skydreamer                       
<snip> 
# Replace busybox                           
                                             
cp -f /mnt/HD_a2/fun_plug.d/bin/busybox /bin

I would not recommend replacing /bin/busybox for two reasons.

The first is that it is linked to /bin/sh and there are shell scripts used by the web interface that fail when a version different version of busybox is used.  This causes side effects that are very difficult to diagnose or debug and possibly undesirable outcomes.

The second is that again the web scripts relay on behaviour of plugins like fdisk as implemented in the original busybox, and which is quite different in the later busybox implementations.

So I do not think it is a good idea to replace any of the utilities unless you are sure that it is not used by the web scripts.  For example I cannot imagine the web scripts using telnet busybox plugin.

Regards,

Jaya


H/W=B1 F/W=1.04; RAID1: SAMSUNG HD501LJ T166 (500GB, SATA 3.0Gb/s 16MB)

Offline

 

#12 2008-03-26 11:57:36

jayas
Member
Registered: 2008-01-24
Posts: 151

Re: Modified fun_plug for disk maintenance

Hi bfg100k,

bfg100k wrote:

I just tried this and ran e2fsck on my /dev/sda2 (i couldn't find /dev/md0). When the check completes (it shows a message SYSTEM WAS MODIFIED) it ends with an ERROR/ prompt. When I reboot (by issuing the command reboot on the prompt), I get a warning about the fs not being unmounted cleanly again. Any ideas?

What command did you use to reboot?  I believe you should be doing "do_reboot" and not "reboot".

Regards,

Jaya


H/W=B1 F/W=1.04; RAID1: SAMSUNG HD501LJ T166 (500GB, SATA 3.0Gb/s 16MB)

Offline

 

#13 2008-03-26 15:35:08

bfg100k
Member
Registered: 2007-09-15
Posts: 55

Re: Modified fun_plug for disk maintenance

HaydnH wrote:

bfg100k wrote:

FYI, rebooting via the web console seems to ensure that the file systems are cleanly unmounted.

I'd be interested to know how you know this for sure, it may not give you errors but that doesn't mean much!

ok, i cannot know that for sure but at least i no longer see the msg "file system was not cleanly unmounted." in the system logs anymore when I reboot via the web interface.

Offline

 

#14 2008-03-26 16:03:14

bfg100k
Member
Registered: 2007-09-15
Posts: 55

Re: Modified fun_plug for disk maintenance

jayas wrote:

Hi bfg100k,

bfg100k wrote:

I just tried this and ran e2fsck on my /dev/sda2 (i couldn't find /dev/md0). When the check completes (it shows a message SYSTEM WAS MODIFIED) it ends with an ERROR/ prompt. When I reboot (by issuing the command reboot on the prompt), I get a warning about the fs not being unmounted cleanly again. Any ideas?

What command did you use to reboot?  I believe you should be doing "do_reboot" and not "reboot".

Regards,

Jaya

well, just "reboot". I did not know about "do_reboot". Will give that a try next time. Thanks!

Offline

 

#15 2008-03-26 17:05:59

skydreamer
Member
From: At the Atlantic Coast
Registered: 2007-01-06
Posts: 232

Re: Modified fun_plug for disk maintenance

jayas wrote:

Hi Skydreamer,

skydreamer wrote:

#!/bin/sh

# Revision 080219 by Skydreamer                       
<snip> 
# Replace busybox                           
                                             
cp -f /mnt/HD_a2/fun_plug.d/bin/busybox /bin

I would not recommend replacing /bin/busybox for two reasons.

The first is that it is linked to /bin/sh and there are shell scripts used by the web interface that fail when a version different version of busybox is used.  This causes side effects that are very difficult to diagnose or debug and possibly undesirable outcomes.

The second is that again the web scripts relay on behaviour of plugins like fdisk as implemented in the original busybox, and which is quite different in the later busybox implementations.

So I do not think it is a good idea to replace any of the utilities unless you are sure that it is not used by the web scripts.  For example I cannot imagine the web scripts using telnet busybox plugin.

Regards,

Jaya

Hi Jayas,

The plugin is meant to be used only temporarily for verification of the ext3 FS consistency through telnet and not for normal work. Otherwise I take your point.
Is fdisk running on your box? I cannot get it working it fails with segfault.

Regards,
SD

Offline

 

#16 2008-04-19 11:00:43

kentsu
Member
Registered: 2008-02-12
Posts: 11

Re: Modified fun_plug for disk maintenance

What am I missing here?

Doing

Code:

umount /dev/md0

Just gives me that device is busy. How are you supposed to use this script really?

Cheers

Offline

 

#17 2008-04-19 11:07:46

kentsu
Member
Registered: 2008-02-12
Posts: 11

Re: Modified fun_plug for disk maintenance

I got it immediately after hitting 'Submit'. I replaced the other 'fun_plug' script with this one.

Hooray.

Offline

 

#18 2008-04-19 15:03:10

jayas
Member
Registered: 2008-01-24
Posts: 151

Re: Modified fun_plug for disk maintenance

Hi Skydreamer

skydreamer wrote:

The plugin is meant to be used only temporarily for verification of the ext3 FS consistency through telnet and not for normal work. Otherwise I take your point.

In my case I actually leave minimal fun_plug running at client sites.  So I guess my requirments are different.  BTW I am able to use this minimal fun_plug (using fonz's build) to do fsck on the drives if needed.

Is fdisk running on your box? I cannot get it working it fails with segfault.

I think the version of busybox they are using requires different arguements for fdisk compared to later versions.   Here is my transcript:

Code:

~ # fdisk -l /dev/sda

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               1          66      530113+ 82 Linux swap
/dev/sda2              67       60638   486544590  83 Linux
~ #

H/W=B1 F/W=1.04; RAID1: SAMSUNG HD501LJ T166 (500GB, SATA 3.0Gb/s 16MB)

Offline

 

#19 2008-05-08 13:23:20

jainoxi
Member
Registered: 2008-05-08
Posts: 7

Re: Modified fun_plug for disk maintenance

I've found a simpler way to e2fsck the filesystem:

1. First, stop all unneeded ffp services with the scripts in /mnt/HD_a2/ffp/start. Leave /ffp/bin/sh, /ffp/sbin/telnetd, /ffp/sbin/syslogd and /ffp/sbin/klogd running. Check with top if there are any services left.
2. Remount the disk read-only: mount /mnt/HD_a2/ -o remount,ro
3. Run e2fsck /dev/md0, this will scan the disk even when mounted.

Offline

 

#20 2008-05-11 01:03:15

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

Re: Modified fun_plug for disk maintenance

Thank you for this script.

I was wondering if it will be updated for ffp 0.5?

My attempt at it messed up my device to the point of needed a hardware reset...so I'd like to leave it in more capable hands!!

Offline

 

#21 2008-05-11 02:29:58

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

Re: Modified fun_plug for disk maintenance

i was in a hurry yesterday so i quickly took needed files from 0.4, and tweaked skydreamer's script to work.

check the attached file for details

manually unpack e2fsck-ffp05.tgz in /mnt/HD_a2/ (its not a fun_plug package) and rename fun_plug.disk_check

edit: seems like attachment is too big or .zip files are not allowed. anyhow: http://www.sendspace.com/file/732ibc

Last edited by SilentException (2008-05-11 02:33:47)


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

 

#22 2008-05-11 02:36:20

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

Re: Modified fun_plug for disk maintenance

SilentException wrote:

i was in a hurry yesterday so i quickly took needed files from 0.4, and tweaked skydreamer's script to work.

check the attached file for details

manually unpack e2fsck-ffp05.tgz in /mnt/HD_a2/ (its not a fun_plug package) and rename fun_plug.disk_check

edit: seems like attachment is too big or .zip files are not allowed. anyhow: http://www.sendspace.com/file/732ibc

Cool, I'll give it a try later...I'm a little reluctant because of my last attempt...but I'll get over it! wink

Offline

 

#23 2008-05-11 02:56:02

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

Re: Modified fun_plug for disk maintenance

Okay, I gave it a try, it boots fine, and telnet starts, but I get this error...I think the library didn't get linked properly or something...looking into it.

Code:

badblocks: can't load library 'libext2fs.so.2'

Offline

 

#24 2008-05-11 03:06:01

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

Re: Modified fun_plug for disk maintenance

SuperInsanity wrote:

Okay, I gave it a try, it boots fine, and telnet starts, but I get this error...I think the library didn't get linked properly or something...looking into it.

Code:

badblocks: can't load library 'libext2fs.so.2'

hm, try to swap lines 46 (cp) and 47 (rm) in fun_plug.

Last edited by SilentException (2008-05-11 03:06:18)


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

 

#25 2008-05-11 06:33:05

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

Re: Modified fun_plug for disk maintenance

I'm not sure which lines...46 is blank, and 47 is a commented line, so I assume 36 & 37?

#!/bin/sh

# 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 smile
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
36 cp -f /mnt/HD_a2/ffp/share/e2fsck/libext2fs.so.2.4 /lib
37 rm -r /lib/libext2fs.so*

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
46 #
47 # killall smbd

# killall nmbd
# umount /dev/md0
# e2fsck /dev/md0
#
# or
#
# umount /dev/md0
# e2fsck -v -f -c /dev/md0
# or
# badblocks -v -s -n /dev/md0


Or maybe, as I just noticed in editing this file that there is a lot of hidden spaces in many of the lines, perhaps that is having an effect?

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB