[ccoss] unmount cdrom, device is busy, what is using it, using fuser as asolution

Have you ever tried to unmount the CD-ROM, and it says the device is 
busy. This is a solution to find out what process is using the CD-ROM.

chris@p450:~> cat /etc/fstab
.....................
/dev/cdrecorder      /media/cdrecorder    auto       
ro,noauto,user,exec   0 0
.....................
chris@p450:~> ls -l /dev/cdrecorder
lrwxrwxrwx    1 root     root            3 2003-10-13 21:35 
/dev/cdrecorder -> sr0
chris@p450:~> fuser -m /dev/sr0
/dev/sr0:             1247
chris@p450:~> fuser -m /dev/cdrecorder
/dev/cdrecorder:      1247

/dev/cdrecorder shows the same results as /dev/sr0.

chris@p450:~> ps 1247
  PID TTY      STAT   TIME COMMAND
 1247 ?        S      2:35 kdeinit: konqueror --silent
chris@p450:~>

Ah, so it's konqueror that is accessing cdrecorder!

.............tried changing to different directory in konqueror (file 
manager)......................
chris@p450:~> fuser -m /dev/cdrecorder
/dev/cdrecorder:      1247

konqueror is still accessing cdrecorder.

............tried to close konqueror window that was viewing my 
files...........
chris@p450:~> fuser -m /dev/cdrecorder
/dev/cdrecorder:      1247
..........tried to close all konqueror windows, including Web browsing 
windows..........
chris@p450:~> fuser -m /dev/cdrecorder
chris@p450:~>
chris@p450:~> umount /dev/cdrecorder
chris@p450:~>

Success!

Hmm, what caused this?

...............mounted cdrecorder with right-click on KDE desktop icon 
and click on "Mount" option...........
p450:/home/chris # fuser -m /dev/cdrecorder
p450:/home/chris #

Nothing accessing cdrecorder yet!

.............opened konqueror............
p450:/home/chris # fuser -m /dev/cdrecorder
p450:/home/chris #
...........show navigation panel in konqueror (two-pane view)............
chris@p450:~> fuser -m /dev/cdrecorder
chris@p450:~>

Nothing accessing cdrecorder yet!

...........clicked on "file:/media/cdrecorder" in konqueror..........
chris@p450:~> fuser -m /dev/cdrecorder
chris@p450:~>
...........clicked on "file:/media/cdrecorder/IDE" in konqueror..........
chris@p450:~> fuser -m /dev/cdrecorder
chris@p450:~>

Nothing accessing cdrecorder yet!

...........clicked on "file:/media/cdrecorder/IDE/Readme.txt" in 
konqueror..........
chris@p450:~> fuser -m /dev/cdrecorder
chris@p450:~>
...............unmounted cdrecorder with right-click on KDE desktop icon 
and click on "Unmount" option...........

Nothing accessing cdrecorder yet, so unmounting was successful.

...............mounted cdrecorder with right-click on KDE desktop icon 
and click on "Mount" option...........

Hmm, still didn't find what caused this?

chris@p450:~> cd /media/cdrecorder/IDE/
chris@p450:/media/cdrecorder/IDE> fuser -m /dev/cdrecorder
/dev/cdrecorder:     18082c
chris@p450:/media/cdrecorder/IDE>

Ah, so this is one way to make cdrecorder busy! Let's make the 
cdrecorder not busy.

 In the default display mode, each file name is followed by a letter 
denoting the type of access:

              c      current directory.

Hence the "c" after the 18082.

chris@p450:/media/cdrecorder/IDE> cd
chris@p450:~> fuser -m /dev/cdrecorder
chris@p450:~>

Sucess! The cdrecorder is not busy anymore.

...............unmounted cdrecorder with right-click on KDE desktop icon 
and click on "Unmount" option...........

Nothing accessing cdrecorder yet, so unmounting was successful.

...............mounted cdrecorder with right-click on KDE desktop icon 
and click on "Mount" option...........

chris@p450:~> cd /media/cdrecorder/IDE/
chris@p450:/media/cdrecorder/IDE> fuser -m /dev/cdrecorder
/dev/cdrecorder:     18082c
chris@p450:/media/cdrecorder/IDE>

cdrecorder is busy again.

chris@p450:/media/cdrecorder/IDE> fuser -k /dev/cdrecorder

-k     Kill processes accessing the file.

chris@p450:/media/cdrecorder/IDE> fuser -m /dev/cdrecorder
/dev/cdrecorder:     18082c
chris@p450:/media/cdrecorder/IDE>

Still there. This didn't kill the konsole window I was in.

The fuser man page says a fuser  process  never  kills itself, so that's 
why the -k option didn't work.

............using another konsole subshell (#3 instead of 
#4).................
chris@p450:/mnt/mandrake/home/chris_temp> fuser -k /dev/cdrecorder
chris@p450:/mnt/mandrake/home/chris_temp> fuser -m /dev/cdrecorder
/dev/cdrecorder:     18082c
chris@p450:/mnt/mandrake/home/chris_temp>

Still there.

chris@p450:/mnt/mandrake/home/chris_temp> ps 18082
  PID TTY      STAT   TIME COMMAND
18082 pts/0    S      0:00 /bin/bash
chris@p450:/mnt/mandrake/home/chris_temp>

...........opened a second konsole window, and using this one.......

chris@p450:~> cd /media/cdrecorder/IDE
chris@p450:/media/cdrecorder/IDE>

............back to first konsole window..........

chris@p450:/media/cdrecorder/IDE> fuser -m /dev/cdrecorder
/dev/cdrecorder:     18082c 18234c

Both the first and second konsoles are using cdrecorder.

............in first konsole window.........

chris@p450:/media/cdrecorder> cd
chris@p450:~> fuser -m /dev/cdrecorder
/dev/cdrecorder:     18234c
chris@p450:~> fuser -k /dev/cdrecorder
chris@p450:~> fuser -m /dev/cdrecorder
/dev/cdrecorder:     18234c
chris@p450:~>

fuser didn't kill the second konsole window.

............back to second konsole window, which was causing cdrecord to 
be busy..........

chris@p450:/media/cdrecorder/IDE> cd
chris@p450:~>

............in first konsole window.........

chris@p450:~> fuser -m /dev/cdrecorder
chris@p450:~>

cdrecorder is not busy because of manually moving out of cdrecorder 
directory in second konsole window.

Christopher Paulin


_______________________________________________
CCOSS mailing list
ccoss@xxxxxxxxxxxxx
CCOSS mailing list page: http://www.freelists.org/cgi-bin/list?list_id=3594
CCOSS Web page: http://www.ccoss.org

Other related posts: