Linux下使用刻錄機(jī)的具體方法
1.1 先決條件
a. Linux內(nèi)核 >=V2.4.0-test8
b. cdrecord V1.10a4 (http://www.fokus.gmd.de/research/cc/glone/employees/joerg.schilling/private/cdrecord.html)
c. usbmgr V0.3.5 (http://www.wonder.ne.jp/~shuu/usbmgr/)
d. modutils-2.3.15 或者更新的版本 (非常重要!)
e. 裝有HP CD-Writer Plus 8210e刻錄機(jī)的電腦
1.2 第一步
請(qǐng)先查看你的BIOS里面的設(shè)置,看是否已經(jīng)允許使用usb接口。如果你用同一臺(tái)電腦,并且在MS Win下面可以正常得使用這個(gè)刻錄機(jī),
那你可以省去檢查BIOS這一步。
1.3 給Linux做準(zhǔn)備工作
你必須對(duì)編譯和升級(jí)內(nèi)核100%的熟悉。如果你對(duì)此是個(gè)新手的話,那你要當(dāng)心。因?yàn)槟憧赡茉斐膳f內(nèi)核的丟失或者不能引導(dǎo)等問題。
我建議使用模塊化的內(nèi)核配置,因此你要對(duì)"insmod","lsmod","modprobe","depmod"等命令非常的熟悉。
1.3.1 menuconfig
下面的是我配置內(nèi)核時(shí)所選的選項(xiàng):
Code maturity level options -->-
[*] Prompt for development and/or incomplete code/drivers
Loadable module support --->
[*] Enable loadable module support
[*] Set version information on all module symbols
[*] Kernel module loader
Block devices --->
Loopback device support
SCSI support --->
SCSI support
SCSI disk support
SCSI CD-ROM support
[*] Enable vendor-specific extensions (for SCSI CDROM)
(2) Maximum number of CDROM devices that can be loaded as modules
SCSI generic support
[*] Enable extra checks in new queueing code
[*] Verbose SCSI error reporting (kernel size +=12K)
[*] SCSI logging facility
SCSI low-level drivers --->
deactivate any SCSI-Device you don have!
File systems --->
ISO 9660 CDROM file system support
[*] Microsoft Joliet CDROM extensions
[*] /proc file system support
UDF file system support (read only)
USB support --->
Support for USB
[*] USB verbose debug messages
[*] Preliminary USB device filesystem
[*] Enforce USB bandwidth allocation (EXPERIMENTAL)
--- USB Controllers
UHCI (Intel PIIX4, VIA, ...) support
<> OHCI (Compaq, iMacs, OPTi, SiS, ALi, ...) support
Select the correct USB Controller for your System!!!!!!
USB Mass Storage support
這些就是所以和配置使用我的HP CD-Writer Plus 8210e刻錄機(jī)有關(guān)的選項(xiàng)。我用的是V2.4.0-test8的內(nèi)核。
編譯的時(shí)候會(huì)有大量的編譯調(diào)試信息,如果正常的話他們可以不管他們,但如果發(fā)生問題的時(shí)候,他們可以幫助你查找的原因。
再次警告:如果你對(duì)配置和安裝新內(nèi)核不是很熟悉的話建議要當(dāng)心,這樣是有一定風(fēng)險(xiǎn)的。
1.3.2安裝模塊
當(dāng)你的新內(nèi)核和模塊編譯完成后,你會(huì)在modules目錄下面發(fā)現(xiàn)下面這些模塊文件:
cd /lib/modules/2.4.0-test8
cd kernel
ls fs/isofs
isofs.o
ls drivers/cdrom
cdrom.o
ls drivers/scsi
scsi_mod.o sd.o sg.o sr_mod.o
ls drivers/usb
storage usb-uhci.o usbcore.o
ls drivers/usb/storage
usb-storage.o
重新啟動(dòng)!
1.4 下面的步驟
下載usbmgr包,解壓縮并閱讀README文件。在解壓后的目錄里用make進(jìn)行編譯。然后make install?,F(xiàn)在我們配置usbmgr的
配置文件usbmgr.conf,它放在/etc/usbmgr目錄下。編輯這個(gè)文件,進(jìn)行下面幾步:
a) 去掉在HOST CONTROLLER這節(jié)里面的某個(gè)host選項(xiàng)前面的注釋符"#".在我的計(jì)算機(jī)上是這樣設(shè)置的: host usb-uhci
b) 把下面三行加到STORAGE一節(jié)里的vendor 0x3f0 product 0x107這個(gè)模塊的最后。
scsi_mod, sr_mod, usb-storage
現(xiàn)在你要運(yùn)行"update_usbdb"這個(gè)命令:update_usedb usbmgr.conf
接下去運(yùn)行"usbmgr"命令。這個(gè)命令在后臺(tái)執(zhí)行,所以你看不到任何結(jié)果輸出。但是你可以通過查看messages文件來(lái)查看運(yùn)行情況:
tail -n50 /var/log/messages
#p#
正常的輸出應(yīng)該像這樣的:
Sep 15 12:55:28 usbmgr[326]: start 0.3.5
Sep 15 12:55:28 usbmgr[328]: open error "/etc/usbmgr/preload.conf"
Sep 15 12:55:28 kernel: usb.c: registered new driver usbdevfs
Sep 15 12:55:28 kernel: usb.c: registered new driver hub
Sep 15 12:55:28 kernel: usb-uhci.c: $Revision: 1.237 $ time 11:07:02 Sep 10 2000
Sep 15 12:55:28 kernel: usb-uhci.c: High bandwidth mode enabled
Sep 15 12:55:28 kernel: usb-uhci.c: USB UHCI at I/O 0xfce0, IRQ 10
Sep 15 12:55:28 kernel: usb-uhci.c: Detected 2 ports
Sep 15 12:55:28 kernel: usb.c: new USB bus registered, assigned bus number 1
Sep 15 12:55:28 kernel: usb.c: USB new device connect, assigned device number 1
Sep 15 12:55:28 kernel: usb.c: kmalloc IF c2e1f760, numif 1
Sep 15 12:55:28 kernel: usb.c: new device strings: Mfr=0, Product=2, SerialNumber=1
Sep 15 12:55:28 kernel: usb.c: USB device number 1 default language ID 0x0
Sep 15 12:55:28 kernel: Product: USB UHCI Root Hub
Sep 15 12:55:28 kernel: SerialNumber: fce0
Sep 15 12:55:28 kernel: hub.c: USB hub found
Sep 15 12:55:28 kernel: hub.c: 2 ports detected
Sep 15 12:55:28 kernel: hub.c: ganged power switching
Sep 15 12:55:28 kernel: hub.c: standalone hub
Sep 15 12:55:28 kernel: hub.c: global over-current protection
Sep 15 12:55:28 kernel: hub.c: power on to power good time: 2ms
Sep 15 12:55:28 kernel: hub.c: hub controller current requirement: 0mA
Sep 15 12:55:28 kernel: hub.c: port 1 is removable
Sep 15 12:55:28 kernel: hub.c: port 2 is removable
Sep 15 12:55:28 kernel: hub.c: local power source is good
Sep 15 12:55:28 kernel: hub.c: no over-current condition exists
Sep 15 12:55:28 kernel: hub.c: enabling power on all ports
Sep 15 12:55:28 kernel: usb.c: hub driver claimed interface c2e1f760
Sep 15 12:55:28 kernel: usb.c: kusbd: /sbin/hotplug add 1
Sep 15 12:55:28 kernel: usb.c: kusbd policy returned 0x0
Sep 15 12:55:28 usbmgr[328]: "usb-uhci" was loaded
Sep 15 12:55:28 usbmgr[332]: mount /proc/bus/usb
Sep 15 12:55:28 usbmgr[328]: USB device is matched the configuration
Sep 15 12:55:28 usbmgr[328]: "none" isn loaded
這里還有兩個(gè)文件需要查看:
a) cat /proc/interrupts
CPU0
0: 991954 XT-PIC timer
1: 19880 XT-PIC keyboard
2: 0 XT-PIC cascade
8: 2 XT-PIC rtc
9: 14 XT-PIC Cirrus Logic PD 6832, Cirrus Logic PD 6832 (#2)
10: 42 XT-PIC usb-uhci
12: 243881 XT-PIC PS/2 Mouse
13: 0 XT-PIC fpu
14: 16314 XT-PIC ide0
NMI: 0
ERR: 0
結(jié)果:可以看到usb-uchi已經(jīng)起來(lái)了,并且被分配了一個(gè)中斷:這里是:int10
b) lsmod
usb-uhci 21708 0 (unused)
usbcore 49856 1 [usb-uhci]
nfsd 69928 4 (autoclean)
lockd 49340 1 (autoclean) [nfsd]
sunrpc 58244 1 (autoclean) [nfsd lockd]
unix 14372 37 (autoclean)
結(jié)果:模塊"usb-uhci"和"usbcore"應(yīng)該在這里羅列。
1.5. 試一下熱插拔
把帶電的HP CD-Writer Plus 8210e 刻錄機(jī)插到你主機(jī)的USB接口上。這樣就會(huì)觸動(dòng)usbmgr程序來(lái)引導(dǎo)必須的模塊。讓我們
先查看一下:tail -n50 /var/log/messages。新的輸出應(yīng)該是報(bào)告熱插拔這個(gè)事件的,所以顯示像下面這樣:
Sep 15 13:13:07 kernel: hub.c: port 1 connection change
Sep 15 13:13:07 kernel: hub.c: portstatus 101, change 1, 12 Mb/s
Sep 15 13:13:08 kernel: hub.c: portstatus 103, change 0, 12 Mb/s
Sep 15 13:13:08 kernel: usb.c: USB new device connect, assigned device number 2
Sep 15 13:13:08 kernel: usb.c: kmalloc IF c2e1f660, numif 1
Sep 15 13:13:08 kernel: usb.c: new device strings: Mfr=1, Product=2, SerialNumber=0
Sep 15 13:13:08 kernel: usb.c: USB device number 2 default language ID 0x409
Sep 15 13:13:08 kernel: Manufacturer: Shuttle Technology Inc.
Sep 15 13:13:08 kernel: Product: HP USB CD-Writer Plus
Sep 15 13:13:08 kernel: usb.c: unhandled interfaces on device
Sep 15 13:13:08 kernel: usb.c: USB device 2 (prod/vend 0x3f0/0x107) is not claimed [..]
Sep 15 13:13:08 kernel: Length = 18
Sep 15 13:13:08 kernel: DescriptorType = 01
Sep 15 13:13:08 kernel: USB version = 1.00
Sep 15 13:13:08 kernel: Vendor:Product = 03f0:0107
Sep 15 13:13:08 kernel: MaxPacketSize0 = 64
?ep 15 13:13:08 kernel: NumConfigurations = 1
Sep 15 13:13:08 kernel: Device version = 2.00
Sep 15 13:13:08 kernel: Device Class:SubClass:Protocol = 00:00:00
Sep 15 13:13:08 kernel: Per-interface classes
Sep 15 13:13:08 kernel: Configuration:
Sep 15 13:13:08 kernel: bLength = 9
Sep 15 13:13:08 kernel: bDescriptorType = 02
Sep 15 13:13:08 kernel: wTotalLength = 0027
Sep 15 13:13:08 kernel: bNumInterfaces = 01
Sep 15 13:13:08 kernel: bConfigurationValue = 01
Sep 15 13:13:08 kernel: iConfiguration = 03
Sep 15 13:13:08 kernel: bmAttributes = 40
Sep 15 13:13:08 kernel: MaxPower = 0mA
Sep 15 13:13:08 kernel:
Sep 15 13:13:08 kernel: Interface: 0
Sep 15 13:13:08 kernel: Alternate Setting: 0
Sep 15 13:13:08 kernel: bLength = 9
Sep 15 13:13:08 kernel: bDescriptorType = 04
Sep 15 13:13:08 kernel: bInterfaceNumber = 00
Sep 15 13:13:08 kernel: bAlternateSetting = 00
Sep 15 13:13:08 kernel: bNumEndpoints = 03
Sep 15 13:13:08 kernel: bInterface Class:SubClass:Protocol = ff:00:00
Sep 15 13:13:08 kernel: iInterface = 04
Sep 15 13:13:08 kernel: Endpoint:
Sep 15 13:13:08 kernel: bLength = 7
Sep 15 13:13:08 kernel: bDescriptorType = 05
Sep 15 13:13:08 kernel: bEndpointAddress = 01 (out)
Sep 15 13:13:08 kernel: bmAttributes = 02 (Bulk)
Sep 15 13:13:08 kernel: wMaxPacketSize = 0040
Sep 15 13:13:08 kernel: bInterval = 00
Sep 15 13:13:08 kernel: Endpoint:
Sep 15 13:13:08 kernel: bLength = 7
Sep 15 13:13:08 kernel: bDescriptorType = 05
Sep 15 13:13:08 kernel: bEndpointAddress = 82 (in)
Sep 15 13:13:08 kernel: bmAttributes = 02 (Bulk)
Sep 15 13:13:08 kernel: wMaxPacketSize = 0040
Sep 15 13:13:08 kernel: bInterval = 00
Sep 15 13:13:08 kernel: Endpoint:
Sep 15 13:13:08 kernel: bLength = 7
Sep 15 13:13:08 kernel: bDescriptorType = 05
Sep 15 13:13:08 kernel: bEndpointAddress = 83 (in)
Sep 15 13:13:08 kernel: bmAttributes = 03 (Interrupt)
Sep 15 13:13:08 kernel: wMaxPacketSize = 0002
Sep 15 13:13:08 kernel: bInterval = 20
Sep 15 13:13:08 kernel: usb.c: kusbd: /sbin/hotplug add 2
Sep 15 13:13:08 kernel: usb.c: kusbd policy returned 0x0
Sep 15 13:13:08 usbmgr[328]: USB device is matched the configuration
Sep 15 13:13:08 kernel: usb.c: registered new driver usb-storage
Sep 15 13:13:08 kernel: scsi0 : SCSI emulation for USB Mass Storage devices
Sep 15 13:13:08 kernel: scsi : 1 host.
Sep 15 13:15:55 kernel: Vendor: HP Model: CD-Writer+ 8200 Rev: 1.0f
#p#
Sep 15 13:15:55 kernel: Type: CD-ROM ANSI SCSI revision: 02
Sep 15 13:15:55 kernel: Detected scsi CD-ROM sr0 at scsi0, channel 0, id 0, lun 0
Sep 15 13:15:55 kernel: sr0: scsi3-mmc drive: 8x/24x writer cd/rw xa/form2 cdda tray
Sep 15 13:15:55 kernel: Uniform CD-ROM driver Revision: 3.11
Sep 15 13:13:08 kernel: WARNING: USB Mass Storage data integrity not assured
Sep 15 13:13:08 kernel: USB Mass Storage device found at 2
Sep 15 13:13:08 kernel: usb.c: usb-storage driver claimed interface c2e1f660
Sep 15 13:13:08 kernel: USB Mass Storage support registered.
Sep 15 13:13:08 usbmgr[328]: "scsi_mod" was loaded
Sep 15 13:13:08 usbmgr[328]: "sr_mod" was loaded
Sep 15 13:13:08 usbmgr[328]: "usb-storage" was loaded
請(qǐng)先檢查這行:USB device 2 (prod/vend 0x3f0/0x107)...,如果你得到的是同樣的ID號(hào)(0x3f0/0x107),那就說(shuō)明你安裝
的是HP8210e,如果你得到的ID是(0x3f0/0x207),那么說(shuō)明你安裝的是HP8230e,它還沒有被支持。
下面的12行十分重要。在"scsi: 1 host:"之后顯示的是這個(gè)刻錄機(jī)的有關(guān)信息。
"Detected scsi CD-ROM sr0 at scsi0, channel 0, id 0, lun 0"這行告訴你你的刻錄機(jī)已經(jīng)被系統(tǒng)發(fā)現(xiàn),并且設(shè)備名稱是
/dev/sr0。在其他的linux版本里可能會(huì)是/dev/scd0。這兩個(gè)是沒有區(qū)別的??磎essages文件里面顯示的什么就是什么了。
可能是我的電腦太舊了,有的時(shí)候這個(gè)過程不一定成功,如果你發(fā)現(xiàn)信息里面沒有出現(xiàn)供應(yīng)商的名稱,那你就需要重新插拔一次。兩三次
后應(yīng)該就沒有問題了。
1.6 測(cè)試
初次的測(cè)試可以是放一張普通的光盤到刻錄機(jī)里,然后mount上去:mount -r -t iso9660 /dev/sr0。
接下去就是測(cè)試刻錄了:(cdrtools-1.10a04 這個(gè)包應(yīng)該事先已經(jīng)裝好),用cdrecord -scanbus 可以查看刻錄機(jī)信息:
Cdrecord 1.10a04 (i586-pc-linux-gnu) Copyright (C) 1995-2000 J??Schilling
Linux sg driver version: 3.1.16
Using libscg version schily-0.4
scsibus0:
0,0,0 0) HP CD-Writer+ 8200 1.0f Removable CD-ROM
0,1,0 1) *
0,2,0 2) *
0,3,0 3) *
0,4,0 4) *
0,5,0 5) *
0,6,0 6) *
0,7,0 7) *
如果想看更多的信息,可以用:cdrecord -prcap -inq dev=0,0,0 返回的是:
Cdrecord 1.10a04 (i586-pc-linux-gnu) Copyright (C) 1995-2000 J??Schilling
scsidev: ,0,0
scsibus: 0 target: 0 lun: 0
Linux sg driver version: 3.1.16
Using libscg version schily-0.4
Device type : Removable CD-ROM
Version : 2
Response Format: 1
Vendor_info : HP
Identifikation : CD-Writer+ 8200
Revision : 1.0f
Device seems to be: Generic mmc CD-RW.
Drive capabilities, per 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 BURN-Proof (Sanyo)
Does read multi-session CDs
Does read fixed-packet CD media using Method 2
Does not read CD bar code
Does not read R-W subcode information
Does read raw P-W subcode data from lead in
Does return CD media catalog number
Does return CD ISRC information
Does not support C2 error pointers
Does not deliver composite A/V data
Does play audio CDs
Number of volume control levels: 256
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 not support digital output on port 2
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 in kB/s: 4234
Current read speed in kB/s: 4234
Maximum write speed in kB/s: 706
Current write speed in kB/s: 706
Buffer size in KB: 2048
現(xiàn)在我們準(zhǔn)備刻錄了。我用的是cdrtools-1.10a04軟件包。當(dāng)然事先要看一下README文件。做的第一個(gè)測(cè)試是:(先放一張新的刻錄盤)
mkisofs -L -l -J -r file1 file2 dir1 dir2 | cdrecord -v -pad -eject -dummy -nofix fs=4m speed=4 dev=0,0,0 -
這個(gè)命令把file1,file2,dir1,dir2做成一個(gè)iso9660格式的鏡像文件,它使用了-J,-r參數(shù),并通過管道直接傳給cdrecord程序。
cdrecord程序會(huì)按照冗余模式測(cè)試寫完整個(gè)光盤。但這個(gè)只是測(cè)試,并沒有真正的寫到刻錄盤上。這個(gè)命令使用了4M的RAM作為buff,
并使用了4速刻錄,使用的設(shè)備是scsi-device 0,0,0.請(qǐng)注意最后的那個(gè)破折號(hào)"-",它告訴cdrecord數(shù)據(jù)是來(lái)自于管道的。請(qǐng)查看這個(gè)
測(cè)試刻錄是不是有問題。請(qǐng)記住一點(diǎn):一張光盤的最大容量是650M,在你刻錄前請(qǐng)先查看要刻錄的容量。
真正的刻錄命令應(yīng)該是:
mkisofs -L -l -J -r file1 file2 dir1 dir2 | cdrecord -v -pad -eject fs=4m speed=4 dev=0,0,0 -
你要把-dummy -nofix 這兩個(gè)參數(shù)去掉。
如果你用新的CD-RW光盤就需要用下面這個(gè)命令:
mkisofs -L -l -J -r file1 file2 dir1 dir2 | cdrecord -v -pad -eject blank=fast fs=4m speed=4 dev=0,0,0 -
這個(gè)命令中的blank=fast參數(shù)將把CD-RW上的數(shù)據(jù)全部抹去,所以要當(dāng)心使用。還要注意:千萬(wàn)不要在刻錄的時(shí)候進(jìn)行熱插拔。
這樣會(huì)造成光盤甚至你的linux系統(tǒng)的破壞。所以記住在拔掉前一定要先取出光盤,以防萬(wàn)一。
1.8 鏈接
Linux USB-ProjectLinux-CD-Writing-HOWTO
通過上文我們知道了如何在Linux下使用刻錄機(jī),趕快去跟朋友分享吧。
【編輯推薦】