8

If I have a tmpfs set to 50%, and later on I add or remove RAM, does tmpfs automatically adjust its partition size?

Also what if I have multiple tmpfs each set at 50%. Do multiple tmpfs compete against each other for the same 50%? How is this managed by the OS?

1 Answer 1

7

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 tmpfs it will have a size of 2gb now.

When mounting multiple instances of tmpfs each with 50% set, it will work. If both tmpfs instances were filled completely, the system will swap out the lesser used pages. If swap space is full too, you will have No space left on device errors.

Edit:

tmpfs only uses the amount of memory that is taken, not the full 50%. So, if only 10mb of those 1gb are taken, your tmpfs instance only occupies those 10mb. It's not not reserved, it's dynmically. With multiple instances of 50%, the first one that need memory gets memory. The system swapps the lesser used pages, if 50% is occupied or not. The tmpfs instance is not aware of the fact whether it uses physical ram or swap space. You can mount a tmpfs of 100gb if you want and it will work.

I assume that you shut the system down before adding ram. So the tmpfs is remounted at startup anyway. If you add ram while the system runs, you will fry the ram, the motherboard and most likely your hand. I can't really recommand that :-)

Sources:

8
  • If there are multiple instances of tmpfs at 50%, do they all equally share the 50%, or do the percentages add up? Also do I need to remount the tmpfs to take advantage of the new RAM? Or does it automatically adjust? Jun 6, 2014 at 6:27
  • @CMCDragonkai see my edit
    – chaos
    Jun 6, 2014 at 7:02
  • But there are ways to hot add ram, I'm more referring to servers, not personal desktops. Jun 6, 2014 at 7:37
  • Ok here's an example, if there are 2 tmpfs with both 50% (1 gb each). If the first has 1gb filled up (assume no paging for simplicity), does that mean the 2nd tmpfs has no more space, since the first tmpfs has already filled up the total 50% share? Jun 6, 2014 at 7:38
  • I don't know if it adjusts automatically. I would do a remount/resize. I case of your second question (no swap) the tmpfs will still have plenty of free disk space, and your machine will crash.
    – chaos
    Jun 6, 2014 at 7:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .