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-10 16:59:58

pcp
Member
From: Moravistan
Registered: 2008-04-23
Posts: 75

Disk suspend for the debian and custom distros

Today, I've downloaded the new d-link's firmware, and because lot of people referenced that disk suspend is now working, I did some investigation in system changes.
It seems that d-link engineers has solved the cron and atd disk access issue by the mounting /var/spool directory as tmpfs. Copypasta from the /etc/rc.sh follows:

Code:

echo "mount tmpfs for hibernation"
mount -t tmpfs  tmpfs /var/spool
mkdir /var/spool
mkdir /var/spool/at
touch /var/spool/at/.SEQ
chmod 777 /var/spool/at/.SEQ
mkdir /var/spool/cron
mkdir /var/spool/cron/crontabs

this basically creates the /var/spool directory in the ram, instead on the filesystem, and the daemons can no longer wake-up the disk from it's sweet sleep.

The next question is the disk suspend. This can be done by the hdparm
command, but this stuff is hidden deeply in the /usr/sbin/ubutton binary, and no one except the d-link staff can say what it really does.

So, what to do if you want the hibernation on custom system?
1) mount the /var/spool as tmpfs, as in the code above. do this before the atd/crond starts up.
2) add the hdparm disk suspend command to some startup script (/etc/rc.local on debian, /etc/rc.sh on hacked d-link system)

Code:

 hdparm -S 120 /dev/sda

- this will suspend the disk after 10mins of inactivity. The value to a -S parameter is 5-second multiplier. Thus, 10mins is (10*60)/5 = 120
3) reboot the device and report the results.

Offline

 

#2 2008-09-10 17:05:41

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

Re: Disk suspend for the debian and custom distros

pcp wrote:

by the mounting /var/spool directory as tmpfs

Interesting, but I don't see how this helps, since (on my DNS-323) /var/spool is not on disk, but in RAM (part of the initial ramdisk).
Is this different on a DNS-313?

Offline

 

#3 2008-09-10 17:17:37

pcp
Member
From: Moravistan
Registered: 2008-04-23
Posts: 75

Re: Disk suspend for the debian and custom distros

fonz wrote:

Interesting, but I don't see how this helps, since (on my DNS-323) /var/spool is not on disk, but in RAM (part of the initial ramdisk).
Is this different on a DNS-313?

since the fw 1.01b06 version, device can hibernate (disk suspend). This was impossible in the previous fw versions, because crond and atd were reading from the disk frequently (looking for the changes in their cfg files), and thus causing disk wake-ups. The new ramfs-mount should solve this.

But i dunno what kind of black magic is doing their ubutton binary. I'll check it as soon I'll have some time to experiment with my dns at home.

Last edited by pcp (2008-09-10 17:19:49)

Offline

 

#4 2008-09-12 11:56:30

pcp
Member
From: Moravistan
Registered: 2008-04-23
Posts: 75

Re: Disk suspend for the debian and custom distros

Disregard everything i've written. I downloaded the new sources and there are changes in the sata kernel driver. More info soon.

Offline

 

#5 2008-09-17 17:18:31

pcp
Member
From: Moravistan
Registered: 2008-04-23
Posts: 75

Re: Disk suspend for the debian and custom distros

after further investigation i've found the solution for the working disk suspend on a dns
there are steps to (hopefully) create a working suspend

1)  you will need a new kernel, either from the newest firmware, or compiled from the sources (which can be found at a d-link gpl taiwan site. be warned, dl speed from there is about 50kBps, and the package has 280MB). this kernel has a patched sata driver, which counts the disk's idle time, and after a specified time (settable by a ioctl) sends a SIGUSR1 to the process id registered by the another ioctl. this process then suspends the disk via ioctl, similar to the hdparm -y option.
2) the process suspending the disk is called pwrmgm. it is located in the ramdisk of the 1.02b04 firmware. if anyone is interested, i can probably write this program in C for people who want to compile against custom libc/uClibc.
3) all directories contatining the regulary accessed files must be mounted as a tmpfs filesystem. this filesystem resides in the RAM, so configure your programs to do not write logs, etc.. too frequently or at all.
4) I can provide the my minimal system's image, kernel, and the ramdisk for people who are interested in device hacking. it has most of the d-link's crap turned off, it has new busybox without that funny 5874468 code, fan daemon, program to control front disk LED, and it can be used with the ffp. sadly, you must configure everything by hand, because web service and other d-link-specific services are missing
5) just ask if you have any questions.

Offline

 

#6 2008-09-18 20:59:25

radir
Member
Registered: 2008-01-03
Posts: 68

Re: Disk suspend for the debian and custom distros

Hi,

Do you mean http://tsd.dlink.com.tw/temp/download/3 … 080723.tgz as the latest source with working spindown code?

And of course very interested in any improvement :-) thus if you could upload pwrmgm or similar ... would appreciate it!

Thanks.

Offline

 

#7 2008-09-19 12:46:21

pcp
Member
From: Moravistan
Registered: 2008-04-23
Posts: 75

Re: Disk suspend for the debian and custom distros

dns313v1.01_GPL_20080723.tgz contains latest kernel sources. but it's not worth downloading - the archive has ~280MB, and the only usable thing inside are that kernel sources. i think i can pack & upload it somewhere soon.
attached is the pwrmgm - this is the d-link's binary. pass the number of minutes of disk inactivity berfore suspend as an argument. if you want to test it directly, send the USR2 signal to the running process (killall -USR2 pwrmgm). you need to have the latest kernel running.

Offline

 

#8 2008-09-21 13:12:30

pcp
Member
From: Moravistan
Registered: 2008-04-23
Posts: 75

Re: Disk suspend for the debian and custom distros

okay, here are the kernel sources

http://www.popcorp.org/data/linux-dlink313.tbz2 (45MB)

Offline

 

#9 2008-09-25 20:43:32

radir
Member
Registered: 2008-01-03
Posts: 68

Re: Disk suspend for the debian and custom distros

Pcp,

Is it possible to upload the kernel config file please? By default lots of feature is enabled but I guess most of them are not required (e.g. mouse, sound). Though not sure which are really required.

Thanks.

Offline

 

#10 2008-09-29 12:46:24

pcp
Member
From: Moravistan
Registered: 2008-04-23
Posts: 75

Re: Disk suspend for the debian and custom distros

radir wrote:

Pcp,

Is it possible to upload the kernel config file please? By default lots of feature is enabled but I guess most of them are not required (e.g. mouse, sound). Though not sure which are really required.

Thanks.

here it is. hope it will work.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB