Step 1: Securing /tmp
Step 1.1: Backup your fstab file
1 |
cp /etc/fstab /etc/fstab.bak |
Step 1.2: Creating tmpmnt partition file (Around 1Gb in size)
1 2 |
cd /var dd if=/dev/zero of=tmpMnt bs=1024 count=1048576 |
Step 1.3: Format the new partition
1 |
mkfs.ext3 -j /var/tmpMnt |
Press Y when asked
Step 1.4: Making backup of old /tmp
1 |
cp -Rp /tmp /tmp_backup |
Step 1.5: Mount the tmp filesystem
1 |
mount -o loop,noexec,nosuid,rw /var/tmpMnt /tmp |
Step 1.6: Set the right permissions
1 |
chmod 0777 /tmp |
Step 1.7: Copy the files back to new tmp folder
1 |
cp -Rp /tmp_backup/* /tmp/ |
Step 1.8: Adding new /tmp filesystem to fstab
1 |
echo "/var/tmpMnt /tmp ext3 loop,rw,noexec,nosuid,nodev 0 0" >> /etc/fstab |
Step 2: No need for 2 tmp filesystems, so we symlink /var/tmp to /tmp
1 2 |
rm -rf /var/tmp/ ln -s /tmp/ /var/tmp |
source: http://www.directadmin.com/forum/showthread.php?t=29807&page=1