1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

slimming down running things...

Discussion in 'Tomato Firmware' started by Mangix, Aug 23, 2012.

  1. Mangix

    Mangix Networkin' Nut Member

    I have an E1500 with WAN disabled and connected to another router. Because I only want to run an SSH server with it(the regular router does not support SSH or custom firmware) I'm wondering if I can slim things down a little further.

    This is a ps output:
        1 root      1380 S    /sbin/init noinitrd
        2 root         0 SW<  [kthreadd]
        3 root         0 SW<  [ksoftirqd/0]
        4 root         0 SW<  [events/0]
        5 root         0 SW<  [khelper]
       18 root         0 SW<  [kblockd/0]
       40 root         0 SW   [pdflush]
       41 root         0 SW   [pdflush]
       42 root         0 SW<  [kswapd0]
       43 root         0 SW<  [aio/0]
       85 root         0 SW<  [mtdblockd]
      266 root       748 S    hotplug2 --persistent --no-coldplug
      306 root      1364 S    buttons
      307 root      1300 S    console
      308 root      1720 S    /bin/sh
      517 root      1196 S    dropbear -p 2222 -s -a
      520 nobody    1100 S    dnsmasq -c 1500 --log-async
      539 root      1404 S    httpd
      541 root      1720 S    crond -l 9
      594 root      1264 R    dropbear -p 2222 -s -a
      595 root      1720 S    -sh
      599 root      1712 R    ps
    The only things to get rid of are httpd(no problem) but am wondering about dnsmasq and crond. Is it possible to disable them through some sort of nvram setting or web interface setting without killing them?

    Oh also, this is toastman version 1.28.7500.4 .
  2. koitsu

    koitsu Network Guru Member

    When you say "slimming down", are your concerns over memory usage or are you just focusing on/worried about the number of total processes that the router has running? What is the focus?

    If it's regarding memory usage, the amount you see above in the VIRT column is not an accurate representation of how much memory each process is actually taking up. What you want is the RES/RSS column, which Busybox (being the pile of crap that it is) does not show you. I would tell you to install Entware + procps to get /opt/bin/ps but that would violate your "slimming down" requirement, so here's a one-liner that should get you the RES/RSS of each process:

    for i in /proc/[0-9]*/status; do awk '/Name:/ { name=$NF } /VmRSS:/ { res=$(NF-1) } /VmSize:/ { virt=$(NF-1) } END { if (res != 0) { printf("%-20s%-7u%-7u\n", name, res, virt) } }' $i ; done
    Please note that should be all on one line.

    Output columns will be: process name, RES/RSS usage (in kilobytes), and VIRT/VSZ (in kilobytes).

    I would not advise disabling crond -- it's what's responsible for rotating/clearing out your /var/log/messages file, which is kept in RAM (since it's part of the / filesystem which is RAM-only). Failure to rotate this log out will result in a gradual decline of available memory.

    Disabling dnsmasq is acceptable, as long as you know you will never, ever need a DHCP server running on the router itself for your LAN. dnsmasq provides not only DNS relay capabilities but the DHCP server for the LAN as well.
  3. Mangix

    Mangix Networkin' Nut Member

    the aim really is to just have the stuff that I absolutely need running and nothing more. Not really concerned about memory usage(32MB RAM).

    that crond part is interesting. Curious if it does something similar in dd-wrt(I disable it there since it appears to do nothing).

    as far as disabling dnsmasq, how would I do that? I can't seem to find any setting in the web interface(wish to avoid doing killall commands if possible).

    edit: I just real your dnsmasq part again. Isn't DHCP disabled by default in tomato? Why is it running then? I don't recall enabling it.
  4. koitsu

    koitsu Network Guru Member

    I believe certain daemons are expected to be running all the time, and the list of those daemons is hard-coded into the code for init. (Do not kill init :p Your system will reboot if you do that). So unless there is an NVRAM variable to turn off the behaviour, you would have to modify the TomatoUSB code and build your own firmware. Toastman and/or Shibby can comment on if there's an NVRAM variable to shut off some daemons (like dnsmasq, crond, etc.).

    Toastman disables the DHCP server functionality of dnsmasq by default, yes -- meaning it is disabled at run-time, not compile-time. He can explain why the default is to have the DHCP server functionality disabled. However, the DNS capabilities of dnsmasq are still enabled (and there is no way to disable such).

    Point: do not confuse the terms "DHCP server" with "dnsmasq". dnsmasq -- the daemon/process -- serves two purposes: it can act as a DHCP server for your LAN, and it acts as DNS proxy/resolver for your LAN (relaying DNS lookup requests directed to it, to the DNS servers delegated to you by your ISP).
  5. Mangix

    Mangix Networkin' Nut Member

    sounds good. and yeah i've killed init on dd-wrt before. rebooted.

    looks like I need to scour the nvram space to see if I can do anything.

    thanks for the info.

Share This Page