Sponsored Content
Top Forums Shell Programming and Scripting How to add nodev for /dev/shm partition in Linux using shell script? Post 302914956 by Perderabo on Friday 29th of August 2014 10:56:06 AM
Old 08-29-2014
Actually, I think that the OP wants to alter /etc/fstab via a shell script to make this change permanent. I had to make a similar change because our security auditors requested it. In my case i had to modify our kickstart file so that "nodev,nosuid,noexec" was added to /dev/shm during the OS installation. What I did was:
Code:
awk ' $2=="/dev/shm" { $4=$4",nodev,nosuid,noexec" ;} 1' < fstab  > fstab.new
cp fstab.new fstab
rm fstab.new

There were other, similiar changes to other file systems. I gave each one it's own paragraph. This makes it easy to modify later. That awk statement is very easy to understand which means that I don't need to waste time explaining code to an auditor who is reviewing my kickstart.
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

Ran out of space on /dev/root partition

hi, I have a SCO unix server which has a 36gb hard drive, but the IT company who supplied it assigned 1gb to /dev/root, 15mb to /dev/boot and 33gb to /dev/u. The /dev/root partition is now full, is there a way I can use the 33gb assigned to /dev/u without loosing any data, preferably... (2 Replies)
Discussion started by: Martyn
2 Replies

2. UNIX for Dummies Questions & Answers

Need to add aditional space on an exsisting Linux Partition..

Hi, I need to add more space to an exsisting /u partition by adding an additional physical drive, so that the additional space is added in continuation to the exsisting /u diskspace. Is it possible...if yes....how do I go about it. Thanks, Amit (1 Reply)
Discussion started by: amitsayshii
1 Replies

3. UNIX for Dummies Questions & Answers

Remove /dev/sdb partition using fdisk - BY ACCIDENT!

Hello everyone - Please forgive me if I violate the forum's etiquette as this is my very first post. I'm posting this on both the dummies and the advance section with the hope for any responses. I stumbled on this forum while frantically looking for an answer to a dumb, ignorant thing I did... (2 Replies)
Discussion started by: kevindoman
2 Replies

4. UNIX for Advanced & Expert Users

Remove /dev/sdb partition using fdisk - BY ACCIDENT!

Hello everyone - Please forgive me if I violate the forum's etiquette as this is my very first post. I'm posting this on both the dummies and the advance section with the hope for any responses. I stumbled on this forum while frantically looking for an answer to a dumb, ignorant thing I did... (5 Replies)
Discussion started by: kevindoman
5 Replies

5. Shell Programming and Scripting

Shell script to make and mount a Partition

Hi, I need to mount a new partition in a series of Pc that have a single hard drive of 20 GB; the used and partioned space amounts to 10 GB, between root, boot and swap; the script is to make the mounting process automatic These are the contents of my script: ... (1 Reply)
Discussion started by: HernandJ2
1 Replies

6. Shell Programming and Scripting

shell script Partition Creation

Hello all How is it going I want Shell Patch The work of the following division of the disk Can this 200 MB EXT3 /boot 20 Gb EXT3 / 10 GB Swap End Of Space ( Linux LVM ) Found a similar script can be customized by you to be the work required #!/bin/bash VSIZE=200 fdisk /dev/hda... (1 Reply)
Discussion started by: x-zer0
1 Replies

7. UNIX for Advanced & Expert Users

/dev/shm space in red hat linux

I am using redhat linux machine and oracle11g version. /dev/shm shows 88%. Will this be freed automatically? OR should i clean any files? >df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/systemvg-rootvol 7.6G 2.2G 5.1G 30% /... (5 Replies)
Discussion started by: govindts
5 Replies

8. Red Hat

Shrink LVM partition & create new Linux Primary partition

Hello All, I have a Red Hat Linux 5.9 Server installed with one hard disk & 2 Partitions created on it as follows, /boot - Linux Partition & another is LVM - One VG & under that 5-6 Logical volumes(var,opt,home etc). Here my requirement is to take out 1GB of space from LVM ( Any logical... (5 Replies)
Discussion started by: gr8_usk
5 Replies

9. UNIX for Dummies Questions & Answers

Increasing size for /dev/shm

Hello, How do I increase the size of /dev/shm ? Additional pv have been added and rootlv has been extended How can I extend /dev/shm? Best regards, Vishal (1 Reply)
Discussion started by: admin_db
1 Replies

10. UNIX for Advanced & Expert Users

Disk /dev/sdb doesn't contain a valid partition table

Hello, I have rebooted the RHEL VM but after rebooting the vm it not showing all the partition mounted on OS level, if i'll execute the fdisk -l command, then i'm able to see the same disk. below is the fdisk output : # fdisk -l Disk /dev/sda: 107.6 GB, 107639996416 bytes 255 heads, 63... (1 Reply)
Discussion started by: purushottamaher
1 Replies
tmpfs(5)						   Debian Administrator's Manual						  tmpfs(5)

NAME
tmpfs - variables that configure tmpfs filesystems mounted during boot DESCRIPTION
The /etc/default/tmpfs file contains variable settings in POSIX format: VAR=VAL Only one assignment is allowed per line. Comments (starting with '#') are also allowed. This file is for the configuration of tmpfs filesystems mounted in early boot, before filesystems from /etc/fstab are mounted. This cur- rently includes the filesystems /run, /run/lock, /run/shm and /tmp. /run is required to be a tmpfs on systems supporting tmpfs mounts. /run/lock and /run/shm may be separate tmpfs mounts, useful for enforcing separate size limits. /tmp is not required to be a tmpfs, but is mounted as a tmpfs by default. /run Previously configured using RAMRUN in /etc/default/rcS, /run is now always mounted as a ram file system (tmpfs). The size of the tmpfs can be controlled using TMPFS_SIZE and RUN_SIZE. If desired, the defaults may also be overridden with an entry in in /etc/fstab, for example: tmpfs /run tmpfs nodev,nosuid,size=10%,mode=755 0 0 The contents of /run will always be lost on system reboot, and it it is no longer explicitly cleaned at boot. Packages can not expect directories in /run to exist after boot. Packages expecting this are buggy and need to be fixed. Note that /run was previ- ously /var/run, and a compatibility symlink or bind mount will be created to allow the old path to continue to function. /run/lock Previously configured using RAMLOCK in /etc/default/rcS. Configured using RAMLOCK, TMPFS_SIZE and LOCK_SIZE. If desired, the defaults may also be overridden with an entry in in /etc/fstab, for example: tmpfs /run/lock tmpfs nodev,noexec,nosuid,size=52428800,mode=1777 0 0 Note that irrespective of these settings, /run/lock will be located on a tmpfs, either one mounted on /run/lock (if RAMLOCK=yes) or one mounted on /run (if RAMLOCK=no), and as a result the contents of /var/lock will always be lost on system reboot, and it it is no longer explicitly cleaned at boot. Packages can not expect directories in /var/lock to exist after boot. Packages expecting this are buggy and need to be fixed. Note that /run/lock was previously /var/lock, and a compatibility symlink or bind mount will be created to allow the old path to continue to function. /run/shm Previously configured using RAMSHM in /etc/default/rcS. Note that the setting in /etc/default/rcS, if present, will still be used, but the setting in /etc/default/tmpfs will take precedence if enabled. Configured using RAMSHM, TMPFS_SIZE and SHM_SIZE. If desired, the defaults may also be overridden with an entry in in /etc/fstab, for example: tmpfs /run/shm tmpfs nosuid,nodev,size=40%,mode=1777 0 0 Packages can not expect directories in /run/shm to exist after boot. Note that /run/shm was previously /dev/shm, and a compatibil- ity symlink or bind mount will be created to allow the old path to continue to function. If an fstab entry for /dev/shm exists instead of /run/shm, then /dev/shm will continue to be used; note that this is only needed for users of newer versions of the Oracle database, which contain a buggy check for /dev/shm. /tmp Previously configured using RAMTMP in /etc/default/rcS. Note that the setting in /etc/default/rcS, if present, will still be used, but the setting in /etc/default/tmpfs will take precedence if enabled. Configured using RAMTMP, TMPFS_SIZE and TMP_SIZE. If desired, the defaults may also be overridden with an entry in in /etc/fstab, for example: tmpfs /tmp tmpfs nodev,nosuid,size=20%,mode=1777 0 0 Packages can not expect directories in /tmp to exist after boot. OPTIONS
The following variables can be set. Enabling or disabling tmpfs mounts The following options enable specific mounts (with the exception of /run) to be enabled or disabled. Note that the addition of an entry to /etc/fstab for any of the following will enable the mount unconditionally, overriding the setting here. RAMLOCK Mount /run/lock as a tmpfs (separately from /run). Defaults to yes; set to no to disable (/run/lock will then be part of the /run tmpfs, if available). RAMSHM Mount /run/shm as a tmpfs (separately from /run). Defaults to yes; set to no to disable (/run/shm will then be part of the /run tmpfs, if available). RAMTMP Mount /tmp as a tmpfs. Defaults to no; set to yes to enable (/tmp will be part of the root filesystem if disabled). /tmp may also be configured to be a separate mount in /etc/fstab, which will override the RAMTMP setting. Configuring size limits for tmpfs mounts The following options configure size limits for tmpfs mounts. Note that the addition of an entry to /etc/fstab will override any of the limits specified here. The following _SIZE variables are the maximum size (in bytes) that tmpfs filesystems can use. The size will be rounded down to a multiple of the page size, 4096 bytes. If no size is set, TMPFS_SIZE will be used as the default. More complex mount options may be used by the creation of a suitable entry in /etc/fstab. For example: tmpfs /run tmpfs size=10% 0 0 is equivalent to RUN_SIZE=10% and will override the RUN_SIZE setting. This will allow additional options such as nr_blocks and nr_inodes to be used, and also adjustment of the mode, nodev, nosuid, noexec options should any change from the defaults be necessary. TMPFS_SIZE Maximum size for all tmpfs filesystems if no specific size is provided. The default is 20%VM (20% of virtual memory, including swap space). If no value is provided here, the kernel default (50% RAM) will be used. Note that the "%VM" suffix may be used in this and all the _SIZE settings below, but may not be used in /etc/fstab (the absolute size is calculated by the init scripts). RUN_SIZE Maximum size of /run (was previously /var/run). The default is 10% core memory; the size required varies widely depending upon the demands of the software being run; this heuristic scales /run usage on system size. Samba in particular has been seen to use at least 50MiB in a large heavily used server. Typical usage is hundreds of KiB, maximum is tens of MiB. LOCK_SIZE Maximum size of /run/lock (was previously /var/lock). Defaults to 5242880 (5 MiB). Typical usage: tens of KiB; maximum hundreds of KiB. The default of 5 MiB should ensure the limit is never reached. SHM_SIZE Maximum size of /run/shm (was previously /dev/shm). No default size; the size required varies widely depending upon the demands of the software being run. TMP_SIZE Maximum size of /tmp. No default size. Emergency overflow /tmp If the amount of free space on the root filesystem falls below a certain size, a tmpfs will be mounted on /tmp (irrespective of the RAMTMP setting, which this overrides). This is to permit logins when there would otherwise be too little free space for this to be possible. TMP_OVERFLOW_LIMIT Mount a tmpfs on /tmp if the amount of free space on the root filesystem is below the specified limit at boot time (default 1024 KiB). AUTHOR
Roger Leigh <rleigh@debian.org> SEE ALSO
mount(8), rcS(5). 18 Feb 2012 tmpfs(5)
All times are GMT -4. The time now is 12:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy