Dynamically setting mountpoints writeable or read-only??

Walter Dnes waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org
Mon May 15 02:38:43 UTC 2006


  Saturday, I did some "oops" programming.  The only "object-oriented"
thing about it is that some people might "object" to some of my
expletives at the time.  I ran a script to do a major backup to a usb
"shirtpocket" external drive mounted as /mnt/pocket1.  I then took the
drive, plus my 2006 condo insurance papers and my keeper copy of my 2005
income tax to the bank where I stashed them in my safety deposit box.

  I took a second "shirtpocket" drive out of the safety-deposit box and
brought it home.  This drive mounts as /mnt/pocket2.  How many people
see what's coming next?  I then ran the same backup script as in the
morning, which proceeded to copy tons of stuff to /mnt/pocket1, which at
this point was merely an empty directory on the / partition... oops.
Fortunately, reiserfs didn't get hurt buy the full root partition, and I
deleted the stuff in /mnt/pocket1.

  So how do I prevent this in future?  Here are my options...

1) Is there a way to make directories like /mnt/pocket1 read-only, even
for root, when the corresponding device is not mounted?

2) Create a small, 1-cylinder-long dedicated ext2fs partition, and mount
that as /mnt.

3) What I've actually done right now, as a temporary fix, is to change
all my backup scripts to look like so...

#!/bin/bash
targetdrive="nonexistant"
if [[ `grep /mnt/pocket1 /etc/mtab` ]]; then
  targetdrive="pocket1"
elif [[ `grep /mnt/pocket2 /etc/mtab` ]]; then
  targetdrive="pocket2"
elif [[ `grep /mnt/bigdrive /etc/mtab` ]]; then
  targetdrive="bigdrive"
fi
echo "Target Drive = ${targetdrive}"
if [[ "${targetdrive}" = "nonexistant" ]]; then
  echo "No backup target drive mounted.  Exiting without backup."
else
  if [ -a /home/waltdnes/minmax.zip ]; then
    rm /home/waltdnes/minmax.zip
  fi
  zip -9r /home/waltdnes/minmax.zip /home/waltdnes/spoolastra/* -i */.minmax
  rsync -av --delete --exclude-from=/home/waltdnes/.excludersync1 \
    /home/waltdnes/ /mnt/${targetdrive}/waltdnes/
fi

  "bigdrive" is one of those large external USB drives that sits on its
side.  Nice, but way too large to fit into my safety deposit box.  An
extra-large safety-deposit box means a long waiting list (a couple of
years) and is expensive.  Backups at home are nice, but if the condo
burns down, I lose the backups as well as the computer.  "pocket1" and
"pocket2" are a couple of 40-gig "shirtpocket" drives that I rotate
through the safety deposit box.  One of them is always at the bank.

-- 
Walter Dnes <waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org> In linux /sbin/init is Job #1
My musings on technology and security at http://tech_sec.blog.ca
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list