跳至内容

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
华夏公益教科书