kernel2.6 で CD-R を使う

kernel2.6 から sg デバイスを使っての ATAPI の SCSI エミュレーションは Linus に嫌われたみたいで、推奨ではなくなった。cdrecord には本家にマージされない独自のパッチが当てられて ATAPI の直接操作ができるようになっている。cdrecord 本家も、Linux はドライバモデルがコロコロ変わってしまうこと、レガシーとはいえ全てのスタンダードでもある SCSI が軽視されている事が気に入らないみたい。そういう部分で、CD-R の利用については、いまのところ中長期的なところが不透明だ。根底には、レガシーな感じのide-scsiドライバのメンテナ不在が長く続いている事、さらにあまりきれいでない実装のままあまり手が入れられていない SCSI まわりが問題のようだ。同じようなアタッチを必要とする MO あたりの扱いがどうなるのか、日本ローカルと言ってもよさそうなデバイスであるので、気になるところだ。
幸いにして、これまで kernel2.6 系で ATAPI CD-R を使って見た事がなかったのだけど、UBCD を使って、手元在庫の HDD を一度チェックしておこうと思い立ったので、急に必要になった。手元の ubuntu は 2.6 kernel が普通であるから。
接続されているドライブはこれ。自分で組み立てたのでドライブアサインは知っているのだけど、一応確認をしておく。

# dmesg | grep ATAPI
hdd: CD-R/RW RW7063A, ATAPI CD/DVD-ROM drive

とりあえず、対応しているのだろうと、いつものようにデバイスリストを出させて見る。

# cdrecord --scanbus
Cdrecord-Clone 2.01a29 (i686-pc-linux-gnu) Copyright (C) 1995-2004 J?uffffrg Schilling
NOTE: this version of cdrecord is an unofficial (modified) release of cdrecord
and thus may have bugs that are not present in the original version.
Please send bug reports and support requests to .
The original author should not be bothered with problems of this version.

cdrecord: No such file or directory. Cannot open '/dev/pg*'. Cannot open SCSI driver.
cdrecord: For possible targets try 'cdrecord -scanbus'. Make sure you are root.
cdrecord: For possible transport specifiers try 'cdrecord dev=help'.
cdrecord:
cdrecord: For more information, install the cdrtools-doc
cdrecord: package and read /usr/share/doc/cdrecord/README.ATAPI.setup .

そう甘くはないか(^^;。
"README.ATAPI.setup"は、Debianでは gz になっているので、指示通りではファイルがないと怒られる。zcat で中身を読む。

# zcat /usr/share/doc/cdrecord/README.ATAPI.setup.gz

それによると、kernel2.6では、

  • バイス名をチェックする
  • /etc/default/cdrecordを変更する
  • 'cdrecord -prcap'を実行
  • cdrecord を suid-root で動作するように変更
  • 動作させるユーザーをcdromグループに登録

という手順が必要らしい。

デフォルトの/etc/default/cdrecordはこうなっている。

#ident @(#)cdrecord.dfl 1.4 02/07/07 Copyr 1998 J. Schilling
#
# This file is /etc/default/cdrecord
# It contains defaults that are used if no command line option
# or environment is present.
#
# The default device, if not specified elswhere
#
CDR_DEVICE=yamaha

#
# The default speed, if not specified elswhere
#
# Note that newer cdrecord versions do not default
# to speed=1. For MMC compliant drives, the default
# is to write at maximum speed, so it in general does
# not make sense to set up a default speed in /etc/default/cdrecord
#

#CDR_SPEED=40

#
# The default FIFO size if, not specified elswhere
#
CDR_FIFOSIZE=4m

#
# The following definitions allow abstract device names.
# They are used if the device name does not contain the
# the characters ',', ':', '/' and '@'
#
# Unless you have a good reason, use speed == -1 and let
# cdrecord use it's intercal drive specific defaults.
#
# drive name device speed fifosize driveropts
#
teac= 1,3,0 -1 -1 ""
panasonic= 1,4,0 -1 -1 ""
plextor= 1,4,0 -1 -1 ""
sanyo= 1,4,0 -1 -1 burnfree
yamaha= 1,5,0 -1 -1 ""
cdrom= 0,6,0 2 1m

んで以下を書き換えと追記。

CDR_DEVICE=RW7063A
RW7063A= /dev/hdd 4 4m ""

"-prcap"って使ったことないけど何なんだろう。man で調べる。

  • prcap

SCSI-3/mmc 互換ドライブでモードページを 0x2A としたときに取得できるドライブの機能を表示する。

機能諸元を出すだけということなら、設定の有効化とかというわけじゃなさそう。ちゃんと設定が反映されているかどうかの確認しろってことかな。

# cdrecord -prcap
Cdrecord-Clone 2.01a29 (i686-pc-linux-gnu) Copyright (C) 1995-2004 J?uffffrg Schilling
NOTE: this version of cdrecord is an unofficial (modified) release of cdrecord
and thus may have bugs that are not present in the original version.
Please send bug reports and support requests to .
The original author should not be bothered with problems of this version.

scsidev: '/dev/hdd'
devname: '/dev/hdd'
scsibus: -2 target: -2 lun: -2
Warning: Open by 'devname' is unintentional and not supported.
Linux sg driver version: 3.5.27
Using libscg version 'ubuntu-0.8ubuntu1'.
cdrecord: Warning: using unofficial version of libscg (ubuntu-0.8ubuntu1 '@(#)scsitransp.c 1.90 04/01/14 Copyright 1988,1995,2000-2004 J. Schilling').
Device type : Removable CD-ROM
Version : 0
Response Format: 1
Vendor_info : ' '
Identifikation : 'CD-R/RW RW7063A '
Revision : '1.90'
Device seems to be: Generic mmc CD-RW.

Drive capabilities, per MMC page 2A:

Does read CD-R media
Does write CD-R media
Does read CD-RW media
Does write CD-RW media
Does not read DVD-ROM media
Does not read DVD-R media
Does not write DVD-R media
Does not read DVD-RAM media
Does not write DVD-RAM media
Does support test writing

Does read Mode 2 Form 1 blocks
Does read Mode 2 Form 2 blocks
Does read digital audio blocks
Does restart non-streamed digital audio reads accurately
Does not support Buffer-Underrun-Free recording
Does read multi-session CDs
Does read fixed-packet CD media using Method 2
Does not read CD bar code
Does read R-W subcode information
Does not return R-W subcode de-interleaved and error-corrected
Does read raw P-W subcode data from lead in
Does return CD media catalog number
Does return CD ISRC information
Does support C2 error pointers
Does not deliver composite A/V data

Does play audio CDs
Number of volume control levels: 15
Does support individual volume control setting for each channel
Does support independent mute setting for each channel
Does not support digital output on port 1
Does support digital output on port 2
Does not send digital data LSB-first
Does not set LRCK high for left-channel data
Does not have valid data on falling edge of clock
Length of data in BCLKs: 16

Loading mechanism type: tray
Does support ejection of CD via START/STOP command
Does not lock media on power up via prevent jumper
Does allow media to be locked in the drive via PREVENT/ALLOW command
Is not currently in a media-locked state
Does not support changing side of disk
Does not have load-empty-slot-in-changer feature
Does not support Individual Disk Present feature

Maximum read speed: 5645 kB/s (CD 32x, DVD 4x)
Current read speed: 5645 kB/s (CD 32x, DVD 4x)
Maximum write speed: 1059 kB/s (CD 6x, DVD 0x)
Current write speed: 1059 kB/s (CD 6x, DVD 0x)
Buffer size in KB: 2048

という感じで認識されていることがわかった。

suid-rootでの実行については、そもそもubuntuがroot不在のシステムとしてデザインされているところからすると、デフォルトでそうなっていそうなものだけど。
# which cdrecord
/usr/bin/cdrecord
# ls -al /usr/bin/cdrecord

  • rwxr-xr-x 1 root root 133 2004-09-29 08:37 /usr/bin/cdrecord

プログラムレベルでそうなっているのかな...
とりあえず、一般ユーザーでも"-prcap"コマンドの動作は可能のようだ。デバイスを開くことはできているらしい。であれば、"dpkg-reconfigure cdrecord" は不要ということだ。
cdromグループへの登録はどうなっているのか調べる。

# grep cdrom /etc/group
cdrom:x:24:kinneko,hal

これも自動でやってくれている。
さて、これで準備は出来た。

今回は iso イメージを焼くだけなので cdrecord コマンドだけ動けば問題はないのだけど、なにか GUI があったらいいと思うのは人情だ。KNOPPIX の時には、K3B を使っていたのだけど、GNOME メインの ubuntu で使うのはちょっとよろしくない。なぜなら、"k3b k3blibs kdebase-bin kdelibs-bin kdelibs-data kdelibs4 libarts1 libartsc0 libflac++2c102 libnetpbm10 libpcre3 libqt3c102-mt menu menu-xdg netpbm" と、大量のパッケージを入れなくてはならないからだ。
ちょっと調べてみると、ノーチラスには GUI 統合された nautilus-cd-burner という機能が備わっているらしい。
GUI から右クリックで「ディスクへ書き込む」を選ぶと、それらしいウインドウが出てくるが、ためしに焼き終わっている CD-R を入れてみると、焼けないはずなのに完了などと間抜けたメッセージが出る。やっぱ別パッケージだったかな。

# apt-cache search nautilus | grep cd
nautilus-cd-burner - CD Burning front-end for Nautilus
# COLUMNS=120 dpkg -l | grep nautilus-cd-burner
ii nautilus-cd-burner 2.8.3-0ubuntu3 CD Burning front-end for Nautilus

入ってんじゃん。
生ディスクを入れて、再度やってみる。
を、生ディスク用の窓が開いたぞ。OSXみたいで、KDEより便利だぞ。でも、ここにはisoを指定するところはないな。とりあえずこれは閉じて、右クリックから焼く。なんか焼いているみたいね。お、出てきた。
というわけで完了。焼いたCDはちゃんと使えています。
ATAPIでダイレクトになったおかげで、デバイスの扱いがいろいろと楽になってよかったです。