[CONTENT] Linux common parameters of /etc/fstab file

/dev/vg/lv_var /var xfs nodev,nosuid,noexec 0 0
/dev/vg/lv_var_log /var/log xfs nodev,nosuid,noexec,x-systemd.requires-mounts-for=/var 0 0

(
Add:
1) nodev parameter here means this directory can not be interpreted by devices or blocks
2) nosuid parameter here means no setuid files can be created in this directory
3) noexec parameter here means no files can be executed in this directory
4) x-systemd.requires-mounts-for=/var here parameter means /var/log directory can not be mounted until /var directory has been mounted
)

[DEBUG] Linux resolve df command is stuck

Error phenomenon:

Input df command and the command is stuck
Can not us cd / command to access /(root) directory
Can not us ls / command to display /(root) directory

Analysis:

There may be some network storage disconnected

Solution:

Step One: Use mount command to check if there is any disconnected network storage here

# mount

Step Two: Use unmount command to unmount this disconnected network storage

# umount -f -l <nfs storage which is stuck>

[CONTENT] Linux recommended swap size

RHEL6 RHEL7 RHEL8 RHEL9

RAM sizeRecommended swap sizeRecommended swap size if allowing for hibernation
From 0 to 2GB 2 times the RAM size3 times the RAM size
From 2GB to 8GBThe same size of the RAM2 times the RAM size
From 8GB to 64GBAt least 4GB1.5 times the RAM size
From 64GBAt least 4GBHibernation is not recommended
RHEL6 RHEL7 RHEL8 RHEL9 Recommended swap size table

Note: A 100GB swap is recommended if system with over 140 logical processes or over 3TB RAM

Reference:

https://access.redhat.com/solutions/15244

[步骤] Linux 虚拟内存 (交换分区) swap 的设置

步骤一:理解 Linux 虚拟内存 (交换分区) swap 使用优先级的设置机制

Linux 的 swappiness 参数用于控制虚拟内存 (交换分区) swap 的使用。
swappiness 参数的默认值是 60,也就是说当物理内存使用率达到 40 时,开始使用虚拟内存 (交换分区) swap。
当 swappiness 参数的值是 0 时,则只有当物理机内存耗尽了以后才会使用虚拟内存 (交换分区) swap。
当 swappiness 参数的值是 100 时,则立刻使用虚拟内存 (交换分区) swap。

步骤二:Linux 虚拟内存 (交换分区) swap 开关的设置

2.1 查看虚拟内存 (交换分区) swap

# swapon -s

2.2 开启虚拟内存 (交换分区) swap

# swapon -a

2.3 关闭虚拟内存 (交换分区) swap

# swapoff -a

2.4 重启虚拟内存 (交换分区) swap

# swapoff -a && swapon -a

步骤三:Linux 虚拟内存 (交换分区) swap 使用优先级的设置

3.1 临时设置虚拟内存 (交换分区) swap 使用优先级的设置

# sysctl -p swappiness=60

或者:

# sysctl vm.swappiness=60

或者:

# echo 60 > /proc/sys/vm/swappiness

(补充:这里以把 swappiness 的值设置成 60 为例)


注意:
1) 临时设置重启后失效
2) 临时设置了以后不会马上生效,只有当系统重新调用内存以后才会生效

3.2 永久设置虚拟内存 (交换分区) swap 使用优先级的设置

3.2.1 修改 /etc/sysctl.conf 文件
# vim /etc/sysctl.conf

添加以下内容:

......
vm.swappiness=60

(补充:这里以把 swappiness 的值设置成 60 为例)

3.2.2 让刚刚修改的 /etc/sysctl.conf 文件生效
# sysctl -p

3.3 查看虚拟内存 (交换分区) swap 使用优先级的设置

3.3.1 通过 /proc/sys/vm/swappiness 文件查看
# cat /proc/sys/vm/swappiness
3.3.2 通过 sysctl vm.swappiness 命令查看
# sysctl vm.swappiness