Gentoo Archives: gentoo-user

From: Grant Edwards <grant.b.edwards@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] OT: cleanup after USB backup drive unplugged?
Date: Thu, 11 Jan 2018 16:42:49
Message-Id: p3841j$tfr$1@blaine.gmane.org
[This has nothing to do specifically with Gentoo.]

What cleanup actions would you have put in a script to be triggered by
udev when a USB or Firewire backup drive has been unplugged?

The external Firewire drive I used for nightly backups died yesterday.

I replaced it with a USB3 drive, so I needed to update the udev rules
that automatically mount it and then "umount" it when it's removed.
Both rules are firing when they should:

KERNEL=="sd?1",\
 SUBSYSTEMS=="scsi",\
 ENV{ID_SERIAL}=="WD_My_Passport_259F_57584A314143353435594B54-0:0",\
 ACTION=="add",\
 SYMLINK+="passport",\
 RUN+="/bin/mount -text4 -o atime /dev/%k /extbackup"

KERNEL=="sd?1",\
 ACTION=="remove",\
 ENV{ID_SERIAL}=="WD_My_Passport_259F_57584A314143353435594B54-0:0",\
 RUN+="/usr/local/bin/myumount /extbackup"

Here's the embarassing part: The /usr/local/bin/myumount script went
missing (backup drive is dead), and I can't recall exactly what it
did.  Obviously, one should never unplug the drive while it's mounted,
but if that _does_ happen, what would one put in myumount to mitigate
the situation.

The only think I can think of is to do a "umount -l".

-- 
Grant Edwards               grant.b.edwards        Yow! How many retured
                                  at               bricklayers from FLORIDA
                              gmail.com            are out purchasing PENCIL
                                                   SHARPENERS right NOW??

Replies

Subject Author
Re: [gentoo-user] OT: cleanup after USB backup drive unplugged? Adam Carter <adamcarter3@×××××.com>