[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Mounting a DVD (busy message)



Quoting Thomas Schmitt (scdbackup@gmx.net):
> [I wrote:]
> > $ mount /media/cdrom0
> > mount: block device /dev/sr0 is write-protected, mounting read-only
> > mount: /dev/sr0 already mounted or /media/cdrom0 busy
> > $ mount /media/cdrom0
> > mount: block device /dev/sr0 is write-protected, mounting read-only
> 
> It looks like some process is opening /dev/sr0 (the link target
> of /dev/cdrom0) with flag O_EXCL for a short time.
> 
> I can provoke the message by running in one terminal
> 
>   cdrskin dev=/dev/sr0 grab_drive_and_wait=60
> 
> and then trying to mount /dev/sr0 in another terminal.
> After the cdrskin run has ended, the next mount attempt
> succeeds.
> 
> > I can live with this, but I'm curious to know why.
> 
> btrace(8) might tell something. As superuser in a terminal
> 
>   btrace /dev/sr0 2>&1 | tee -i /tmp/btrace.log
> 
> The names of acting processes are told in []-brackets.
> E.g.
>   11,0    1       16    23.917345909 13645  Q   R 4096 + 8 [systemd-udevd]
>   11,0    4       11   106.816656855 13652  G   N [cdrskin]
> 
> When the interesting event has happened, end the btrace run
> by Ctrl+C and read file /tmp/btrace.log from its end.
> The numbers "23.917345909" and "106.816656855" are seconds
> since btrace start. So you can easily judge which lines
> are too old to be related to your invisible drive groper.

Hi, I forgot about this thread and was reminded by your recent post
concerning btrace. Thanks for the command.

I ran   btrace /dev/sr0 2>&1 | tee -i /tmp/btrace.log
and then inserted a CD and tried to mount it. To reduce the amount of
output I then pressed ^C after about 2 seconds.
There are 113 lines of output. A list of unique process names
extracted (in alphabetical order) from the brackets is:

[0] [2] [ata_id] [cdrom_id] [kworker/0:2] [kworker/1:1] [mount]

I then repeated this, but tried the mount command twice, which works
of course on the second time. Now I got 652 lines of output and the
new list of process names is:

[0] [2] [ata_id] [blkid] [cdrom_id] [kworker/0:2] [kworker/1:1]
[mount] [(null)] [udisks-part-id]

(Note that the null ones all came within the first 54 lines.)

I thought for a while, and then remembered that if you look at
/dev/disk/by-label you can see a CD before it's ever mounted.
So I tried repeating the experiment without trying to mount the CD.

The first time, I gave up waiting on btrace before anything appeared
in /dev/disk the first time (half a minute or more). So I had another
go, and this time btrace spat out 368 lines almost immediately; the
CD label appeared too. A third try, was like the first: no lines
output and no appearance in /dev/disk/by-label (several minutes).

So here's my guess: as soon as I try to mount the CD, a process not
under my control pops up (probably it's [cdrom_id]) and fills in
/dev/disk/by-label. However, it can't be bothered to do that until I
try to mount the CD. (Perhaps it actually did when btrace gave
368 lines.)

So my new question is: why doesn't the process that fills
/dev/disk/by-label run when I insert the CD, but waits instead for me
to try to access it?

Cheers,
David.


Reply to: