How to mount tmpfs?

0315

To mount a tmpfs filesystem in Linux, you can use the mount command. Here’s how to do it:

Basic Command

sudo mount -t tmpfs -o size=SIZE tmpfs MOUNT_POINT

Parameters

  • SIZE: Specify the size of the tmpfs filesystem (e.g., 100M for 100 megabytes, 1G for 1 gigabyte). If you want it to use all available memory, you can omit this option.
  • MOUNT_POINT: The directory where you want to mount the tmpfs filesystem (e.g., /mnt/mytmpfs).

Example

  1. Create a Mount Point:
    First, create a directory where you want to mount the tmpfs:

    sudo mkdir /mnt/mytmpfs
  2. Mount the tmpfs:
    Now, mount the tmpfs filesystem:

    sudo mount -t tmpfs -o size=100M tmpfs /mnt/mytmpfs
  3. Verify the Mount:
    You can verify that it has been mounted by using the df command:

    df -h /mnt/mytmpfs

Unmounting

To unmount the tmpfs, use the following command:

sudo umount /mnt/mytmpfs

Persistent Mount

If you want to make the tmpfs mount persistent across reboots, you can add an entry to the /etc/fstab file:

tmpfs   /mnt/mytmpfs   tmpfs   size=100M   0   0

This will ensure that the tmpfs is mounted automatically at boot time.

0 Comments

no data
Be the first to share your comment!