Ubuntu – How to check if a cdrom is in the tray remotely (via ssh)

cdcd-drivedevicesmountmountpoint

I have a server running Ubuntu 10.04 (it's on the other side of the world and I haven't built up the wherewithal to upgrade it remotely yet) and I have been told that there is a CD in one of it's two CD drives. I want to rip an image of the cd and then download it to my local computer (I don't need help with either of these steps).

However, I cannot seem to confirm whether or not there actually is a CD in the drive as I was told. It did not automatically mount anywhere (which I'm thinking might just be a result of it being a headless server not running X, nautilus, or any of the other nice user friendly things).

There are two CD drives connected via SCSI:

austin@austinvpn:/proc/scsi$ cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: WDC WD400EB-75CP Rev: 06.0
  Type:   Direct-Access                    ANSI  SCSI revision: 05
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: Lite-On  Model: LTN486S 48x Max  Rev: YDS6
  Type:   CD-ROM                           ANSI  SCSI revision: 05
Host: scsi1 Channel: 00 Id: 01 Lun: 00
  Vendor: SAMSUNG  Model: CD-R/RW SW-248F  Rev: R602
  Type:   CD-ROM                           ANSI  SCSI revision: 05

However when I try mounting either of these devices (and every other device that could possibly be the cd-drive), it says no medium found:

austin@austinvpn:/proc/scsi$ sudo mount -t iso9660 /dev/scd1 /cdrom
mount: no medium found on /dev/sr1
austin@austinvpn:/proc/scsi$ sudo mount -t iso9660 /dev/scd0 /cdrom
mount: no medium found on /dev/sr0
austin@austinvpn:/proc/scsi$ sudo mount -t iso9660 /dev/cdrom /cdrom
mount: no medium found on /dev/sr1
austin@austinvpn:/proc/scsi$ sudo mount -t iso9660 /dev/cdrom1 /cdrom
mount: no medium found on /dev/sr0
austin@austinvpn:/proc/scsi$ sudo mount -t iso9660 /dev/cdrw /cdrom
mount: no medium found on /dev/sr1

Here are the contents of my /dev folder:

austin@austinvpn:/proc/scsi$ ls /dev
agpgart          loop6               ram6      tty10  tty38  tty8
austinvpn        loop7               ram7      tty11  tty39  tty9
block            lp0                 ram8      tty12  tty4   ttyS0
bsg              mapper              ram9      tty13  tty40  ttyS1
btrfs-control    mcelog              random    tty14  tty41  ttyS2
bus              mem                 rfkill    tty15  tty42  ttyS3
cdrom            net                 root      tty16  tty43  urandom
cdrom1           network_latency     rtc       tty17  tty44  usbmon0
cdrw             network_throughput  rtc0      tty18  tty45  usbmon1
char             null                scd0      tty19  tty46  usbmon2
console          oldmem              scd1      tty2   tty47  usbmon3
core             parport0            sda       tty20  tty48  usbmon4
cpu_dma_latency  pktcdvd             sda1      tty21  tty49  vcs
disk             port                sda2      tty22  tty5   vcs1
dri              ppp                 sda5      tty23  tty50  vcs2
ecryptfs         psaux               sg0       tty24  tty51  vcs3
fb0              ptmx                sg1       tty25  tty52  vcs4
fd               pts                 sg2       tty26  tty53  vcs5
full             ram0                shm       tty27  tty54  vcs6
fuse             ram1                snapshot  tty28  tty55  vcs7
hpet             ram10               snd       tty29  tty56  vcsa
input            ram11               sndstat   tty3   tty57  vcsa1
kmsg             ram12               sr0       tty30  tty58  vcsa2
log              ram13               sr1       tty31  tty59  vcsa3
loop0            ram14               stderr    tty32  tty6   vcsa4
loop1            ram15               stdin     tty33  tty60  vcsa5
loop2            ram2                stdout    tty34  tty61  vcsa6
loop3            ram3                tty       tty35  tty62  vcsa7
loop4            ram4                tty0      tty36  tty63  vga_arbiter
loop5            ram5                tty1      tty37  tty7   zero

And here is my fstab file:

austin@austinvpn:/proc/scsi$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
/dev/mapper/austinvpn-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=ed5520ae-c690-4ce6-881e-3598f299be06 /boot           ext2    defaults        0       2
/dev/mapper/austinvpn-swap_1 none            swap    sw              0       0

Am I missing something/doing something wrong, or is there just no CD in the drive or is the drive possibly broken? Is there any nice command to list devices with mountable media?

Thanks in advance for any help!

Best Answer

The output isn't quite as pretty as yours but it doesn't require you to install anything:

$ sudo lshw | awk '/\*-cd/,/con/' | sed -e 's/^[ \t]*//'

*-cdrom                   
description: DVD-RAM writer
product: DVD RW AD-7240S
vendor: Optiarc
physical id: 0.0.0
bus info: scsi@8:0.0.0
logical name: /dev/sr0
version: 1.00
capabilities: removable audio cd-r cd-rw dvd dvd-r dvd-ram
configuration: ansiversion=5 status=nodisc
*-cdrom
description: DVD-RAM writer
physical id: 0.0.0
bus info: scsi@9:0.0.0
logical name: /dev/cdrom
logical name: /dev/cdrw
logical name: /dev/dvd
logical name: /dev/dvdrw
logical name: /dev/sr1
logical name: /media/X3_Linux
capabilities: audio cd-r cd-rw dvd dvd-r dvd-ram
configuration: mount.fstype=iso9660 mount.options=ro,nosuid,nodev,relatime,uid=1000,gid=1000,iocharset=utf8,mode=0400,dmode=0500 state=mounted status=ready
Related Question