Linux: Create /tmp And Mount as Partition File With the noexec, nosuid, And nodev

Linux: Create /tmp And Mount as Partition File With the noexec, nosuid, And nodev

To create a /tmp partition file and mount it with the noexec, nosuid, and nodev options in Linux, you can follow these steps:

  1. Create the /tmp partition file using the dd command. For example:
dd if=/dev/zero of=/tmp.partition bs=1M count=1024
S‮o‬urce:www.lautturi.com

This will create a 1 GB /tmp.partition file filled with zeros. You can adjust the size of the file and the block size (bs) as needed.

  1. Use the mke2fs command to create an ext2 filesystem on the /tmp.partition file. For example:
mke2fs /tmp.partition
  1. Mount the /tmp.partition file as the /tmp filesystem using the mount command and the noexec, nosuid, and nodev options. For example:
mount -o noexec,nosuid,nodev /tmp.partition /tmp

This will mount the /tmp.partition file as the /tmp filesystem, with the noexec, nosuid, and nodev options enabled.

  1. To make the /tmp partition file persistent across reboots, you can add an entry for it to the /etc/fstab file. For example:
/tmp.partition /tmp ext2 noexec,nosuid,nodev 0 0

This will tell the system to mount the /tmp.partition file as the /tmp filesystem with the noexec, nosuid, and nodev options enabled whenever the system boots.

For more information about creating and mounting partition files in Linux, you can refer to the dd, mke2fs, and mount man pages or search online for tutorials and examples.

Created Time:2017-10-30 10:17:44  Author:lautturi