Default tmpfs configuration

本文介绍如何在Linux系统中初始化RAM磁盘并挂载tmpfs文件系统,包括为/dev/shm和/run目录设置合适的参数。此外,还讨论了如何限制tmpfs文件系统的大小,以避免占用过多内存。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/boot/initramfs-$(uname -r).img

点击(此处)折叠或打开

  1. if ! ismounted /dev/shm; then
  2.     mkdir -m 0755 /dev/shm
  3.     mount -t tmpfs -o mode=1777,nosuid,nodev,strictatime tmpfs /dev/shm >/dev/null
  4. fi

  5. if ! ismounted /run; then
  6.     mkdir -m 0755 /newrun
  7.     mount -t tmpfs -o mode=0755,nosuid,nodev,strictatime tmpfs /newrun >/dev/null
  8.     cp -a /run/* /newrun >/dev/null 2>&1
  9.     mount --move /newrun /run
  10.     rm -fr -- /newrun
  11. fi
/usr/lib/dracut/modules.d/99base/init.sh

The size of a tmpfs filesystem is actually the maximum amount of space that it could use. When the filesystem is empty, it is no using any memory. It won't allow the filesystem to contain more than that size of data, which defaults to 50 of RAM.

点击(此处)折叠或打开

  1. mount -t tmpfs -o mode=1777,nosuid,nodev,strictatime,size=20% tmpfs /dev/shm >/dev/null

  2. mount -t tmpfs -o mode=1777,nosuid,nodev,strictatime,size=10m tmpfs /dev/shm >/dev/null

  3. mount -t tmpfs -o mode=1777,nosuid,nodev,strictatime,nr_blocks=1000 tmpfs /dev/shm >/dev/null




来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24644775/viewspace-2131195/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/24644775/viewspace-2131195/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值