Difference between revisions of "Ramdisk"

From Linuxintro
imported>ThorstenStaerk
 
Line 6: Line 6:
 
To increase the Ramdisk's size without loosing a file, use
 
To increase the Ramdisk's size without loosing a file, use
 
  mount -t tmpfs tmpfs /tmp -o size=1024M,remount
 
  mount -t tmpfs tmpfs /tmp -o size=1024M,remount
 +
 +
= How it looks =
 +
Once you have mounted /tmp as a RAMDISK, changes will not persist a reboot. New files will cause RAM consumption. To find out if you have /tmp being a RAMDISK, use the command mount or df:
 +
<pre>
 +
root@instance-2:~# df -h | grep tmp
 +
tmpfs            99M  320K  99M  1% /run
 +
tmpfs          493M    0  493M  0% /dev/shm
 +
tmpfs          5.0M    0  5.0M  0% /run/lock
 +
tmpfs          493M    0  493M  0% /sys/fs/cgroup
 +
tmpfs            99M    0  99M  0% /run/user/838632064
 +
tmpfs            12M    0  12M  0% /tmp
 +
root@instance-2:~# mount | grep tmp
 +
udev on /dev type devtmpfs (rw,nosuid,relatime,size=495576k,nr_inodes=123894,mode=755)
 +
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=100956k,mode=755)
 +
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
 +
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
 +
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
 +
tmpfs on /run/user/838632064 type tmpfs (rw,nosuid,nodev,relatime,size=100952k,mode=700,uid=838632064,gid=838632064)
 +
tmpfs on /tmp type tmpfs (rw,relatime,size=12288k)
 +
</pre>
 +
In the above example you have a RAMDISK on /tmp and on some system directories.

Latest revision as of 09:31, 27 November 2021

A Ramdisk in Linux can be created on the /tmp folder using the command

mount -t tmpfs tmpfs /tmp -o size=512M

In this case, the Ramdisk will be 512MB big.

Increase size

To increase the Ramdisk's size without loosing a file, use

mount -t tmpfs tmpfs /tmp -o size=1024M,remount

How it looks

Once you have mounted /tmp as a RAMDISK, changes will not persist a reboot. New files will cause RAM consumption. To find out if you have /tmp being a RAMDISK, use the command mount or df:

root@instance-2:~# df -h | grep tmp
tmpfs            99M  320K   99M   1% /run
tmpfs           493M     0  493M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           493M     0  493M   0% /sys/fs/cgroup
tmpfs            99M     0   99M   0% /run/user/838632064
tmpfs            12M     0   12M   0% /tmp
root@instance-2:~# mount | grep tmp
udev on /dev type devtmpfs (rw,nosuid,relatime,size=495576k,nr_inodes=123894,mode=755)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=100956k,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
tmpfs on /run/user/838632064 type tmpfs (rw,nosuid,nodev,relatime,size=100952k,mode=700,uid=838632064,gid=838632064)
tmpfs on /tmp type tmpfs (rw,relatime,size=12288k)

In the above example you have a RAMDISK on /tmp and on some system directories.