2 # Script for flexible /etc/fstab.d configuration
3 # From Atha, with a lot of improvements from truc - thanks!
5 # You can find information on how to use this script at
6 # http://forums.gentoo.org/viewtopic.php?p=6364143
8 # This script idealy goes into /usr/local/bin and is called update-fstab -
9 # you need to configure your fstab entries in separate files in /etc/fstab.d;
10 # only filenames starting with two digits are included!
11 # Examples: /etc/fstab.d/01base or /etc/fstab.d/61nfs-dm8000, to name just two.
14 # Distributed under the terms of the GNU General Public License v2 or later
18 # fstabdpath sets the path where the individual fstab file are located, this should normaly be /etc/fstab.d.
19 fstabdpath
="/etc/fstab.d"
20 # fstabdverbose sets the verbosity level. Default is 0 (no messages). If you want verbose output (i.e. to debug) set this to 1.
26 [ ${fstabdverbose} -gt 0 ] && echo $@
31 if [ ! -d ${fstabdpath} ] ; then
32 echo "update-fstab: ${fstabdpath} is not present!" >&2
36 if [ -e ${fstabdpath}/fstab
] ; then
37 echo "update-fstab: please remove ${fstabdpath}/fstab before you run this script.
38 update-fstab: NOTE: It may have been left by a previously run update-fstab, but you should check anyway." >&2
42 cat << 'EOT' > ${fstabdpath}/fstab
&& message
"${fstabdpath}/fstab created, header added"
44 # automatically generated by the update-fstab script
46 # Please change the according lines in /etc/fstab.d/* if you want them to be permanent,
47 # otherwise they will not survive the next invocation of update-fstab!
51 for fstab_file
in ${fstabdpath}/[0-9][0-9]* ; do
52 grep '^[^#].*' ${fstab_file} >> ${fstabdpath}/fstab
53 message
"Added: ${fstab_file}"
56 mv -f /etc
/fstab
/etc
/fstab.d.bak
&& message
"Existing /etc/fstab renamed to /etc/fstab.d.bak"
57 mv -f ${fstabdpath}/fstab
/etc
/fstab
&& message
"New file system table ${fstabdpath}/fstab moved to /etc/fstab"