Extend the tmpfs file system

centos7filesystemstmpfs

I'm trying to extend the tmfs file system size from 1.1 GB to 2GB.

Tried the following commands-

[root@~]# df -h /dev/shm/
Filesystem Size Used Avail Use% Mounted on
tmpfs      1.1G 732K 1.1G   1% /dev/shm

Edited the fstab

/etc/fstab

tmpfs /dev/shm tmpfs size=2.0G 0 0

tried to remount the file system using mount command

Got an error saying :-

mount : /dev/shm not mounted or bad option  try using 
dmesg | tail 

Tried the following command

root @ dmesg | tail :- 
SELinux: initilized (dev tmpfs, type tmpfs), use transition SIDs
tmpfs: BAD value '2.0G' for mount option 'size'

What might be a good value for the mount option size?

Best Answer

If your example fstab entry is accurate, you have specified a valid size as 2g. But the dmesg output shows 2.0G. I don't know what's up with that. Did you make a mistake? There are lots of other ways to specify the size. Try specifying it in bytes, since it's the default. That would be 2147483648 or so I believe.

mount man page:

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.

And just to make sure, you have enough memory right? Just in case the error is incorrect... the default is to use 50% of your memory as a maximum.

EDIT:

I noticed you edited your question and changed the fstab line from 2g to 2.0G. Was that the problem? You haven't reported back. Did trying 2g or bytes work?