Get the App
SLTechnology News&Howtos  ›  Database  › 

How Linux 6 makes tmpfs effective

Shulou Source: shulou.com Published: 2022-05-31 14:46:52 11月14日 Update

Editor to share with you how Linux 6 to make tmpfs effective, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The solution is to add parameters to: / etc/fstab so that the configuration is loaded automatically when the system starts:

Tmpfs / dev/shm tmpfs defaults,size=3G 0 0

The default value of tmpfs is half of the system memory, this configuration can be used normally under Redhat system, but I tested under Oracle Linux 6.1and found that this parameter does not take effect, even if it is set here to 3G tmpfs OS startup, the size of the check memory will still become half of the memory.

Manual mount is required to take effect after startup:

[root@rac1 ~] # df-lh

Filesystem Size Used Avail Use% Mounted on

/ dev/sda3 14G 11G 2.4G 83% /

Tmpfs 3.0G 0 3.0G 0% / dev/shm

/ dev/sda1 194M 46M 139m 25% / boot

Tmpfs 3.0G 0 3.0G 0% / dev/shm

[root@rac1 ~] # cat / etc/fstab

#

# / etc/fstab

# Created by anaconda on Tue Nov 2213:02:55 2011

#

# Accessible filesystems, by reference, aremaintained under'/ dev/disk'

# See man pages fstab (5), findfs (8), mount (8) and/or blkid (8) for more info

#

UUID=b1d2de8e-de31-4deb-b4e8-755c0ed01616/ ext4 defaults 1 1

UUID=4df5aa5f-8ef0-473a-931a-51d11e21aa53/boot ext4 defaults 1 2

UUID=82085104-5021-4aaf-8e85-f213998107b6swap swap defaults 0 0

Tmpfs / dev/shm tmpfs defaults,size=3G 0 0

Devpts / dev/pts devpts gid=5,mode=620 0 0

Sysfs / sys sysfs defaults 0 0

Proc / proc proc defaults 0 0

[root@rac1 ~] #

So if we just modify / etc/fstab, there will be no effect under Oracle Linux6.1.

We also need to modify another configuration file for the modification of tmpfs in fstab to take effect: / etc/rc.d/rc.sysinit

Step 1: comment the following statement

# mount-f / dev/shm > / dev/null2 > & 1

Step 2:

Find the following in rc.sysinit:

# Mount all other filesystems (except forNFS and / proc, which is already

# mounted). Contrary to standard usage

# filesystems are NOT unmounted in singleuser mode.

If ["$READONLY"! = "yes"]; then

Action $"Mounting local filesystems:" mount-a-tnonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2-O no_netdev

Else

Action $"Mounting local filesystems:" mount-a-n-tnonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2-O no_netdev

Fi

Add the type tmpfs in the following section:

If ["$READONLY"! = "yes"]; then

Action $"Mounting local filesystems:" mount-a-t tmpfs,nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2-O no_netdev

Else

Action $"Mounting local filesystems:" mount-a-n-t tmpfs,nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2-Ono_netdev

Fi

Then restart OS:

[root@rac1 ~] # df-lh

Filesystem Size Used Avail Use% Mounted on

/ dev/sda3 14G 11G 2.4G 83% /

Tmpfs 3.0G 88K 3.0G 1% / dev/shm

/ dev/sda1 194M 46M 139m 25% / boot

Now after rebooting, tmpfs can automatically change according to the value we set.

The above is all the contents of the article "how to make tmpfs effective in Linux 6". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Content articles systems configuration memory parameters not much can make size most cases manual files methods is in more comments knowledge types industries Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Huawei NVidia Shulou Technology OPPO Reno