我正在尝试将 tmfs 文件系统大小从 1.1 GB 扩展到 2GB。
尝试了以下命令-
[root@~]# df -h /dev/shm/
Filesystem Size Used Avail Use% Mounted on
tmpfs 1.1G 732K 1.1G 1% /dev/shm
编辑 fstab
/etc/fstab
tmpfs /dev/shm tmpfs size=2.0G 0 0
尝试使用 mount 命令重新挂载文件系统
收到错误信息:-
mount : /dev/shm not mounted or bad option try using
dmesg | tail
尝试了以下命令
root @ dmesg | tail :-
SELinux: initilized (dev tmpfs, type tmpfs), use transition SIDs
tmpfs: BAD value '2.0G' for mount option 'size'
安装选项大小的合适值是多少?
答案1
如果您的示例 fstab 条目准确,则您已指定有效大小2g
。但dmesg
输出显示2.0G
。我不知道这是怎么回事。你犯了错误吗?还有很多其他方法可以指定大小。尝试在字节,因为它是默认设置。2147483648
我认为是这样的。
mount
手册页:
Mount options for tmpfs
size=nbytes
Override default maximum size of the filesystem. The size is given in bytes, and rounded up to entire pages. The default is half of the memory. The size parameter also accepts a suffix % to
limit this tmpfs instance to that percentage of your physical RAM: the default, when neither size nor nr_blocks is specified, is size=50%
nr_blocks=
The same as size, but in blocks of PAGE_CACHE_SIZE
nr_inodes=
The maximum number of inodes for this instance. The default is half of the number of your physical RAM pages, or (on a machine with highmem) the number of lowmem RAM pages, whichever is the
lower.
The tmpfs mount options for sizing (size, nr_blocks, and nr_inodes) accept a suffix k, m or g for Ki, Mi, Gi (binary kilo (kibi), binary mega (mebi) and binary giga (gibi)) and can be changed on
remount.
只是为了确保你有足够的内存,对吧?以防万一错误...默认最多使用 50% 的内存。
编辑:
我注意到您编辑了您的问题,并将 fstab 行从 改为2g
。2.0G
那是问题所在吗?您还没有回复。尝试2g
或字节有效吗?
答案2
从 mount 的手册页(向下滚动很多):
Mount options for tmpfs
size=nbytes
Override default maximum size of the filesystem. The size is given
in bytes, and rounded up to entire pages. The default is half of
the memory. The size parameter also accepts a suffix % to limit
this tmpfs instance to that percentage of your physical RAM: the
default, when neither size nor nr_blocks is specified, is size=50%
nr_blocks=
The same as size, but in blocks of PAGE_CACHE_SIZE