Linux (Cent-OS) – CD Drive – Aftermath of “Safely Remove Hardware”

Background

It all started innocently enough.  There are a couple of machines that I wanted to play with.  One has a trial version of MS Windows 7, and believe me it works well and reliably.  And, the other one will not even come up!

I am trying to get my Linux Lab environment back up.  Who isn’t these days?

Well once Cent OS is installed, like every other Windows aficionados I started playing around with the GUI and pressed on a wrong button.

 

Introduction

Which wrong button, you might ask?  Well, the one that states “Safely Remove Drive“.

SafelyRemoveHardware_2

And, so even though my sure and reliable Memorex DVD Double Layer is still attached, it is no longer visible, as confirmed in the screen shot below:

ComputerWindowPostsSafelyRemoveHardware

 

 

So how do we get the CD/DVD Back?

List CD / DVD

I tried listing devices, grepping on cdrom

Command:

ls -la /dev | grep cdrom

Output:

listCDAndDVD

From the output above, our CDs and DVDs are:

a) /dev/cdrom1
b) /dev/sr0

 

 

Eject CD

Ejected the CD, hoping placing a new one in will result in the OS now seeing it.

Syntax:

sudo eject /dev/ [filename]

Command:

sudo eject /dev/cdrom1

 

List Attached Hardware Devices

 

Use dmesg

Use dmesg to list hardware devices that Kernel recognizes.

In this case, list SCSI related info

Syntax:

dmesg | grep -i SCSI

Output:

dmesg--grep--SCSI

 

In this case, list usb related info

Syntax:


dmesg | grep -i usb

Output:

dmesg--usb

 

Hoping to remount it, using mount … But when I tried to do so, did not get anywhere.

Command:

mkdir /mnt/DVD
mount -r -t iso9660 /dev/sr1 /mnt/DVD

Error Message:

mount: special device /dev/sr1 does not exist

 

 

Reset USB Devices

 

The one thing that worked, is the one posted by Tamás Tapsonyi

How do I reset a USB Device without unplugging it in linux
Link

 


# Original by Tamás Tapsonyi
# Slightly modified by Daniel Adeniji
# resetting USB ports
# http://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line/290519#290519
#http://stackoverflow.com/questions/59838/how-to-check-if-a-directory-exists-in-a-shell-script
# if Folder exists /sys/bus/pci/drivers/ehci_hcd/
# resetting USB2 ports
if [ -d "/sys/bus/pci/drivers/ehci_hcd/" ]; then
   echo "Resetting USB2 Ports ..."
   for i in $(ls /sys/bus/pci/drivers/ehci_hcd/|grep🙂
	 do echo $i >/sys/bus/pci/drivers/ehci_hcd/unbind
        echo $i >/sys/bus/pci/drivers/ehci_hcd/bind
    done
    echo "Completed resetting USB2 Ports"
else
   echo "Skipped USB2 Ports"
fi


# if Folder exists /sys/bus/pci/drivers/xhci_hcd/
if [ -d "/sys/bus/pci/drivers/xhci_hcd/" ]; then
   echo "Resetting USB3 Ports ..."
   for i in $(ls /sys/bus/pci/drivers/xhci_hcd/|grep🙂
     do echo $i >/sys/bus/pci/drivers/xhci_hcd/unbind
     echo $i >/sys/bus/pci/drivers/xhci_hcd/bind
   done
    echo "Completed resetting USB3 Ports"
else
   echo "Skipped USB3 Ports"
fi

 

Validation

Our CD/DVD now shows up on the GUI and we can also query /var/log/dmesg and see that it is registered as sr1

Command:

cat /var/log/dmesg | egrep '(CD|DVD)'

 

Output:

var-log-dmesg --egrep cd-dvd

 

Conclusion

Of course, you can always unplug/re-plug in the USB Device or restart the device if it has its own power switch.

 

 

References

References – CD / DVD

 

References – CD/DVD Eject

 

References – dmesg

References – USB Device Reset

 

References – VLC

2 thoughts on “Linux (Cent-OS) – CD Drive – Aftermath of “Safely Remove Hardware”

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s