Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I list all the installed optical drivers with udev or any other core-based tool (perl is also very good) ?

P.S.: I know about the wodim --devices command, but it's an undesirable dependence.

share|improve this question

migrated from serverfault.com Feb 25 '13 at 7:49

This question came from our site for system and network administrators.

If you like Perl, then this example code found in CPAN could do the trick. It also have low dependencies. The library you need is Device-Cdio.

use strict;

    chdir 'example' if -d 'example';
    use lib '../lib';
    eval "use blib";  # if we fail keep going - maybe we have installed Cdio

use Device::Cdio;
use Device::Cdio::Device;
use Device::Cdio::Track;
use vars qw($0 $program $pause %opts);

sub print_drive_class($$$) {
    my ($msg, $bitmask, $any) = @_;
    my @cd_drives = Device::Cdio::get_devices_with_cap($bitmask, $any);
    print "$msg...\n";
    foreach my $drive (@cd_drives) {
    print "Drive $drive\n";
    print "-----\n";
my @cd_drives = Device::Cdio::get_devices($perlcdio::DRIVER_DEVICE);
foreach my $drive (@cd_drives) {
    print "Drive $drive\n";
print "-----\n";
print_drive_class("All CD-ROM drives (again)", $perlcdio::FS_MATCH_ALL, 0);
share|improve this answer
dmesg | awk '/CD-ROM/ && /Attached/{print "/dev/"$NF}' – Rahul Patil Feb 25 '13 at 9:22
@RahulPatil is this supposed to work ? Because it doesn't in my system. – drcelus Feb 25 '13 at 10:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.