跳至內容

Unix指南/解釋/光碟

來自Wikibooks,開放世界的開放書籍

讀取CD音訊

[編輯 | 編輯原始碼]

這會將CD音軌中的音訊複製到一個檔案中。對於某些驅動器(沒有模擬連線到音效卡的驅動器),這是正確播放檔案的唯一方法。

授予使用者許可權

[編輯 | 編輯原始碼]

首先,您應該對CD裝置具有讀寫許可權。(您可以成為root來讀取CD,但隨後您必須將檔案“chown”回給您自己。)

首先檢視您的CD裝置節點。在*BSD上,它們位於/dev/cd*/dev/rcd*。如果它們看起來像這樣

$ ls -l /dev/cd*
brw-r--'---  1 root  operator    3,   0 Nov  1 16:26 /dev/cd0a
brw-r--'---  1 root  operator    3,   2 Nov  1 16:26 /dev/cd0c
brw-r--'---  1 root  operator    3,  16 Nov  1 16:26 /dev/cd1a
brw-r--'---  1 root  operator    3,  18 Nov  1 16:26 /dev/cd1c

這裡,root需要授予使用者讀寫許可權。我們決定將使用者新增到“wheel”組。一旦他們加入,我們更改裝置的組並授予該組讀寫許可權。

$ sudo chgrp wheel /dev/cd* /dev/rcd*
$ sudo chmod g+gw /dev/cd* /dev/rcd*
$ ls -l /dev/cd*
brw-rw--'--  1 root  wheel    3,   0 Nov  1 16:26 /dev/cd0a
brw-rw--'--  1 root  wheel    3,   2 Nov  1 16:26 /dev/cd0c
brw-rw--'--  1 root  wheel    3,  16 Nov  1 16:26 /dev/cd1a
brw-rw--'--  1 root  wheel    3,  18 Nov  1 16:26 /dev/cd1c

讀取曲目

[編輯 | 編輯原始碼]

在讀取音軌之前,我們必須插入CD。

例如,這裡我們讀取音軌2並將其儲存在song.wav中。我們的“.wav”字尾是因為這是cdparanoia的預設格式。當CD在

$ cdparanoia 2 song37.wav

彈出光碟

[編輯 | 編輯原始碼]

許多系統都提供eject命令。

$ eject cd0

燒錄光碟

[編輯 | 編輯原始碼]

場景:將名為backup的目錄的內容放到CD中。

這裡我們以root身份進行實際燒錄(和彈出)。使用者需要具有“sudo”訪問許可權,但不需要對CD裝置節點有任何特殊訪問許可權。

建立CD的磁碟映像。我們將其命名為burn.iso.

  • -R是ISO6990 Rock Ridge支援
  • -r是Rock Ridge,但所有檔案都位於根目錄下(可在具有不同使用者的計算機上使用)
  • -hfs表示混合ISO9660/HFS磁碟
$ mkisofs -o burn.iso -r -hfs backup
$ chmod a-w burn.iso

將其掛載以檢查有效性。(NetBSD/OpenBSD)

$ sudo vnconfig /dev/svnd0c burn.iso
$ sudo mount -r -t cd9660 /dev/svnd0a /mnt
$ diff /mnt backup
$ echo $?
0
$ sudo umount /mnt
$ sudo vnconfig -u /dev/svnd0c

儘管file具有誤導性,但檔案系統是好的。

$ file burn.iso
burn.iso: x86 boot sector, extended partition table

插入空白光碟。

這是一個演示的測試燒錄cdrecord -v.

$ sudo cdrecord -v -dummy dev=/dev/cd0c burn.iso
cdrecord: No write mode specified.
cdrecord: Assuming -tao mode.
cdrecord: Future versions of cdrecord may have different drive dependent defaults.
cdrecord: Continuing in 5 seconds...
Cdrecord-Clone 2.01 (--) Copyright (C) 1995-2004 Jörg Schilling
TOC Type: 1 = CD-ROM
scsidev: '/dev/cd0c'
devname: '/dev/cd0c'
scsibus: -2 target: -2 lun: -2
Using libscg version 'schily-0.8'.
SCSI buffer size: 61440
atapi: 0
Device type    : Removable CD-ROM
Version        : 0
Response Format: 2
Capabilities   :
Vendor_info    : 'MATSHITA'
Identifikation : 'CD-RW  CW-8123  '
Revision       : 'CA0T'
Device seems to be: Generic mmc2 DVD-ROM.
Current: 0x0009
Profile: 0x0010
Profile: 0x0008
Profile: 0x0009 (current)
Profile: 0x000A
Using generic SCSI-3/mmc   CD-R/CD-RW driver (mmc_cdr).
Driver flags   : MMC-2 SWABAUDIO BURNFREE
Supported modes: TAO PACKET SAO SAO/R96P SAO/R96R RAW/R16 RAW/R96P RAW/R96R
Drive buf size : 1731072 = 1690 KB
FIFO size      : 4194304 = 4096 KB
Track 01: data   114 MB
Total size:      130 MB (12:58.58) = 58394 sectors
Lout start:      131 MB (13:00/44) = 58394 sectors
Current Secsize: 2048
ATIP info from disk:
  Indicated writing power: 5 
  Is not unrestricted
  Is not erasable
  Disk sub type: Medium Type B, low Beta category (B-) (4)
  ATIP start of lead in:  -11834 (97:24/16)
  ATIP start of lead out: 359849 (79:59/74)
Disk type:    Short strategy type (Phthalocyanine or similar)
Manuf. index: 24
Manufacturer: Sony Corporation
Blocks total: 359849 Blocks current: 359849 Blocks remaining: 301455
Starting to write CD/DVD at speed 24 in dummy TAO mode for single session.
Last chance to quit, starting dummy write    0 seconds. Operation starts.
Waiting for reader process to fill input buffer ... input buffer ready.
BURN-Free is ON.
Turning BURN-Free off
Starting new track at sector: 0
Track 01:  114 of  114 MB written (fifo 100%) [buf  98%]   8.2x.
Track 01: Total bytes read/written: 119586816/119586816 (58392 sectors).
Writing  time:  102.275s
Average write speed   7.6x.
Min drive buffer fill was 98%
Fixating...
WARNING: Some drives don't like fixation in dummy mode.
Fixating time:   34.457s
cdrecord: fifo had 1947 puts and 1947 gets. 
cdrecord: fifo was 0 times empty and 1860 times full, min fill was 80%.
$ echo $?
0

實際燒錄

$ sudo cdrecord dev=/dev/cd0c burn.iso
Password:
cdrecord: No write mode specified.
cdrecord: Assuming -tao mode.
cdrecord: Future versions of cdrecord may have different drive dependent defaults.
cdrecord: Continuing in 5 seconds...
Cdrecord-Clone 2.01 (--) Copyright (C) 1995-2004 Jörg Schilling
scsidev: '/dev/cd0c'
devname: '/dev/cd0c'
scsibus: -2 target: -2 lun: -2
Using libscg version 'schily-0.8'.
Device type    : Removable CD-ROM
Version        : 0
Response Format: 2
Capabilities   :
Vendor_info    : 'MATSHITA'
Identifikation : 'CD-RW  CW-8123  '
Revision       : 'CA0T'
Device seems to be: Generic mmc2 DVD-ROM.
Using generic SCSI-3/mmc   CD-R/CD-RW driver (mmc_cdr).
Driver flags   : MMC-2 SWABAUDIO BURNFREE
Supported modes: TAO PACKET SAO SAO/R96P SAO/R96R RAW/R16 RAW/R96P RAW/R96R
Starting to write CD/DVD at speed 24 in real TAO mode for single session.
Last chance to quit, starting real write    0 seconds. Operation starts.
Track 01: Total bytes read/written: 119586816/119586816 (58392 sectors).
$ echo $?
0

我們現在應該彈出已完成的光碟。作業系統或驅動器可能不知道光碟現在在其上有一個檔案系統。

$ sudo eject cd0

如果我們重新插入光碟,那麼我們可以掛載/解除安裝它。

$ sudo mount /dev/cd0a /mnt
$ sudo umount /mnt
華夏公益教科書