Skip navigation.
Home
Now Shipping Version 7.0

Preventing /etc/fstab From Updating Automatically

Jon Du Quesne's picture

Posts: 5513

I have been reading the various threads about /etc/fstab "magically" changing when the system starts but I haven't responded because I couldn't find the modifications that I made to my system. But I found them!

You can make some changes to the following files in the /usr/sbin directory so that you can control whether fstab is built or left alone. I am currently running SimplyMepis 3.3.1-1 so I have no knowledge whether this method will work with the 3.4+ version of Mepis and udev Smiling

All changes below must be made as user root.

The files to be modified are /usr/sbin/addfstab and /usr/sbin/buildfstab. A "configuration" file called /etc/default/buildfstab.conf needs to be created.

First, create the file /etc/default/buildfstab.conf. This is what it looks like:

#!/bin/bash
# /etc/default/buildfstab.conf
# 2005-07-19
# Jon Du Quesne

# Configuration file for /usr/sbin/buildfstab and /usr/sbin/addfstab

# If this file does not exist, then /usr/sbin/addfstab and
# /usr/sbin/buildfstab work as usual (they cause /etc/fstab to
# change dynamically.
#
# If this file exists and STATIC_FSTAB is set to 0 (no) (default)
# then /usr/sbin/addfstab and /usr/sbin/buildfstab work as usual.
#
# If this file exists and STATIC_FSTAB is set to 1 (yes)
# then /usr/sbin/addfstab and /usr/sbin/buildfstab are skipped.
# /etc/fstab will not be changed dynamically.

#
# Set STATIC_FSTAB
#
#STATIC_FSTAB=0 # Enables dynamic /etc/fstab changes
STATIC_FSTAB=1 # Disables dynamic /etc/fstab changes

Permissions are read-write for root only.


Next, modify /usr/sbin/addfstab to use the above configuration file. If STATIC_FSTAB is set to 1 then nothing will be added to /etc/fstab.


Here is my modified /usr/sbin/addfstab file (I have only included the section that I changed, marked by "jvd"):



#!/bin/bash
# Calls scanpartitions as root and adds entries to /etc/fstab

PATH="/bin:/sbin:/usr/bin:/usr/sbin"
export PATH
umask 022

# *** beg 2005-07-19 jvd ***
if [ -f /etc/default/buildfstab.conf ] ; then
. /etc/default/buildfstab.conf
if [ $STATIC_FSTAB != 0 ] ; then
exit 0
fi
fi
# *** end 2005-07-19 jvd ***

[ ! -e /proc/partitions ] && { echo "$0: /proc not mounted, exiting" >&2; exit 1
; }


Next, the changes to /usr/sbin/buildfstab (again, my changes marked with "jvd"):



#!/bin/bash
# Calls scanpartitions as root and adds entries to /etc/fstab

PATH="/bin:/sbin:/usr/bin:/usr/sbin"
export PATH
umask 022

# *** beg 2005-07-19 jvd ***
if [ -f /etc/default/buildfstab.conf ] ; then
. /etc/default/buildfstab.conf
if [ $STATIC_FSTAB != 0 ] ; then
exit 0
fi
fi
# *** end 2005-07-19 jvd ***

[ ! -e /proc/partitions ] && { echo "$0: /proc not mounted, exiting" >&2; exit 1
; }


I hope this will help Smiling


Jon


good work:)

good work:)

Thanks sir, that so make easy to work cause I make server now

EKO WAHYUDI
Lampung Post
Electronic Data Processing & Programer

Thanks so much!

At first I found MEPIS' Kwikdisk a great utility, but having about 20 partitions spread over 4 drives made it tough to keep track of what was where. And the frustration of having my edited fstab overwritten!

Your instructions are clear and get the job done. You've made me very happy, and I'm starting to like MEPIS more because of it.

BTW, I'm running 6.5_rc2 and had no problems. Thanks again!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.