[ccoss] Re: unmount cdrom, device is busy, what is using it, usingfuser as a solution

  • From: dave <dave@xxxxxxxxxx>
  • To: ccoss@xxxxxxxxxxxxx
  • Date: Fri, 28 Nov 2003 12:58:56 -0500

you can also do this with the lsof (list open files) command:

dave@insp5100:~$ lsof /cdrom
dave@insp5100:~$ cd /cdrom
dave@insp5100:/cdrom$ lsof /cdrom
COMMAND PID USER   FD   TYPE DEVICE SIZE  NODE NAME
bash    912 dave  cwd    DIR   11,0 2048 59392 /cdrom
lsof    917 dave  cwd    DIR   11,0 2048 59392 /cdrom
lsof    918 dave  cwd    DIR   11,0 2048 59392 /cdrom
dave@insp5100:/cdrom$ umount /cdrom
umount: /cdrom: device is busy
umount: /cdrom: device is busy
dave@insp5100:/cdrom$ cd
dave@insp5100:~$ lsof /cdrom
dave@insp5100:~$ umount /cdrom
dave@insp5100:~$


1st line shows nothing accessing /cdrom
2nd line show me cd'ing into /cdrom
3rd shows that I'm now sitting in that dir
8th shows an attempted umount, unsuccessful
9th shows me cd'ing out
10th shows nothing accessing /cdrom now
11th shows that the umount is now successful.

here's another example that shows xmms playing an mp3 from a mounted cd....

dave@insp5100:~$ lsof /cdrom
COMMAND PID USER   FD   TYPE DEVICE    SIZE  NODE NAME
xmms    963 dave   10r   REG   11,0 6959104 79562 /cdrom/Santana-Love Of 
My Life (feat Dave Matthews)-Supernatural.mp3
xmms    964 dave   10r   REG   11,0 6959104 79562 /cdrom/Santana-Love Of 
My Life (feat Dave Matthews)-Supernatural.mp3
xmms    965 dave   10r   REG   11,0 6959104 79562 /cdrom/Santana-Love Of 
My Life (feat Dave Matthews)-Supernatural.mp3
xmms    968 dave   10r   REG   11,0 6959104 79562 /cdrom/Santana-Love Of 
My Life (feat Dave Matthews)-Supernatural.mp3
xmms    977 dave   10r   REG   11,0 6959104 79562 /cdrom/Santana-Love Of 
My Life (feat Dave Matthews)-Supernatural.mp3
xmms    978 dave   10r   REG   11,0 6959104 79562 /cdrom/Santana-Love Of 
My Life (feat Dave Matthews)-Supernatural.mp3


dave



Christopher Paulin wrote:
> 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: //www.freelists.org/cgi-bin/list?list_id=3594
> CCOSS Web page: http://www.ccoss.org

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

Other related posts:

  • » [ccoss] Re: unmount cdrom, device is busy, what is using it, usingfuser as a solution