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-03-11 19:36:40

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

cleanboot 1.0 for DNS-323 / CH3SNAS

* Problem:

When you install fun_plug in your DNS-323 or CH3SNAS box, it runs most of the programs from the mounted hard disks, so it prevents them from being unmounted cleanly.

You have this problem if your dmesg shows the following line:

Code:

EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended

* Solution:

Cleanboot will modify the reboot & shutdown process to overcome this issue, allowing you to cleanly reboot or shutdown your box.

* How to install cleanboot in fonz fun_plug 0.5:

telnet or ssh into your box, and issue the following commands:

      # wget http://pof.eslack.org/dns323/cleanboot-2.1-ffp05.tgz
      # funpkg cleanboot-2.1-ffp05.tgz
      # /ffp/start/cleanboot.sh start


* How to upgrade cleanboot to new version 2.1 (2009-11-02):

telnet or ssh into your box, and issue the following commands:

      # wget http://pof.eslack.org/dns323/cleanboot-2.1-ffp05.tgz
      # funpkg -u cleanboot-2.1.tgz
      # /ffp/start/cleanboot.sh start


* How to shutdown your box after cleanboot has been installed:

telnet or ssh into your box and issue the command 'shutdown' or 'halt'.

NOTE: at the moment this is the only way to cleanly shutdown, if you do it either via the web panel or by pressing the button, the hard drives will not be cleanly unmounted.


* How to reboot your box after cleanboot has been installed:

There are several ways to reboot, all of them will umount the hard drives properly:

    1) telnet or ssh into your box and issue the command 'reboot'.
    2) issue a 'system restart' through the web administration panel
    3) point your browser to http://your_nas_ip/goform/System_restart


* How do I repair my filesystem if I already have the 'unchecked fs' warning:

There are two different methods to perform manual filesystem checks, choose the one you prefer:

    1) http://dns323.kood.org/forum/t1708-Modi … nance.html
    2) http://www.inreto.de/dns323/fsck/


ChangeLog
version-1.1 changes:
- replaced usual reboot, shutdown and halt commands by 'clean' ones
- properly set perms on mount points before halting
version-1.2 changes:
- fix: properly reboot the system (return reboot link to busybox when finished)
version-1.3 changes:
- extended list of binaries to SIGKILL (should not be necessary, but it doesn't hurt anyway)
- look for $FUNPLUGDIR environment variable instead of hardcoded path
version-2.0 changes:
- rewrote do_reboot in C, no longer depend on a patched binary
- all original do_reboot stuff moved to cleanboot external script
- merged shutdown and reboot scripts in a single file
version-2.0-ffp05 changes:
- this package is *only* for fonz fun_plug 0.5-experimental users
- updated startup script
- added config file in /ffp/etc/cleanboot.conf
version-2.1-ffp05 changes:
- merged all fixes done by SilentException, marinalink, silversurfer, EnricoM while i've been away:
    - fix do_reboot on some CH3SNAS firmwares
    - wakeup disks at the begining
    - flush filesystem buffers
    - included lsof for better kill handlink
    - fix missing paths
    - pid check before kill when killing daemons
    - swapoff
- thank you guys smile

Enjoy ;-)

Last edited by pof (2009-11-02 17:16:58)


Attachments:
Attachment Icon cleanboot-2.1-ffp05.tgz, Size: 60,076 bytes, Downloads: 735

Offline

 

#2 2008-03-11 19:48:28

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

pof wrote:

# do_shutdown

Have you tried relinking /sbin/reboot (and/or the funplug versions in .../fun_plug.d/sbin/) to your scripts so that I can use the usual commands without having to remeber to use the special ones?

Offline

 

#3 2008-03-11 19:56:43

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

I see no problem, you can do for example:

# rm /sbin/reboot
# rm /mnt/HD_a2/fun_plug.d/sbin/reboot
# ln -s /usr/sbin/do_reboot /sbin/reboot
# ln -s /usr/sbin/do_reboot /mnt/HD_a2/fun_plug.d/sbin/reboot

This will allow you to cleanly reboot by using the 'reboot' command.
The same will apply for shutdown, but the link should point to '/usr/sbin/do_shutdown'.

Offline

 

#4 2008-03-11 20:15:12

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

There's another thing that would be great on shutdown/reboot (haven't seen that in your scripts):

Code:

chmod 0777 /mnt/HD_a2
chmod 0777 /mnt/HD_b2  (if present)

This has bitten me several times. See also
http://dns323.kood.org/forum/t407-Runni … THIS..html

Offline

 

#5 2008-03-11 20:58:29

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

Thanks, I have updated the script (version 1.1) with your suggestions smile

Offline

 

#6 2008-03-11 22:12:29

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

fixed a bug in 'reboot' command in version 1.2.

Offline

 

#7 2008-03-12 03:38:59

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

pof wrote:

* Problem:

When you install fun_plug in your DNS-323 or CH3SNAS box, it runs most of the programs from the mounted hard disks, so it prevents them from being unmounted cleanly.

You have this problem if your dmesg shows the following line:

Code:

EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended

Hi Pof,

My installation of (minimal) fun_plug does not run any programs from mounted disks after startup, and thus I am able unmount all disks through TELNET.  I still get the EXT2-fs warnings.

Even if fun_plug is not installed, it seems the DNS-323 does not shutdown cleanly.  In this case, cleanboot would be useful even if fun_plug is not installed?

Jaya


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

Offline

 

#8 2008-03-12 03:48:46

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

jayas wrote:

Even if fun_plug is not installed, it seems the DNS-323 does not shutdown cleanly.  In this case, cleanboot would be useful even if fun_plug is not installed?

Yes, it will also be useful in this case, but you will need a "minimal" fun_plug to start cleanboot. If you don't have a standard fun_plug installation, make sure to edit the scripts to fit your needs (ie: manually kill running daemons, fix some hardcoded file paths, etc...).

What cleanboot does, is replacing the intenal 'do_reboot' command with a patched one which will hook up a script in the midlde of the reboot process. If the hooked script touches /tmp/shutdown after the processes have been killed, then it will perform as a shutdown (chkbutton daemon will take care of it), otherwise it will act just as a normal reboot.

Offline

 

#9 2008-03-12 08:18:50

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

Hi Pof,

I notice that you have provided a patched version of do_reboot.  I cannot seem to find the source in the GPL distribution from D-LINK.  Could I ask where you got the source from, or if you reverse engineered it from scratch.  The script it generates and run seems simple.

Jaya


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

Offline

 

#10 2008-03-12 09:54:44

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

no much reverse engineering needed, I just patched a string (replaced a kill command), so no source needed at all to do the patch wink

Offline

 

#11 2008-03-12 12:27:53

oxygen
Member
Registered: 2008-03-01
Posts: 320
Website

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

I would recommend some changes to the scripts:

1. in pof-clean*. , first run through the stop scripts and then kill the daemons that are still running with kill -9. Maybe you could extent that list also a bit (upnp, rsyncd, unfsd)
2. make /mnt/HD_a2/fun_plug.d changeable in a central place. i have installed it in /mnt/usbstick

Offline

 

#12 2008-03-12 12:55:41

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

@oxygen:

Theoretically you shouldn't need to kill daemons (only mt-daapd, because that's what I patched on the original binary) because do_reboot and chkbutton take care of that for you. But stopping services properly and then do the kill -9, just in case something failed seems a good idea smile

Thanks for the feedback, I take note of your suggestions for next version... big_smile

Offline

 

#13 2008-03-12 18:03:05

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

uploaded version 1.3, which includes oxygen's suggestions smile

Offline

 

#14 2008-03-12 21:28:32

knireis
Member
Registered: 2007-12-10
Posts: 231

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

When i type in the first command in the telnet window, I get the following error message:
wget: bad address 'pof.eslack.org'

any suggestions? I run funplug 0.4

Last edited by knireis (2008-03-12 21:29:06)

Offline

 

#15 2008-03-12 21:36:38

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

@knireis: make sure you have internet connection available (gateway & dns server) set in your DNS323 configuration. Otherwise you can just download the .tgz and place it in your storage through the network instead of using wget.

Offline

 

#16 2008-03-13 05:52:57

nUll
Member
Registered: 2008-03-09
Posts: 113

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

Thanks for the patch.

Offline

 

#17 2008-03-13 16:55:19

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

I have released cleanboot 2.0 (see first post) which includes the following changes:

It no longer depends on the patched do_reboot binary which is not available in dlink or conceptronic GPL sources, I disassembled the do_reboot using radare and found it's pretty simple to implement the same functionality in C. So I rewrote it and put all its functionality in a shell script (/sbin/cleanbot.sh) instead of a binary program, so it should be easily customizable for advanced users.

For those interested in seeing the source it's here:
http://pof.eslack.org/dns323/cleanboot-2.0-src.tar.gz

Instructions to upgrade from 1.x to 2.0 are also in the first post smile

Last edited by pof (2008-03-13 16:57:09)

Offline

 

#18 2008-03-14 05:31:38

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

I have released a package for fonz fun_plug 0.5-experimental users. See instructions in the first post.

Offline

 

#19 2008-03-14 08:15:33

rap
Member
From: Reading - UK
Registered: 2008-02-28
Posts: 119

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

Hi - I've tried to use version 2 for fp 0.4 but I'm not sure that it's working.

After following the install instructions I telneted to my device and ran "reboot". The telnet session is killed but not much happens in the way of an actual reboot happening. After leaving it for a few minutes I can no longer telnet until I restart via the web UI.

funplug.log shows (below) that the script is starting

"* Running /mnt/HD_a2/fun_plug.d/start/cleanboot.sh start ...
Setting up cleanboot... "

Any idea what I might have got wrong?

RAP

Offline

 

#20 2008-03-14 12:19:45

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

@Rap:

If you have additional software in your fun_plug installation which is not ran through an start/stop script, try adding it to the list of programs to kill in /mnt/HD_a2/fun_plug.d/share/cleanboot/cleanboot.sh

For example, if you have mldonkey installed, add "$(pidof mlnet)" at the end of the "/bin/kill -9" command. You can identify the name of the additional program to kill by issuing the command 'ps ax'.

Offline

 

#21 2008-03-14 12:53:34

rap
Member
From: Reading - UK
Registered: 2008-02-28
Posts: 119

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

I think the only thing I'm running that is not a start script is mediatomb so I'll have a look at that.

Cheers

RAP

Offline

 

#22 2008-03-14 15:08:37

rap
Member
From: Reading - UK
Registered: 2008-02-28
Posts: 119

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

Hi - I edited the section of the file as below but it is still not working

/bin/kill -9 $(pidof mt-daapd) $(pidof ftpd) $(pidof pure-ftpd) \
             $(pidof telnetd) $(pidof dropbear) $(pidof svnserve) \
             $(pidof smbclient) $(pidof smbd) $(pidof nmbd) \
             $(pidof wget) $(pidof btget) $(pidof sftp-server) \
             $(pidof SyncMms) $(pidof getMsg) $(pidof lpd) \
             $(pidof upnp) $(pidof rsyncd) $(pidof unfsd) \
             $(pidof mediatomb)

Any other ideas?

RAP

Offline

 

#23 2008-03-14 15:25:11

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

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

mmmh... weird, what you've done seems fine.

Is the 'shutdown' command working?
Which firmware version do you have?

Offline

 

#24 2008-03-15 08:22:10

rap
Member
From: Reading - UK
Registered: 2008-02-28
Posts: 119

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

No, shutdown doesn't work either.

I'm using he latest stock firmware I could find - 1.04

As I do not see, to have much luck with it, what's the best way to remove the script?

RAP

Offline

 

#25 2008-03-15 17:11:35

Rival
Member
From: Budapest
Registered: 2008-03-13
Posts: 53
Website

Re: cleanboot 1.0 for DNS-323 / CH3SNAS

rap wrote:

No, shutdown doesn't work either.
I'm using he latest stock firmware I could find - 1.04
As I do not see, to have much luck with it, what's the best way to remove the script?
RAP

To remove script you only have to delete cleanboot.sh from your ${FUNPLUGDIR}/start, and also remove ${FUNPLUGDIR}/share/cleanboot directory... restart your NAS and that's all...

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB