- How to change tmpfs partition size in Linux ( RHEL / CentOS 7 )
- Change tmpfs partition size for /dev/shm
- Change tmpfs partition size for /run
- Change tmpfs partition size for /run/user/$UID
- Change tmpfs partition size for /sys/fs/cgroup
- Not enough space on /tmp
- 7 Answers 7
- How to Resize tmpfs on Linux
- Resize TMPFS
- Увеличить размер каталога /tmp/
How to change tmpfs partition size in Linux ( RHEL / CentOS 7 )
In my last article I gave an overview on tuned and steps to create a custom tuned profile as per your performance requirement. In this article I will share the steps to (increase/decrease) change tmpfs partitions size in Linux. With RHEL 7 the Linux kernel provides a number of different ways for userspace to communicate with it.
For many facilities there are system calls, others are hidden behind netlink interfaces, and even others are exposed via virtual file systems such as /proc or /sys . These file systems are programming interfaces, they are not actually backed by real, persistent storage. They simply use the file system interface of the kernel as interface to various unrelated mechanisms.
Now by default systemd assigns a certain part of your physical memory to these partitions as a threshold. But what if your requirement requires you to change tmpfs partition size?
For some of the tmpfs partitions, you can change the threshold size by using fstab . While for other partitions like ( /run/user/ ) which are created runtime, you cannot use fstab to change tmpfs partition size for such runtime directories.
Below are the list of tmpfs partitions available in RHEL 7
Filesystem Size Used Avail Use% Mounted on tmpfs 187G 0 187G 0% /dev/shm tmpfs 187G 41M 187G 1% /run tmpfs 187G 0 187G 0% /sys/fs/cgroup tmpfs 38G 0 38G 0% /run/user/1710 tmpfs 38G 0 38G 0% /run/user/0
You may notice that /etc/fstab does not contains entries for these tmpfs partitions but still df -h will show these partitions.
Change tmpfs partition size for /dev/shm
If an application is POSIX compliant or it uses GLIBC (2.2 and above) on a Red Hat Enterprise Linux system, it will usually use the /dev/shm for shared memory (shm_open, shm_unlink). /dev/shm is a temporary filesystem (tmpfs) which is mounted from /etc/fstab . Hence the standard options like «size» supported for tmpfs can be used to increase or decrease the size of tmpfs on /dev/shm (by default it is half of available system RAM).
For example, to set the size of /dev/shm to 2GiB, change the following line in /etc/fstab :
none /dev/shm tmpfs defaults 0 0
none /dev/shm tmpfs defaults,size=2G 0 0
For the changes to take effect immediately remount /dev/shm :
A mount -o remount to shrink a tmpfs will succeed if there are not any blocks or inodes allocated within the new limit of the smaller tmpfs size. It is not possible to predict or control this, however a remount simply will not work if it cannot be done. In that case, stop all processes using tmpfs, unmount it, and remount it using the new size.
Lastly validate the new size
# df -h /dev/shm Filesystem Size Used Avail Use% Mounted on tmpfs 2.0G 0 2.0G 0% /dev/shm
Change tmpfs partition size for /run
/run is a filesystem which is used by applications the same way /var/run was used in previous versions of RHEL. Now /var/run is a symlink to /run filesystem. Previously early boot programs used to place runtime data in /dev under numerous hidden dot directories. The reason they used directories in /dev was because it was known to be available from very early time during machine boot process. Because /var/run was available very late during boot, as /var might reside on a separate file system, directory /run was implemented.
By default you may not find any /etc/fstab entry for /run, so you can add below line
none /run tmpfs defaults,size=600M 0 0
For the changes to take effect immediately remount /run :
lastly validate the new size
# df -h /run Filesystem Size Used Avail Use% Mounted on tmpfs 600M 9.6M 591M 2% /run
Change tmpfs partition size for /run/user/$UID
/run/user/$UID is a filesystem used by pam_systemd to store files used by running processes for that user. In previous releases these files were typically stored in /tmp as it was the only location specified by the FHS which is local, and writeable by all users. However using /tmp can causes issues because it is writeable by anyone and thus access control was challenging. Using /run/user/$UID fixes the issue because it is only accessible by the target user.
tmps partition size for /run/user/$UID is taken based on RuntimeDirectorySize value from /etc/systemd/logind.conf
# grep -i runtime /etc/systemd/logind.conf RuntimeDirectorySize=10%
By default the default threshold for these runtime directory is 10% of the total physical memory.
From the man page of logind.conf
Modify this variable to your required value, for example I have provided threshold of 100M
# grep -i runtime /etc/systemd/logind.conf RuntimeDirectorySize=100M
Next restart the systemd-logind service
Change tmpfs partition size for /sys/fs/cgroup
/sys/fs/cgroup is an interface through which Control Groups can be accessed. By default there may or may not be /etc/fstab content for /sys/fs/cgroup so add a new entry
Current value for /sys/fs/cgroup
# df -h /sys/fs/cgroup Filesystem Size Used Avail Use% Mounted on tmpfs 63G 0 63G 0% /sys/fs/cgroup
Add below line in your /etc/fstab to change the threshold to 2GB
none /sys/fs/cgroup tmpfs defaults,size=2G 0 0
Remount the partition /sys/fs/cgroup
# mount -o remount /sys/fs/cgroup
Lastly validate the updated changes
# df -h /sys/fs/cgroup Filesystem Size Used Avail Use% Mounted on tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
Lastly I hope the steps from the article to change tmpfs partition size on Linux was helpful. So, let me know your suggestions and feedback using the comment section.
Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud
If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.
For any other feedbacks or questions you can either use the comments section or contact me form.
Thank You for your support!!
Not enough space on /tmp
I’m not able to run update manager as I get an error saying that there is not enough free space in the /tmp directory. I’ve practically cleaned out the tmp directory but the error persists. here’s df-h
/dev/loop0 13G 11G 952M 92% / udev 2.0G 4.0K 2.0G 1% /dev tmpfs 785M 920K 784M 1% /run none 5.0M 0 5.0M 0% /run/lock none 2.0G 584K 2.0G 1% /run/shm /dev/sda6 20G 14G 6.4G 68% /host overflow 1.0M 16K 1008K 2% /tmp
Here, a simple reboot solved the issue. As @josinalvo explained, / was full and was increased on the fly: The disk was a virtual disk.
7 Answers 7
What seems to have happened:
Your / was full, then Ubuntu created a new partition, in RAM memory, to use temporarily.
Now, this 1MB partition is not big enough for the job, either.
1) increase the size of this partition just to do the upgrade
2) actually delete enough files in the HD that this partition is no longer needed.
sudo umount /tmp sudo mount -t tmpfs -o size=1048576,mode=1777 overflow /tmp
This should give you an 1MB partition (just like the one you had =P).
Now, to increase the size, you increase the size in that line, so that, with size=10485760 , you’d get 10 MB.
Your goal is to find a number that is enough for the job, but leaves enough ram too
Comments on 1
You may want to try sudo umount -l /tmp , if you get some variation of «the file system is busy and cannot be unmounted»
Another possible solution to «the file system s busy(. )» is to do fuser -m /tmp to find pids (process numbers) that are using /tmp, then ps -elf , stop or kill processes
You may want to try sudo mount -t tmpfs -o size=1MB,mode=1777 overflow /tmp or even sudo mount -t tmpfs -o size=1G,mode=1777 overflow /tmp (for 1 megabyte or 1 gigabyte, respectively) — that is, units are available so that you dont have to type a huge number
Open a terminal and run sudo umount /tmp or, if that fails, sudo umount -l /tmp .
Delete files in /tmp (now /tmp is the thing actually in your HD, rather than a virtual ram disk), uninstall unused packages, delete files in your home folder and so on.
How to Resize tmpfs on Linux
tmpfs is a temporary file system that stores data in virtual. It does not create an file or directory on your hard drive. If you umnount and remount tmpfs file system all the files and directory residing in it are lost permanently.
tmpfs is similar to ramfs and RAM disk but with a few additional features. tmpfs is able to grow or shrink its space to accommodate files,and it can use swap space to store unneeded data. ramfs and RAM disk doesn’t have this capability.
In this article I will show you how to resize tmpfs on Linux machine.
Resize TMPFS
1. Login to you server with root access.
2. Check the current volume information using df command like below:
# df -h Filesystem Size Used Avail Use% Mounted on /dev/simfs 3.0G 2.6G 505M 84% / none 3.6G 4.0K 3.6G 1% /dev tmpfs 3.0G 3.0G 0.0G 100% /dev/shm
3. Next check how much tmpfs space is beeing used using du command like below.
As you can see tmpfs 100% is used.
4. Lets resize the tmpfs volume by remounting it with a new size parameter. Make sure that the size is at least twice as large as current usage.
# mount -o remount,size=6G,noexec,nosuid,nodev,noatime /dev/shm
5. Verify the made changes using df command.
# df -h Filesystem Size Used Avail Use% Mounted on /dev/simfs 3.0G 2.6G 505M 84% / none 3.6G 4.0K 3.6G 1% /dev tmpfs 6.0G 3.0G 3.0G 50% /dev/shm
6. Edit the /etc/fstab file to make this changes permanently.
# vim /etc/fstab none /dev/pts devpts rw 0 0 tmpfs /dev/shm tmpfs size=6G,noexec,nosuid,nodev,noatime 0 0
Save and close file. You can also run mount command to apply changes in /etc/fstab file.
Увеличить размер каталога /tmp/
Мануал
Иногда необходимо увеличить размер каталога, который в свою очередь находится в корневом каталоге системы.
# mount -t tmpfs tmpfs /tmp -o size=1024M,mode=1777,remount
Теперь проверим, есть ли у нас каталог в фстабе:
Если нет, создаем, если существует то выполняем следующую команду:
# none /tmp tmpfs size=1024M,mode=1777,rw 0 0
Теперь готов каталог/tmp/ с размером, указанным в операторе “size” размером 1024 mb.
Пожалуйста, не спамьте и никого не оскорбляйте. Это поле для комментариев, а не спамбокс. Рекламные ссылки не индексируются!
- Аудит ИБ (49)
- Вакансии (12)
- Закрытие уязвимостей (105)
- Книги (27)
- Мануал (2 305)
- Медиа (66)
- Мероприятия (39)
- Мошенники (23)
- Обзоры (819)
- Обход запретов (34)
- Опросы (3)
- Скрипты (114)
- Статьи (352)
- Философия (114)
- Юмор (18)
Anything in here will be replaced on browsers that support the canvas element
В этой заметке вы узнаете о блокировке IP-адресов в Nginx. Это позволяет контролировать доступ к серверу. Nginx является одним из лучших веб-сервисов на сегодняшний день. Скорость обработки запросов делает его очень популярным среди системных администраторов. Кроме того, он обладает завидной гибкостью, что позволяет использовать его во многих ситуациях. Наступает момент, когда необходимо ограничить доступ к […]
Знаете ли вы, что выполняется в ваших контейнерах? Проведите аудит своих образов, чтобы исключить пакеты, которые делают вас уязвимыми для эксплуатации Насколько хорошо вы знаете базовые образы контейнеров, в которых работают ваши службы и инструменты? Этот вопрос часто игнорируется, поскольку мы очень доверяем им. Однако для обеспечения безопасности рабочих нагрузок и базовой инфраструктуры необходимо ответить […]
Одной из важнейших задач администратора является обеспечение обновления системы и всех доступных пакетов до последних версий. Даже после добавления нод в кластер Kubernetes нам все равно необходимо управлять обновлениями. В большинстве случаев после получения обновлений (например, обновлений ядра, системного обслуживания или аппаратных изменений) необходимо перезагрузить хост, чтобы изменения были применены. Для Kubernetes это может быть […]
Является ли запуск сервера NFS в кластере Kubernetes хорошей идеей или это ворота для хакеров Одним из многочисленных преимуществ сетевой файловой системы является ее способность выполнять многократное чтение-запись. И как и все в наши дни, NFS – это просто еще одна служба, которую можно запустить в своем кластере Kubernetes. Однако является ли сервер NFS подходящей […]
Репозитории Git хранят ценный исходный код и используются для создания приложений, работающих с конфиденциальными данными. Если злоумышленнику удастся скомпрометировать учетную запись GitHub с уязвимым репозиторием, он сможет перенести вредоносные коммиты прямо на производство. Подписанные коммиты помогают избежать этого. Что такое подписанные коммиты? Подписанные коммиты подразумевают добавление цифровой подписи к вашим коммитам с использованием закрытого криптографического […]