Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resize /dev/shm?

On Ubuntu 18.04, When I run

$ df -h,

I see this result:

Filesystem      Size  Used Avail Use% Mounted on
...
tmpfs           3,9G   73M  3,8G   2% /dev/shm
...

/dev/shm has a 3.9G size.

How could I change the size of /dev/shm?

like image 952
Manu NALEPA Avatar asked Nov 11 '19 15:11

Manu NALEPA


People also ask

Is Dev SHM in RAM?

/dev/shm is a temporary file storage filesystem (see tmpfs ) that uses RAM for the storage. It can function as shared memory that facilitates IPC. It is a world-writeable directory. The size of /dev/shm is limited by excess RAM on the system, and hence you're more likely to run out of space on this filesystem.

What is Dev SHM Chrome?

/dev/shm is nothing but implementation of traditional shared memory concept. It is an efficient means of passing data between programs. One program will create a memory portion, which other processes (if permitted) can access. This will result into speeding up things on Linux.


2 Answers

One time resize:

$ sudo mount -o remount,size=8G /dev/shm
like image 103
rogerdpack Avatar answered Oct 26 '22 22:10

rogerdpack


  1. Edit file /etc/fstab (with sudo if needed).
  2. In this file, try to locate a line like this one : none /dev/shm tmpfs defaults,size=4G 0 0.

Case 1 - This line exists in your /etc/fstab file:

  • Modify the text after size=. For example if you want an 8G size, replace size=4G by size=8G.
  • Exit your text editor, then run (with sudo if needed) $ mount -o remount /dev/shm.

Case 2 - This line does NOT exists in your /etc/fstab file:

  • Append at the end of the file the line none /dev/shm tmpfs defaults,size=4G 0 0, and modify the text after size=. For example if you want an 8G size, replace size=4G by size=8G.
  • Exit your text editor, then run (with sudo if needed) $ mount /dev/shm.
like image 20
Manu NALEPA Avatar answered Oct 26 '22 20:10

Manu NALEPA