Dear Managers,
Thank you for the help.
I got replies from several dynamic and resourceful managers.
I am enclosing the list of respondents at the end.
I tried my best to name all of them, but, please excuse me
if forgot any name.
My original questions were:
>
> Dear Managers,
>
> I mount a CDROM say, on /cdrom (directory)
> How can I know what are the processes( or users ) accessing
> this device(filesystem) actively or passively( i.e. cd to this
> directory /cdrom and keep idle) ?
>
> How can I unmount a Filesystem diregarding the message "Device Busy" ?
>
> I understand that the kernel(OS) keeps in a table all the
> information pertaining to each and every file opened by
> some user or the other. In some cases more than one process
> may simultaneously use a particular file. If I get this info,
> I may kill all these processes and then unmount. There may be
> idle processes also.
> But how to use this knowledge and practically solve my
> problems mentioned above?
>
> Any ready_to_use utilities(like iostat to get drive usage info)
> or tips which can be converted to utilities in short time.
>
> Thanks for any help in this matter,
>
> Bye
>
>
> Brahmaji
>
Virtually all of them said the same, namely use utility 'lsof'
which is available in public domain ftp sites.
After getting info. about processes and files they use, kill
the processes and try unmounting the file system(CDROM).
This should work in MANY cases, though may fail in rare situations.
As such, it is NOT possible to unmount a filesystem if you get
a message "Device busy" even after doing above step.
(Reboot the system is the only solution , it seems )
The SUMMARY is:
***************************
Try using lsof or ofiles both available in source code from numerous source
FTP archives to nail down which user keeps the dir or file open
***************************
(1) get lsof from vic.cc.purdue.edu under /pub/lsof
(2) write a little script like the one below to do a forced unmount:
#!/bin/ksh
#
# K S McCabe
PATH=$PATH:/usr/sbin:/usr/local/bin
export PATH
if test ! -w /etc/passwd
then
echo 'Please su to root first.\n'
exit 1
fi
echo "Attempting to force an unmount of $1 ..."
if ! type lsof > /dev/null 2>&1
then
echo
echo 'Warning: lsof could not be found'
exit 1
fi
mount | awk '{print $3}' | egrep "^${1}\$" > /dev/null 2>&1 || exit 1
PROCS=`lsof -t $1 2> /dev/null`
if test ! -z "$PROCS"
then
kill $PROCS > /dev/null 2>&1
fi
umount $1 > /dev/null 2>&1 && exit 0
PROCS=`lsof -t $1 2> /dev/null`
if test ! -z "$PROCS"
then
kill -9 $PROCS > /dev/null 2>&1
fi
if umount $1
then
exit 0
fi
echo 'Warning: Unable to unmount filesystem'
exit 1
***************************
http://www.digital.com/info/misc/pub-domain-osf1.txt.html
***************************
A simple utililty for this, uafuser:
can be found via anonymous ftp within:
raven.alaska.edu:/pub/sois/UA_DUtools.tar.Z
***************************
Persons interested in making their own programs may look into:
fuser (system call)
***************************
Another ftp site for the program lsof:
ftp.munnari.oz.au.
***************************
------------------------------------------------------
sherman_at_pet.wustl.edu
Andres Henckens <henckens_at_luc.ac.be>
Lucien_HERCAUD_at_paribas.com (Lucien HERCAUD)
bernards_at_ecn.nl
Harald Lundberg <hl_at_tekla.fi>
Andreas Bungert <Andreas.Bungert_at_e-technik.uni-kl.de>
Keith_MCCABE_at_paribas.com (Keith MCCABE)
Santosh Krishnan x2815 <santosh_at_heplinux1.uta.edu>
"Bernt Christandl" <beb_at_rosat.mpe-garching.mpg.de>
MC.Vialatte_at_custsv.univ-bpclermont.fr
Daniel.Clar_at_supelec.fr (Daniel Clar)
David Warren <warren_at_atmos.washington.edu>
"Jeffrey G. Micono 6533 (Ktech)" <jgmicon_at_sandia.gov>
alan_at_nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.)
kurt carlson <sxkac_at_java.sois.alaska.edu>
Tom Webster <webster_at_tinman.mdc.com>
Anthony Talltree <aad_at_nwnet.net>
Winfried Huber <win_at_tukan.ffb.eunet.de>
"PETER MILNES" <p_milnes_at_BANKS.NTU.EDU.AU>
Jean Schuller <schuller_at_crnal4.in2p3.fr>
--------------------
Thanks to the list, once again.
Brahmaji
nvbr_at_iitk.ernet.in
Received on Sat Dec 21 1996 - 12:55:44 NZDT