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

/tmp - size and location

Discussion in 'Tomato Firmware' started by dmdp, Jun 8, 2010.

  1. dmdp

    dmdp Guest


    I've recently flashed my RT-N16 with Teddy Bear's mod (btw, thank you so much for the mod, Fedor and Ray Van!) and after fiddling a bit with it, I got questions about /tmp

    a) Where is it actually located as in storing data under it? If that's RAM, does it mean that the whole size of /tmp (which is a separate fs of 63600k i.e. ~64M) is taken out of RAM and is 'basically' lost for applications?

    b) I can see the root's home directory is under /tmp and files placed under it are lost with each reboot. Is that possible to configure /home on an external USB storage (assuming it'd be always attached to the router)? How could it be done automatically (both auto-mounting the storage through /etc/fstab and linking /home to it)?

    I must appologize if my questions are very basic ones but that's the first router I got and that's the very first firmware (chosen out of DD-WRT and Enthusiasts' one) I have ever installed on it.

    BTW, I use the version of Tomato I got is as follows

    Tomato Firmware v1.27.9046 MIPSR2-beta14 K26 USB Ext

    Thank you in advance!
  2. Rasky

    Rasky Addicted to LI Member

    It's allocated "on the fly" while you are using it, so it depends on how much stuff you are putting in there.

    By default, if you activate automount (in the web gui, USB and NAS >> USB Support >> Automount), all partitions are automatically mounted as soon as they are hot-plugged (or at startup after a router reboot). But they will be mounted under /mnt/PARTITION_NAME. So your question boils down to: how can I change the mount point?

    That's easy: you can edit your own /etc/fstab, and it will be honored by the automount. You can use the "LABEL=foobar" syntax to name the devices to mount (partitions), so that it does not depend on the USB enumeration order.

    But, modifications to /etc are not persistent too (it's /tmp/etc afterall)! So how do we solve this chicken-egg?

    To create a persistent /etc/fstab, you can create it on-the-fly through multiple "echo" calls in the init script (Administration >> Scripts in the web interface). Alternatively, you can create the file using vi and then run "nvram setfile2nvram /etc/fstab && nvram commit". This basically stores the file to nvram and it is auto-restored at startup. You can repeat the above command if you change it later, it will overwrite the previous version in nvram. Make sure to always pass the absolute path to the command, though! Also, pay attention to nvram free size, it is a scarce resource (nvram show | tail -n1).

    Another nice feature is that you can create a file named ".autorun", put into the root of an USB partition, and make it executable (chmod +x). Tomato will automatically execute it as soon as the partition is mounted. This is very useful to perform some post-mount operation.

Share This Page