dave wrote: >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 > > Yes, that worked for me too. chris@p450:~> lsof /dev/cdrecorder There's nothing in cdrecorder. Next, I insert a music CD, open xmms, choose /dev/cdrecorder for the file to load, and play it with xmms. chris@p450:~> lsof /dev/cdrecorder COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME xmms 18693 chris 11r BLK 11,0 212604 /dev/sr0 xmms 18694 chris 11r BLK 11,0 212604 /dev/sr0 xmms 18695 chris 11r BLK 11,0 212604 /dev/sr0 xmms 18696 chris 11r BLK 11,0 212604 /dev/sr0 xmms 18697 chris 11r BLK 11,0 212604 /dev/sr0 xmms 18699 chris 11r BLK 11,0 212604 /dev/sr0 lsof says xmms is accessing cdrecorder, which is playing a music CD. Next, I stopped playing the CD but kept xmms open with /dev/cdrecorder loaded. chris@p450:~> lsof /dev/cdrecorder chris@p450:~> xmms is not accessing (playing) cdrecorder even though /dev/cdrecorder is loaded in xmms. Next, I started playing the music CD again. chris@p450:~> lsof /media/cdrecorder/ It is not mounted at the mount point in /etc/fstab. chris@p450:~> lsof /dev/cdrecorder COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME xmms 18693 chris 11r BLK 11,0 212604 /dev/sr0 xmms 18694 chris 11r BLK 11,0 212604 /dev/sr0 xmms 18695 chris 11r BLK 11,0 212604 /dev/sr0 xmms 18696 chris 11r BLK 11,0 212604 /dev/sr0 xmms 18697 chris 11r BLK 11,0 212604 /dev/sr0 xmms 18727 chris 11r BLK 11,0 212604 /dev/sr0 Same as previous results when playing a music CD. chris@p450:~> fuser -m /media/cdrecorder/ /media/cdrecorder/: 1m 384m 387m 530m 568m 616m 657m 853m 876m 891m 914m 950m 959m 960m 961m 962m 963m 964m 966m 984m 990m 991m 992m 993m 994m 995m 996m 1020 1020r 1020c 1020e 1063 1063r 1063c 1063e 1066 1066r 1066c 1066e 1069 1069r 1069c 1069e 1071 1071r 1071c 1071e 1082 1082r 1082c 1082e 1086 1086r 1086c 1086e 1087 1087r 1087c 1087e 1089 1089r 1089c 1089e 1090 1090r 1090c 1090e 1092 1092r 1092c 1092e 1096 1096r 1096c 1096e 1099 1099r 1099c 1099e 1104 1104r 1104c 1104e 1126 1126r 1126c 1126e 1150 1150r 1150c 1150e 1297 1297r 1297c 1297e 1314 1314r 1314c 1314e 1315 1315r 1315c 1315e 1316 1316r 1316c 1316e 1318 1318r 1318c 1318e 1347 1347r 1347c 1347e 1348 1348r 1348c 1348e 1350 1350r 1350c 1350e 1401 1401r 1401c 1401e 1403m 1407 1407r 1407c 1407e 1408 1408r 1408c 1408e 18232 18232r 18232c 18232e 18234r 18234e 18493 18493r 18493c 18493e 18495r 18495c 18495e 18577 18577r 18577c 18577e 18610m 18693 18693r 18693c 18693e 18694 18694r 18694c 18694e 18695 18695r 18695c 18695e 18696 18696r 18696c 18696e 18697 18697r 18697c 18697e 18727 18727r 18727c 18727e 18732r 18732e Ignor this. Too much information. chris@p450:~> fuser -m /dev/cdrecorder chris@p450:~> That device is not mounted. So, in conclusion, lsof can detect unmounted music CDs being played. fuser only detects mounted CDs. > >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 > > > _______________________________________________ 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