![]() |
|
|||||||
| Guides All Guides and HOWTO's. |
![]() |
|
|
Thread Tools | Display Modes |
|
|||
|
On my current desktop I have the following /etc/fstab:
Code:
/dev/wd0a / ffs rw 1 1 /dev/wd0m /home ffs rw,nodev,nosuid 1 2 /dev/wd0e /home/xx ffs rw,nodev,nosuid 1 2 /dev/wd0d /tmp ffs rw,nodev,nosuid 1 2 /dev/wd0k /usr ffs rw,nodev 1 2 /dev/wd0l /usr/local ffs rw,nodev 1 2 /dev/wd0f /var ffs rw,nodev,nosuid 1 2 /dev/wd0h /var/log ffs rw,nodev,nosuid 1 2 /dev/wd0g /var/tmp ffs rw,nodev,nosuid 1 2 Code:
# ---------------------------------------------------------
FILE=/etc/fstab
FILE=$( basename ${FILE} )
ORIG=${FILE}.orig
LABELS=adefghiml
OPTIONS='noatime,softdep' # no trailing "," after last option !
DISK=wd
NR=0
cat <<END
Enabling mount option(s) "${OPTIONS}" on disk ${DISK}${NR} for label(s): "${LABELS}"
END
cp -p ${FILE} ${ORIG}
sed -e "/${DISK}[${NR}][${LABELS}]/ s/rw/rw,${OPTIONS}/" ${ORIG} >${FILE}
The same applies to the mount options to be added and the labels. Even the file name and the name of the backup of the original, have been factored out. As a test we first copy the /etc/fstab to the current directory. Then we run the script with the sh -vx options to check if the variables are being expanded correctly. Code:
$ cp /etc/fstab .
$ sh -vx softdep-noatime-adefghiml
# ---------------------------------------------------------
FILE=/etc/fstab
+ FILE=/etc/fstab
FILE=$( basename ${FILE} )
+ basename /etc/fstab
+ FILE=fstab
ORIG=${FILE}.orig
+ ORIG=fstab.orig
LABELS=adefghiml
+ LABELS=adefghiml
OPTIONS='noatime,softdep' # no trailing "," after last option !
+ OPTIONS=noatime,softdep
DISK=wd
+ DISK=wd
NR=0
+ NR=0
cat <<END
Enabling mount option(s) "${OPTIONS}" on disk ${DISK}${NR} for label(s): "${LABELS}"
END
+ cat
+ << END
Enabling mount option(s) "noatime,softdep" on disk wd0 for label(s): "adefghiml"
cp -p ${FILE} ${ORIG}
+ cp -p fstab fstab.orig
sed -e "/${DISK}[${NR}][${LABELS}]/ s/rw/rw,${OPTIONS}/" ${ORIG} >${FILE}
+ sed -e /wd[0][adefghiml]/ s/rw/rw,noatime,softdep/ fstab.orig
+ > fstab
Code:
/dev/wd0a / ffs rw,noatime,softdep 1 1 /dev/wd0m /home ffs rw,noatime,softdep,nodev,nosuid 1 2 /dev/wd0e /home/xx ffs rw,noatime,softdep,nodev,nosuid 1 2 /dev/wd0d /tmp ffs rw,noatime,softdep,nodev,nosuid 1 2 /dev/wd0k /usr ffs rw,nodev 1 2 /dev/wd0l /usr/local ffs rw,noatime,softdep,nodev 1 2 /dev/wd0f /var ffs rw,noatime,softdep,nodev,nosuid 1 2 /dev/wd0h /var/log ffs rw,noatime,softdep,nodev,nosuid 1 2 /dev/wd0g /var/tmp ffs rw,noatime,softdep,nodev,nosuid 1 2 Code:
sed -e /wd[0][adefghiml]/ s/rw/rw,noatime,softdep/ fstab.orig >fstab
-e : the sed command(s) follow in-line
On all lines matching the pattern:
/wd[0][adefghiml]/
substitute the 'rw' with 'rw,noatime,softdep'
The pattern selecting on which lines to do this substitution or replacement:
/ : start of search pattern
w : a "w" character followed by a
d : "d" character followed by a
[0] : the "0' character. In this case the two brackets could
have been left out. A 'wd[01]' would match both a 'wd0'
and a 'wd1' string
So a '0' followed by one of the followin charaters between
the '[' and ']'
[ : start of the character class
adefghiml : the members of this class
] : end of character class
This means that 'wd0a', 'wd0d' and 'wd0e' up to 'wd0l[/b]
will match.
/ ; end of search pattern
The 'subsitute' or 'search and replace' operation.
s : we do a substitution
/ : delimiter for start of the pattern
rw : a 'r" followed by a 'w'
/ : end delimiter of search pattern, start delimiter of
replacement pattern
rw, : the string sequence 'rw' followed by a comma, followed
noatime, : by the strings 'noatime,' and
softdep : the string 'softdep'
/ : delimiter signalling end of replacement pattern
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump |
|
|||
|
It has been quite a while since FreeBSD went from wd to ad for hard disks. FreeBSD also not supports the mount option 'softdep'. You have to choose to either use 'soft updates' or not when you do a newfs of the label/partition.
Considering this it is somewhat OpenBSD specific ![]() As consolation, a FreeBSD version with adds the "noatime" mount option. First the FreeBSD fstab: Code:
# Device Mountpoint FStype Options Dump Pass# /dev/ad0s3b none swap sw 0 0 /dev/ad0s3a / ufs rw 1 1 /dev/ad0s3e /tmp ufs rw 2 2 /dev/ad0s3f /usr ufs rw 2 2 /dev/ad0s3d /var ufs rw 2 2 /dev/acd0 /cdrom cd9660 ro,noauto 0 0 Code:
# ---------------------------------------------------------
FILE=/etc/fstab
FILE=$( basename ${FILE} )
ORIG=${FILE}.orig
LABELS=adef
OPTIONS='noatime' # no trailing "," after last option !
DISK=ad
NR=0
SLICE=s3
cat <<END
Enabling mount option(s) "${OPTIONS}" on disk ${DISK}${NR}${SLICE} for label(s): "${LABELS}"
END
cp -p ${FILE} ${ORIG}
sed -e "/${DISK}${NR}${SLICE}[${LABELS}]/ s/rw/rw,${OPTIONS}/" ${ORIG} >${FILE}
Code:
sed -e /ad0s3[adef]/ s/rw/rw,noatime/ fstab.orig >fstab Code:
# Device Mountpoint FStype Options Dump Pass# /dev/ad0s3b none swap sw 0 0 /dev/ad0s3a / ufs rw,noatime 1 1 /dev/ad0s3e /tmp ufs rw,noatime 2 2 /dev/ad0s3f /usr ufs rw,noatime 2 2 /dev/ad0s3d /var ufs rw,noatime 2 2 /dev/acd0 /cdrom cd9660 ro,noauto 0 0
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump |
![]() |
| Tags |
| /etc/fstab, freebsd, mount options, noatime, openbsd, softdep |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with some more sensible fstab defaults | maxrussell | FreeBSD General | 4 | 18th July 2009 02:44 PM |
| C F Card and fstab | terryd | FreeBSD General | 1 | 3rd December 2008 04:26 PM |
| Mounting ext2 in fstab | latorion | FreeBSD General | 3 | 6th August 2008 04:56 PM |
| mount fusefs (sshfs) from fstab | elon | FreeBSD General | 4 | 29th July 2008 06:41 PM |
| fstab and CD/DVD device | corneliu | FreeBSD General | 7 | 24th May 2008 02:11 AM |