Bypass Ext File System Read-Only Mode on Errors

If you have poorly written software which corrupts your file system e.g. during its installation, you probably face the problem that once the error occurs, the filesystem will lock for writing, and then your installation suddenly dies, hopeless.

Well, in the case that you want to force it to continue, even after (it) having broken your file system, you can, if it is in the EXT family (EXT2, EXT3 filesystems). The command is (as root) this:

tune2fs -e continue device

device is the one device this option is going to be applied.

Then, after the next reboot, e2fsck (file system check) will check the error, anyway, so you are “safe”. I had two situations installing poorly written software (I hope only the installer is poor in quality), and it helped going on until the end. One of them uses file system intensively and did not present any errors during production execution.

This is analogous to the mount command’s option errors (mount -o errors=continue). Or it can also be one of the options field’s values, in the fstab file e.g. “defaults,errors=continue“.

Useful Shell Function pathmunge

When I wrote a function that updated the PATH environment variable to include a new directory path in its set of values I had named it “addtopath”, and “addtopathhigh” when prepending such directory. I was tweaking the /etc/profile file in Red Hat Enterprise Linux 5.3 when I saw this pathmunge function. It does the same:

pathmunge () {
  if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
     if [ "$2" = "after" ] ; then
        PATH=$PATH:$1
     else
        PATH=$1:$PATH
     fi
  fi
}

The difference, is that it both prepends and appends the PATH variable with the given argument ($1). The second argument controls whether it is an append operation when it is passed the value “after”, otherwise, it just prepends the given path to PATH’s value (analogous to the addtopathhigh function, which prepends the directory to the value and thus makes the added path with HIGHer priority in the search path, that was the reason why I named it that way).

In order to maintain it standard with RHEL I decided to adopt this function. Same name. But I improved it. The new definition expands the variables with curly braces, and after the pre/append it also sanitizes it by cleaning any preceding or trailing semi-colons for the basic case when the PATH variable had an empty value prior to the “munging”.

Here it is:

pathmunge () {
  if ! echo "${PATH}" | /bin/egrep -q "(^|:)${1}($|:)" ; then
    if [ "$2" = "after" ] ; then
      PATH="${PATH}:${1}"
      PATH="${PATH#:}"
    else
      PATH="${1}:${PATH}"
      PATH="${PATH%:}"
    fi
  fi
}