DaemonForums  

Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 30th December 2008
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
ISO Quartermaster
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 589
Post FreeBSD howto: burning and ripping cd's

To create iso
Code:
$ mkisofs -o /path/to/output.iso -R -J /path/to/files/you/want/on/cd
to burn cd-r/cd-rw
Code:
$ burncd data /path/to/output.iso fixate
to burn files to disk (without creating iso) [thanks to Pushrod]
Code:
mkisofs -o /dev/stdout -R -J /path/to/files/you/want/on/cd | burncd data /dev/stdin fixate
to blank cd-rw
Code:
$ burncd blank
to get cd/dvd image (to get iso from disk)
Code:
$ dd if=/dev/acd0 of=/path/to/disk.iso bs=2048

to burn dvd iso to disk
Code:
$ growisofs -dvd-compat -Z /dev/cd0=/path/to/image.iso
to burn files to dvd without creating iso
Code:
$ growisofs -Z /dev/cd0 -R -J /some/files
above 2 commands will overwrite content on dvd+-rw disk
no need to blank (so it seams. i tested on my pc)


to append to dvd (must use same options as when creating this dvd)
Code:
$ growisofs -M /dev/cd0 -R -J /some/more/files
to finalize dvd (you need this after appending to dvd)
Code:
$ growisofs -M /dev/cd0=/dev/zero

to burn audio cd from wav files
Code:
$ burncd audio file1.wav file2.wav file3.wav fixate
here's simple script that uses mplayer and burncd to burn audio cd's from directory with music files (basically any file that mplayer can play)
Code:
#!/bin/sh
for i in `ls`; do
  rm -f /tmp/cd_track.wav
  mplayer -vo null -vc dummy -af resample=44100 -ao pcm:file=/tmp/cd_track.wav $i
  burncd audio /tmp/cd_track.wav
done
rm -f /tmp/cd_track.wav
burncd audio fixate
exit 0
and here's another simple script to rip audio cd's to mp3
Code:
#!/bin/sh
mkdir /tmp/cd
cd /tmp/cd
cdparanoia -B -d /dev/acd0
for i in `ls *.wav`; do
  lame -m s "$i" -o "$(echo $i | awk '{print substr($0,6,2)}' -).mp3"
  rm -f "$i"
done
echo 'files are in /tmp/cd'
exit 0
you can rip 1 audio track to wav with
Code:
$ cdparanoia -B -d /dev/acd0 1
in this example it'll rip track 1 only
and convert it to mp3 with
Code:
lame -m s audio.wav -o audio.mp3



to attach and mount iso image
Code:
$ mdconfig -a -t vnode -u 0 -f /path/to/image.iso
$ mount -t cd9600 /dev/md0 /mnt

to umount and detach iso image
Code:
$ umount /mnt
$ mdconfig -du 0

To make it all happen you need:

in kernel
Code:
options 	CD9660			# ISO 9660 Filesystem, because you want to read them ;)
device		atapicd		# ATAPI CDROM drives
device		atapicam
device		cd				# nessacery for dvd's
device 		pass
device 		scbus
options		MD_ROOT
device		md
options         UDF
and permission to write to /dev/acd0 /dev/cd0 /dev/pass1

note: The pass device number will also depend on the order that SCSI devices are enumerated by the kernel. To determine exactly which one it is, one can use camcontrol devlist as root [thanks to phoenix from daemonforums.org]

note, you can't run growisofs using su, you need to do that as user....

here's some part of my /etc/devfs.conf
Code:
own     acd0    root:users
perm    acd0    0660

own     cd0     root:users
perm    cd0     0660

own     pass1   root:users
perm    pass1   0660

own     pass0   root:users
perm    pass0   0660

note: if you have more than one drive, you need to specify which one to use with burncd as well
use -f flag for this
Code:
burncd -f /dev/acd1 data /path/to/image.iso fixate
to use mkisofs you need to install sysutils/cdrtools
to use growisofs you need to install sysutils/dvd+rw-tools

to use cdparanoia you need to install audio/cdparanoia
to use lame you need to install audio/lame
to use mplayer you need to install multimedia/mplayer



resources:
man 8 burncd
man 8 mkisofs
man 8 growisofs

man 8 mplayer
man 1 cdparanoia

man 8 mdconfig

man 1 lame , hmm why this is not available in freebsd online manual pages?


origianl post:
https://forums.freebsd.org/showthread.php?t=1195

Last edited by graudeejs; 30th December 2008 at 05:03 PM.
Reply With Quote
  #2   (View Single Post)  
Old 30th December 2008
phoenix's Avatar
phoenix phoenix is offline
Risen from the ashes
 
Join Date: May 2008
Posts: 696
Default

Quote:
Originally Posted by killasmurf86 View Post
to get cd/dvd image (to get iso from disk)
Code:
$ dd if=/dev/acd0 of=/path/to/disk.iso bs=1M
Block size for CD/DVD is 2K, so to get the best speed/reliability, you should use bs=2048

Quote:
To make it all happen you need:

in kernel
Code:
options 	CD9660			# ISO 9660 Filesystem, because you want to read them ;)
device		atapicd		# ATAPI CDROM drives
device		atapicam
device		cd				# nessacery for dvd's
device 		pass
device 		scbus
options		MD_ROOT
device		md
and permission to write to /dev/acd0 /dev/cd0 /dev/pass1
One should also have options UDF in order to read DVDs with files larger than 2 GB on them, or to burn DVDs with files larger than 2 GB. I believe there are extensions to cd9660 to allow for files larger than 2 GB, it's more reliable to use UDF.

The pass device number will also depend on the order that SCSI devices are enumerated by the kernel. To determine exactly which one it is, one can use camcontrol devlist

Excellent post. There's some info in there that I hadn't known, as I've been using K3B for so many years now. Nice little cheat-sheet for when I want to burn something remotely. Thanks.
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
  #3   (View Single Post)  
Old 30th December 2008
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
ISO Quartermaster
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 589
Default

Thanks
I will add your info to original post
Reply With Quote
  #4   (View Single Post)  
Old 30th December 2008
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

Quote:
Originally Posted by phoenix View Post
Block size for CD/DVD is 2K, so to get the best speed/reliability, you should use bs=2048
While that is true.. the block size is 2048 bytes.. the transfer rate from CD's is not 2048 bytes per second.

Specifying a larger block size in dd will increase the speed.
Reply With Quote
  #5   (View Single Post)  
Old 30th December 2008
phoenix's Avatar
phoenix phoenix is offline
Risen from the ashes
 
Join Date: May 2008
Posts: 696
Default

Nope, it won't (or, at least not by enough to make a difference):
Code:
[root@thehive /storage]# dd if=/dev/acd0 of=2k.iso bs=2K
230426+0 records in
230426+0 records out
471912448 bytes transferred in 208.567875 secs (2262632 bytes/sec)

[root@thehive /storage]# dd if=/dev/acd0 of=1m.iso bs=1M
450+1 records in
450+1 records out
471912448 bytes transferred in 208.797817 secs (2260141 bytes/sec)

[root@thehive /storage]# md5 /dev/acd0 2k.iso 1m.iso
MD5 (/dev/acd0) = d41d8cd98f00b204e9800998ecf8427e
MD5 (2k.iso) = 400fdb244d7540fd01b82d194d99c284
MD5 (1m.iso) = 400fdb244d7540fd01b82d194d99c284

[root@thehive /storage]# dd if=/dev/acd0 of=1m-2.iso bs=1M
162+1 records in
162+1 records out
170164224 bytes transferred in 88.262563 secs (1927932 bytes/sec)

[root@thehive /storage]# dd if=/dev/acd0 of=2k-2.iso bs=2K
83088+0 records in
83088+0 records out
170164224 bytes transferred in 88.409275 secs (1924733 bytes/sec)

[root@thehive /storage]# md5 /dev/acd0 2k-2.iso 1m-2.iso
MD5 (/dev/acd0) = d41d8cd98f00b204e9800998ecf8427e
MD5 (2k-2.iso) = 6830513ed854155bd0b0bba5ce0c3f92
MD5 (1m-2.iso) = 6830513ed854155bd0b0bba5ce0c3f92
But, it looks like the .iso files created are identical, so maybe it's only on the burning side that it makes a difference?

On a side note, anyone know how to create an md5 hash of a cdrom on FreeBSD? In Linux, one can just "md5sum /dev/cdrom" and get the same md5 hash as the .iso generated via dd, which doesn't seem to work on FreeBSD.
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
  #6   (View Single Post)  
Old 30th December 2008
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
ISO Quartermaster
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 589
Default

perhaps try md5 /dev/cd0
Reply With Quote
  #7   (View Single Post)  
Old 31st December 2008
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

@Phoenix, Apologies.. I was basing my claims on OpenBSD findings.

Each device has a block/character device, /dev/rcd0a and /dev/cd0a, respectively.
  • Block devices are buffered devices.. used only by mount(8). (Usually...).
  • Character devices are unbuffered devices.. used by utilities like, dd(1) for instance.
Code:
[bsdfan@bluebox $ttyp0]~/tests: $ disklabel cd1
# /dev/rcd1c:
type: ATAPI
disk: KR9053430
label:
flags:
bytes/sector: 2048
sectors/track: 100
tracks/cylinder: 1
sectors/cylinder: 100
cylinders: 2310
total sectors: 230930
rpm: 300
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0 

3 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  a:           230930                0 ISO9660                   
  c:           230930                0 ISO9660                   
[bsdfan@bluebox $ttyp0]~/tests: $ dd if=/dev/rcd1a of=2k.iso bs=2k
230930+0 records in
230930+0 records out
472944640 bytes transferred in 159.694 secs (2961550 bytes/sec)
[bsdfan@bluebox $ttyp0]~/tests: $ dd if=/dev/rcd1a of=1m.iso bs=1m 
451+1 records in
451+1 records out
472944640 bytes transferred in 118.886 secs (3978121 bytes/sec)
[bsdfan@bluebox $ttyp0]~/tests: $ dd if=/dev/rcd1a of=10m.iso bs=10m
45+1 records in
45+1 records out
472944640 bytes transferred in 123.956 secs (3815423 bytes/sec)
[bsdfan@bluebox $ttyp0]~/tests: $ md5 2k.iso 1m.iso 10m.iso
MD5 (2k.iso) = 2870e9cf5455d769372bb5d45bc22d9c
MD5 (1m.iso) = 2870e9cf5455d769372bb5d45bc22d9c
MD5 (10m.iso) = 2870e9cf5455d769372bb5d45bc22d9c
[bsdfan@bluebox $ttyp0]~/tests: $ md5 /dev/rcd1a
md5: /dev/rcd1a: read error: Invalid argument
[bsdfan@bluebox $ttyp0]~/tests: $ md5 /dev/cd1a   
MD5 (/dev/cd1a) = 2870e9cf5455d769372bb5d45bc22d9c
[bsdfan@bluebox $ttyp0]~/tests: $
I don't see any instabilities.. and using a larger block size, does appear to increase the speed.

Things must work differently on FreeBSD...
Reply With Quote
  #8   (View Single Post)  
Old 31st December 2008
phoenix's Avatar
phoenix phoenix is offline
Risen from the ashes
 
Join Date: May 2008
Posts: 696
Default

FreeBSD doesn't have separate "buffered" vs "unbuffered" or "block" vs "character" devices. There's just devices. I don't recall off-hand whether they're block, character, or a mix of features from both.
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
  #9   (View Single Post)  
Old 31st December 2008
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

Right; So it looks like their are multiple.. perhaps.. conflicting.. CD-ROM drivers.

There is acd(4) and cd(4)... aka ATAPICAM?

I officially give up trying to understand the strange world of FreeBSD.
Reply With Quote
Old 31st December 2008
robbak's Avatar
robbak robbak is offline
Real Name: Robert Backhaus
VPN Cryptographer
 
Join Date: May 2008
Location: North Queensland, Australia
Posts: 366
Default

Yes, that is right. ATAPI (ie IDE) cd-rom drives are exposed as acd. SCSI cdroms are exposed as cd (as they came first)

ATAPICAM produces a SCSI interface to ATAPI devices - this is possible because ATAPI was basically SCSI commands over the what the IDE interface developed into. So, if you have ATAPICAM installed, your optical devices will be known as both /dev/acd0 and /dev/cd0. See? Not strange at all. Blame those Hysterical Raisins.
__________________
The only dumb question is a question not asked.
The only dumb answer is an answer not given.
Reply With Quote
Reply

Tags
burn, cd, dvd, freebsd

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
FreeBSD GPT howto graudeejs Guides 10 21st December 2010 12:24 AM
HOWTO: Enemy Territory on FreeBSD tangram Guides 0 9th June 2009 03:31 PM
HOWTO: QEMU on FreeBSD vermaden Guides 10 9th March 2009 07:10 PM
HOWTO: FreeBSD with CCACHE vermaden Guides 10 9th July 2008 06:14 PM
HOWTO: BURNCD like DVD and CD CLI burning vermaden Guides 0 5th May 2008 10:45 AM


All times are GMT. The time now is 10:07 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick