site  contact  subhomenews

Ubuntu: Want to mount tmpfs on /tmp

April 28, 2012 — BarryK
I thought perhaps there might be an Ubuntu guru reading this...

I am running Ubuntu Lucid Lynx off an SD card on my Mele A1000 ARM box.

It is a normal "full" install, and I think that it is hitting the SD card really hard, that is, lots of writes to it. In particular, a lot of stuff happens on /tmp, and I would like to mount a tmpfs (in RAM) onto /tmp at bootup.

However, I am unfamiliar with the init/bootup scripts used in Ubuntu -- is it the 'launchd' system? Anyway, I will need to mount the tmpfs on /tmp as early as possible in the bootup, and I cannot see what script to put it into.

In Puppy, I would do that in /etc/rc.d/rc.sysinit, right after remounting '/' as rw.

Comments

tmpfs /tmp
Username: Dougal
Ubuntu and Debian are actually moving to it as the default. A quick google search finds this: http://brainstorm.ubuntu.com/idea/16244/

mount /tmp
Username: K Godt
"Interestingly the kernel overlays the current directory on HDD if /dev or /tmp gets mounted on their specific filesystems (devtmpfs/tmpfs) [code]mkdir /tmp_new cp -a /tmp/* /tmp_new cp -a /tmp/.[a-zA-Z0-9]* /tmp_new mount -t tmpfs none /tmp cp -a /tmp_new/* /tmp cp -a /tmp_new/.[a-zA-Z0-9]* /tmp rm -r /tmp_new[/code] none on /tmp type tmpfs (rw,relatime) [code]mkdir /tmp_new cp -a /tmp/* /tmp_new cp -a /tmp/.[a-zA-Z0-9]* /tmp_new umount /tmp cp -u /tmp_new/* /tmp cp -u /tmp_new/.[a-zA-Z0-9]* /tmp rm -r /tmp_new[/code] So the original /dev or /tmp directory still exist underneath and don't have to be created new if umount ing the temporary /directory . For now i encountered only a problem with an already running pmount having some files in there . pup_event_frontend_d handles the switch nicely until now . http://brainstorm.ubuntu.com/idea/16244/ Solution #1: Mount /tmp as tmpfs in /etc/init.d scripts

/tmp solution
Username: BarryK
"K Godt, Thanks for that link. Solution #1 does not work, as there is no /etc/init.d/mountkernfs.sh file. I think that is for an older version of Ubuntu. I have gone for Solution #2, put an entry into /etc/fstab: [i]tmpfs /tmp tmpfs nodev,nosuid,noexec,mode=1777 0 0[/i] ...except, I took out the 'noexec'. ...um, shouldn't have 'auto' in it? Which reminds me, my USB hard drive is getting mounted with 'nodev', which prevents me for compiling source packages in it. I have to manually unmount the mount it myself. I don't know where that 'nodev' gets set for USB drives, maybe a udev rule? Whatever, when I get a SATA hard drive, I will put entries into /etc/fstab to mount a swap partition, and a working partition (with the options that I want).

man mount
Username: K Godt
"That was dougal finding the Page .. man mount reads like If no -t option is given, or if the auto type is specified,mount will try to guess the desired type. Mount uses the blkid or volume_id library for guessing the filesystem type; if that does not turn up anything that looks familiar, mount will try to read the file /etc/filesystems, or, if that does not exist, /proc/filesystems. All of the filesystem types listed there will be tried, except for those that are labeled "nodev" (e.g., devpts, proc and nfs). If /etc/filesystems ends in a line with a single * only, mount will read /proc/filesystems afterwards. nodev Do not interpret character or block special devices on the file system. where i am unsure about "interpret" character-block special devices .. read them like cat /dev/tty1 _?

Maybe 'noexec'
Username: BarryK
"Ah, maybe it was the 'noexec' that caused trouble for my usb hard drive.

USB Drive
Username: Dougal
""I have to manually unmount the mount it myself." "mount -o remount" with the other options added would be easier. You could also add an fstab line based on your USB drive's UUID...


 " PeterM321"<<It is a normal "full" install, and I think that it is hitting the SD card really hard, that is, lots of writes to it. In particular, a lot of stuff happens on /tmp,...>> There are quite a few options to mount a /tmp tmpfs volume, the one I ended up choosing was declare ramsize=300 mount -t tmpfs -o size=${ramsize}m,atime,diratime,rw /dev/shm /tmp However, if you are wanting to save a USB device a few more write cycles it may be worth considering re-assigning the $HOME directory. (The hidden files in particular get written to rather frequently): mkdir /tmp/home cp -ar $HOME /tmp/home mount --bind $HOME /tmp/home


Tags: puppy