LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 02-06-2012, 03:23 AM   #1
VinRoh
LQ Newbie
 
Registered: Feb 2012
Posts: 6

Rep: Reputation: Disabled
Smile Possible ways to get the media type of CD drive


Hi,
I am new to linux world and facing some issues using SUse Enterprize 32 bit OS. I am looking for commands in linux which can give the media type of the CDrom drive. For instance if I have CD/DVD in the drive , I would like to know if it has No/Wrong Media, cd r/cd rw, Blank Cd etc.

I tried using :

cdrecord -prcap dev=/dev/cdrom 2>/dev/null | grep 'Current:'
from the link:

http://www.linuxquestions.org/questi...writer-712856/

But it just gives reand and write speeds for Cd and DVD.

Also , to let you know, I am using

cdrecord --version

Cdrecord-yelling-line-to-tell-frontends-to-use-it-like-version 2.01.01a03-dvd
Wodim 1.1.8
Copyright (C) 2006 Cdrkit suite contributors
Based on works from Joerg Schilling, Copyright (C) 1995-2006, J. Schilling

Please let me know if it is possible to get the current mediatype details . Thanks in advance for all the suggestions.
 
Old 02-06-2012, 05:59 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
prcap only prints drive capabilities, nothing about the current media type. Use '-minfo' or '-media-info' instead.
 
Old 02-07-2012, 03:00 AM   #3
VinRoh
LQ Newbie
 
Registered: Feb 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks for your reply.
I used the following command for the DVD-RW and it gives the media details:

dvd+rw-mediainfo /dev/cdrom

I am still looking for commands which gives media details when CD is used and not DVD.
The above command is not supported for a CD.

Also, can you suggest me command to find if the cd/dvd has corrupted media.

Thanks once again.
 
Old 02-07-2012, 03:38 AM   #4
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Here's a piece from one of my old scripts, maybe it'll help:

Code:
# more readability
source=$1
destin=$2

# get disk type and minimum writing speed
if cdrecord -prcap dev=$destin 1>/dev/null 2>&1
then
  if cdrecord -prcap dev=$destin 2>/dev/null | grep 'Current:' | grep CD
  then
    # we have a CD
    type=cd
    # get writing speed
    speed=$(cdrecord -prcap dev=$destin 2>/dev/null | grep 'Write speed' | tail -n 1 | sed 's/x/ /g' | awk '{ print $9 }')
  elif cdrecord -prcap dev=$destin 2>/dev/null | grep 'Current:' | grep DVD
  then
    # we have a DVD
    type=dvd
    # get writing speed
    speed=$(cdrecord -prcap dev=$destin 2>/dev/null | grep 'Write speed' | tail -n 1 | sed 's/x/ /g' | awk '{ print $12 }')
  else
    # cannot determine disk type
    echo 'Error: cannot determine disk type, please insert disk !'
    # fail
    exit 1
  fi
else
  # cannot determine disk type
  echo 'Error: cannot determine disk type, please insert disk !'
  # fail
  exit 1
fi
 
Old 02-13-2012, 05:52 AM   #5
VinRoh
LQ Newbie
 
Registered: Feb 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Smile

Thanks for the reply.
This helped me to understand better .
Any idea on DVD RAM media type and ways to know if a cd-R/cd-rw is blank or prewritten.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
way to get the media type of CD drive VinRoh Linux - Newbie 1 02-06-2012 06:33 AM
what are the ways i can back up my data in external media kumars.nitin123 Linux - Desktop 3 11-06-2009 01:05 AM
Help ME! RED HAT ENTERPRISE LINUX 5 DESKTOP DVD- Ways in which i can use this media? redhat5 Linux - Newbie 9 08-10-2009 02:46 AM
LXer: 10 ways to reduce removable media headaches in Linux LXer Syndicated Linux News 1 12-04-2008 01:58 PM
Moving hard drive from one system type to another type SlowCoder Linux - Newbie 7 11-26-2007 10:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 05:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration