Mount /tmp in ram?

Joined
Aug 8, 2008
Messages
28
Reaction score
0
Location
Norway
Can someone please explain how to mount /tmp, /var/log and other useful directories to ram? I don't seem to manage to get the fstab right, my beloved one stops as soon as the cursor appears :(

Code:
/dev/sda1          /                  ext2          defaults,noatime,async        1 1
none               /dev/pts           devpts        gid=5,mode=620         0 0
none               /dev/shm           tmpfs         defaults               0 0
none               /proc              proc          defaults               0 0
none               /sys               sysfs         defaults               0 0
tmpfs              /tmp               tmpfs         defaults,noatime,rw,mode=1777  0 0
tmpfs              /var/tmp           tmpfs         defaults,noatime,rw,mode=1777  0 0
tmpfs              /var/log           tmpfs         defaults,noatime,rw,mode=0755  0 0

#/dev/sda2          swap               swap         defaults               0 0
 
/tmp is already mounted tmpfs, just not in the fstab, they did in in the /etc/rc.d/rc.S script instead, remove/comment the /tmp line in your fstab and it should work. If you want to check this look in the /proc/mounts file, this is the definitive list of mounts maintained by the kernel since the /etc/mtab file which mount reads is not always correct.
 
retsaw said:
/tmp is already mounted tmpfs, just not in the fstab, they did in in the /etc/rc.d/rc.S script instead

sry for dumb questions, i'm a linux noob (willing to change it ,p):
1) why is that? i mean, whats the benefit of not setting it on "the right place"?
2) if it is working, why isn't it listet in terminal using "mount"?
3) what about /var/(lock/log)?

thx in advance =)
 
1) Presumably they needed it mounted earlier than the filesystems in /etc/fstab, I don't know why though.

2) Mount uses the /etc/mtab file to store details of mounts and also reads from it, mount also has an option not to write to this file when making mounts, typically this is used when the filesystem that contains /etc is read-only, however in this case it is mounted read-write before mounting /tmp. So the reason mount doesn't list it as mounted is because someone told mount not to record its mounting in /etc/mtab, but there isn't a good reason to do this.

3) You can mount /var/log in the fstab without problems, however I choose to mount it in /etc/rc.d/rc.S just after the entry to mount /tmp to make sure it was done before any log files were written.
 
Demiurge said:
Can someone please explain how to mount /tmp, /var/log and other useful directories to ram? I don't seem to manage to get the fstab right, my beloved one stops as soon as the cursor appears :(

Code:
/dev/sda1          /                  ext2          defaults,noatime,async        1 1
none               /dev/pts           devpts        gid=5,mode=620         0 0
none               /dev/shm           tmpfs         defaults               0 0
none               /proc              proc          defaults               0 0
none               /sys               sysfs         defaults               0 0
tmpfs              /tmp               tmpfs         defaults,noatime,rw,mode=1777  0 0
tmpfs              /var/tmp           tmpfs         defaults,noatime,rw,mode=1777  0 0
tmpfs              /var/log           tmpfs         defaults,noatime,rw,mode=0755  0 0

#/dev/sda2          swap               swap         defaults               0 0
I have been having the same problem. I swear I got this working before. I had to reinstall the whole OS recently and now, as soon as I put /var/tmp and /var/log it gets stuck with a big X cursor. Very strange!
 
Are you sure the cause is when you put /var/tmp and /var/log, rather than the entry for /tmp?

As I said before /tmp is already mounted in RAM before the fstab gets processed, I believe trying to mount another ramdisk on top of that is what causes the problem, though perhaps it is because by the time the fstab gets processed /tmp and possibly /var/tmp is already being used.
 
Back
Top