Hot answers tagged

22

Linux provides a tmpfs device which any user can use, /dev/shm. It is not mounted to a specific directory by default, but you can still use it as one. Simply create a directory in /dev/shm and then symlink it to wherever you want. You can give the created directory any permissions you choose, so that other users can't access it. This is a RAM backed ...


12

You don't have to do all that, you can just mount /tmp as tmpfs by using a line like the following in /etc/fstab: tmpfs /tmp tmpfs mode=1777,nosuid,nodev 0 0 You can also do it live (but bear in mind stuff that is currently in /tmp on your current filesystem will not be able to be accessed except through the inode and currently open file descriptors, so ...


11

From the Wikipedia page on the Filesystem Hierarchy Standard: Modern Linux distributions include a /run directory as a temporary filesystem (tmpfs) which stores volatile runtime data, following the FHS version 3.0. According to the FHS version 2.3, this data should be stored in /var/run but this was a problem in some cases because this directory isn't ...


10

What sets the size of the tmpfs? (On my machine it resides in /dev/shm) I can see its entry in /etc/fstab, but no notation of its size. The kernel documentation covers this underneath the mount options: size: The limit of allocated bytes for this tmpfs instance. The default is half of your physical RAM without swap. If you oversize your tmpfs ...


9

There is no difference betweem tmpfs and shm. tmpfs is the new name for shm. shm stands for SHaredMemory. See: Linux tmpfs. The main reason tmpfs is even used today is this comment in my /etc/fstab on my gentoo box. BTW Chromium won't build with the line missing: # glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for # POSIX shared memory ...


8

It's perfectly okay to use some directory in /run as long as you have the appropriate rights on it. In some modern distros, /tmp is already a virtual file system in memory or a symlink to a directory inside /run. If this is your case (you can check that in /etc/fstab, or typing mtab), you could use /tmp as your temporary directory. Also, don't get confused ...


7

For all the tmpfs mounts, "Avail" is an artificial limit. The default size for tmpfs mounts is half your RAM. It can be adjusted at mount time. (man mount, scroll to tmpfs). The mounts don't share the same space, in that if you filled the /dev/shm mount, /dev would not show any more "Used", and it would not necessarily stop you from writing data to /dev ...


6

The data on a tmpfs (Temporary Filesystem) will not persist across reboots. If you only care to preserve the mountpoint, that will be dictated by your /etc/fstab definition.


6

If all goes well, your kernel should decide to "do the right thing" all by itself. It uses a lot of fancy heuristics to decide what to swap out and what to keep when there is memory pressure. Those heuristics have been carefully built by really smart people with a lot of experience in memory management and are already good enough that they're pretty hard to ...


6

/etc/default/tmpfs is for sysvinit, for systemd (Debian jessie default) you only need to do: systemctl enable tmp.mount


6

Your system may have one already available; recent Linux systems based on Glibc always have a tmpfs mounted on /dev/shm. If your system doesn't have one or it's too small, then a filesystem not mounted by root pretty much means FUSE. On Ubuntu, you need to be in the fuse group to use FUSE. Looking through available FUSE filesystems, I see only Ramfuse, ...


5

Shared memory is using the 12GB. On your Linux release /dev/shm part of the /dev filesystem (on some releases, it has its own a dedicated file system mounted there). As shown by lsof, the sum is 12 GB: /dev/shm/foo5.44m is 6269616128 bytes /dev/shm/kdfoo.a4o is 6269616128 bytes Neither find nor ls can display theses files because they are unlinked (= ...


5

You can resolve which filesystem a directory or file is on with the command df, and if you include the -T option, the output will include the filesystem type. $ df -T /tmp Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda3 ext4 38715020 5073600 31674780 14% / In the above example, the /tmp directory is on an ext4 filesystem, ...


5

The "marking that memory as unused" is a function of how much work the unlinkat(2) system call has to do, which in turn scales linearly with the size of the file. For a default tmpfs on a RHEL 6 system with ~4G of memory, this can be demonstrated as follows. $ sudo mkdir /tmpfs; sudo mount -t tmpfs -o size=75% tmpfs /tmpfs; cd /tmpfs $ dd if=/dev/zero bs=1M ...


5

It shouldn't be possible. swapon system call requires readpage and bmap (indirectly) calls being implemented by filesystem: http://lxr.free-electrons.com/source/mm/swapfile.c?v=4.0#L2412 if (!mapping->a_ops->readpage) { error = -EINVAL; goto bad_swap; } But none of them are implemented by tmpfs, such an entry is missing from ...


4

The mount command shows what is currently mounted. $ mount|grep -i tmp none on /tmp type tmpfs (rw)


4

As Bratchley already indicated, htop, like everybody, seems to look at the +- cached line in free. If you are using a kernel older than 3.14, then indeed, that does not change. Even if you have a more recent kernel, free and htop have to be smart enough to know where to look though to get the right value. To get a bit deeper into what's happening, check out ...


4

You can use pam-tmpdir for this. It creates a directory for each user that logs in, at the start of their PAM session. See How to remount filesystem at logout? for a little more context... In Debian, Ubuntu and derivatives it's available in libpam-tmpdir.


4

You can try the following to create a case insensitive filesystem in /tmp: truncate -s 100M /tmp/vfat losetup /dev/loop0 /tmp/vfat mkfs.vfat /dev/loop0 mkdir /mnt/vfat mount /dev/loop0 /mnt/vfat If you don't want to use tmpfs but ramfs instead, create a RAM mount first: mkdir /mnt/ramfs mount -t ramfs -o size=110M ramfs /mnt/ramfs Then follow the steps ...


4

Q1: Yes Q2: It is not feasible to recover the data. Nevertheless, if you want to be extreme you could do it like this :) Create some space in ram: mkdir ram mount -t ramfs -o size=1000M ramfs ram/ Create some randomly filled file which we encrypt in that RAM space. Being filled with random data it will be impossible to establish boundaries between ...


4

Technically, you can mount /var/log as tmpfs. You'd need to be sure that /var/log is mounted before syslogd starts, but that's the case by default on most distributions since they support /var on a separate partition. You'll obviously lose all logs, which I guarantee will be a problem one day. Logs are there for a purpose — there're rarely needed, but ...


4

tmpfs uses swap if sufficient RAM is not available. That means you can create and activate a swap partition on the SATA drive and it will be used for /tmp, provided it's a tmpfs. In order to to that, create a swap partition and mount the swap space in your /etc/fstab. Furthermore, you have to ensure that the mounted tmpfs is of sufficient size. Use the size ...


4

You didn't specify the filesystem type - this is required. This is what you need: tmpfs /home/rkmax/Projects/webapp/app/cache tmpfs rw,size=500M,nosuid,uid=1000,gid=100 0 0


4

use ramfs instead of tmpfs. ramfs is a ramdisk (no swap) tmpfs can be both in your /etc/fstab: none /path/to/location ramfs defaults,size=512M 0 0 edit the size parameter to whatever you like but be careful not to exceed your actual amount of ram. NOTE: the use of a ramfs instead of tmpfs is not something i would recommend. you will find ...


3

tmpfs is implemented as cache pages, so a low value for vm.swappiness will make tmpfs files more likely to be swapped out, since the system will favor stealing cache pages over application pages.


3

I know this is rather old but in Debian-type distributions setting Set RAMTMP, RAMRUN and RAMLOCK in /etc/default/tmpfs (/etc/default/rcS or before wheezy) does the same job.


3

Imagine you want to bake a cake. You don't know the recipe, but it's okay: you have your cookbook. You take your cookbook out of your locked safe and open it... and here's what you see: sN+zBL0+S/TNORDzFUADrzbv2K5A5zb62o1WPqDA/1vtfiOTVFJnVRaU/++JSjABIBWw7PjHm+cg RnhGFHGv4xy0wTZi5vw8jTiJsgF6pzvOeVaDoiXdHliGFbiCM1rGxyziNesA5RLoLQx5EzGqNzw2 ...


3

To address the "DirectMap" issue: the kernel has a linear ("direct") mapping of physical memory, separate from the virtual mappings allocated to each user process. The kernel uses the largest possible pages for this mapping to cut down on TLB pressure. DirectMap1G is visible if your CPU supports 1Gb pages (Barcelona onwards; some virtual environments ...


3

The copy will fail prematurely with a file system full situation. In the best case, 4GB of swap and 6GB of RAM will be used to store the original file and the truncated copy. That leaves 10 GB of RAM for the remaining processes, cache and other kernel usage.


3

If you mount a tmpfs instance with a percentage it will take the percent size of the systems physical ram. For instance, if you have 2gb of physical ram and you mount a tmpfs with 50%, your tmpfs will have a size of 1gb. In your scenario, you add physical ram to your system, let's say another 2gb, that your system has 4gb of physical ram. When mounting the ...



Only top voted, non community-wiki answers of a minimum length are eligible