%% LyX 1.1 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[slidesec]{seminar}
\usepackage[latin1]{inputenc}
\usepackage{graphics}
\IfFileExists{url.sty}{\usepackage{url}}
                      {\newcommand{\url}{\texttt}}

\makeatletter


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
 \newenvironment{lyxlist}[1]
   {\begin{list}{}
     {\settowidth{\labelwidth}{#1}
      \setlength{\leftmargin}{\labelwidth}
      \addtolength{\leftmargin}{\labelsep}
      \renewcommand{\makelabel}[1]{##1\hfil}}}
   {\end{list}}
 \usepackage{verbatim}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{slidesec}
\usepackage[dvips]{graphicx}
\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[L]{\small Alon Altman}
\fancyhead[R]{\small alon@vipe.technion.ac.il}
\fancyfoot[L]{\tiny\thedate}
\fancyfoot[C]{\small CD-Writing under linux}
\fancyfoot[R]{\tiny Slide \theslide}
\renewcommand{\slidetopmargin}{2cm}
\renewcommand{\headwidth}{\textwidth}

\makeatother

\begin{document}

\pagestyle{fancy}

\begin{slide}


\includegraphics{tux-cdr.eps} 


\title{Cd-Writing under Linux}


\author{Alon Altman}

\maketitle

\end{slide}
\begin{comment}
Concepts
\end{comment}
\begin{slide}


\slideheading{Concepts}

\begin{itemize}
\item \textbf{\underbar{CD Image}} - A file which includes the entire contents of
a CD-ROM ready for writing.
\item CD-ROM Filesystems:

\begin{itemize}
\item \textbf{\underbar{iso9660}} - {}``Volume and file structure of CD-ROM for information
interchange{}''.
\item \textbf{\underbar{Joliet}} - Micro\$oft extention of iso9660 to support Unicode
and longer file names.
\item \textbf{\underbar{UDF}} (Universal Disk Format) - New standard, used mosly in
DVDs, supporting packet read/write on CD-RW. Under Linux, UDF is still experimental,
and supports only loopback (not CD).
\end{itemize}
\end{itemize}

\end{slide}
\begin{comment}
What do you need?
\end{comment}
\begin{slide}


\slideheading{What do you need?}

\begin{itemize}
\item A \emph{CD-Writer} (SCSI or IDE), that is supported in Linux.
\item A blank CD-R or CD-RW \emph{media.}
\item \emph{Software:} mkisofs and cdrecord.
\item \emph{Data} you want to write as files on your HD, and/or audio tracks as wav
files (data can actually be piped over the network, but it is strongly advised
to keep the data on the local HD).
\item About 640Mb of \emph{free HD space} for CD-Image (not really required, but preferable).
\end{itemize}
\end{slide}
\begin{comment}
Documentaion
\end{comment}
\begin{slide}


\slideheading{Documentaion}

\begin{itemize}
\item \textbf{CD-Writing-HOWTO} - excellent document all about writing CDs in Linux.
\item \textbf{man pages} of \texttt{mkisofs} and \texttt{cdrecord}.
\item \textbf{/usr/share/doc/cdrecord{*}} - \texttt{cdrecord} documentation, also
available on the Web.
\item CDRecord Homepage - \url{http://www.fokus.gmd.de/research/cc/glone/employees/joerg.schilling/private/cdrecord.html}
\end{itemize}
\end{slide}
\begin{comment}
the Process
\end{comment}
\begin{slide}


\slideheading{The CD Writing Process}

\begin{itemize}
\item Prepare your system for writing CDs (done only once)
\item Prepare source directory/wav files
\item Make the ISO image.
\item Write the ISO image to a CD.
\end{itemize}
\end{slide}
\begin{comment}
Preperation
\end{comment}
\begin{slide}


\slideheading{Preparation}

\begin{itemize}
\item Install your CD Writer Drive physically. \textbf{Note:} Make sure your CD Writer
drive is \emph{not} on the same IDE cable as your HD with the CD-images.
\item Install kernel modules \texttt{ide-scsi} (for IDE only), \texttt{sg} and \texttt{sr\_mod}.
You can either re-compile the kernel, or insmod the modules.
\item Edit \texttt{/etc/lilo.conf} and add in your configuration a line \texttt{append={}''hdd=ide-scsi{}''},
while hdd is the name of your CD-Writer.
\item Reboot your computer. Run as root: \texttt{cdrecord -{}-scanbus} and make sure
you see your cd-writer listed.
\end{itemize}
\end{slide}
\begin{comment}
Source dir Preperation
\end{comment}
\begin{slide}


\slideheading{Preparation of Source Directory}

In order to write CDs you need the source data be put in one directory (actually,
the newest version of \texttt{mkisofs} knows to handle multiple source dirs).
If your files are scattered all over the hard disk, you can eiter copy the files
to one source directory, or use symbolic links, and create an image directory
that includes only symbolic links to the source files.

For writing CD-Audio tracks, you need to prepare WAV files that will be converted
to CD-Audio.

\end{slide}
\begin{comment}
Running mkisofs
\end{comment}
\begin{slide}


\slideheading{Running mkisofs}

\texttt{mkisofs} is the program that converts files on your filesystem to a
CD image. The syntax is:

{\par\centering \verb+mkisofs [options] -o filename pathspec+\par}

The \texttt{-o} option specifies the name output \emph{image file} to be written.

The path specification is the name of the source directory.

To use multiple source directories scattered arbitrarily on the filesystem,
you may use the \texttt{-graft-points} option. \texttt{man mkisofs} for details.

\end{slide}
\begin{comment}
mkisofs options
\end{comment}
\begin{slide}


\slideheading{mkisofs options}

\texttt{mkisofs} has \emph{lots} of options, such as:

\begin{lyxlist}{00.00.0000}
\item [\texttt{-v}]Enable verbose mode - a 'must have' option.
\item [\texttt{-r}]Enable Rock Ridge (UNIX permissions)
\item [\texttt{-J}]Enable Joliet (Windows-Readable LFNs)
\item [\texttt{-jcharset}]Specify charset for file names in Windows. Use charset \texttt{iso8859-8}
for standard Hebrew support.
\item [\texttt{-f}]Follow symbolic links - Important if you've symlinked your source
directory.
\item [\texttt{-l}]Allow long file names (31 characters)
\item [\texttt{-D}]Do not relocate deep directories (non-standard).
\item [\texttt{-L}]Allow filenames to begin with a period (non-standard)
\end{lyxlist}
Refer to \texttt{man mkisofs} for complete list of options.

\end{slide}
\begin{comment}
Testing
\end{comment}
\begin{slide}


\slideheading{Testing the CD-Image}

Linux lets you \texttt{mount} a CD-Image as if it is a real CD. This is by using
the special \texttt{loop} device in the kernel. This topic was more throughly
discussed in the Rescue disk lecture.

To test a cdrom image issue the command:

\verb+# mount -o loop,ro -t iso9960 image.iso /mnt/cdimage+

Don't forget to unmount the image after testing:

\verb+# umount /mnt/cdimage+

\end{slide}
\begin{comment}
cdrecord
\end{comment}
\begin{slide}


\slideheading{Running cdrecord}

\texttt{cdrecord} is program that actually writes the disk. The syntax is:

\begin{lyxlist}{00.00.0000}
\item [\texttt{cdrecord}]\texttt{{[}general options{]} dev=}\texttt{\emph{device}}
\texttt{{[}track options{]}} \texttt{\emph{track1}}\texttt{...}\texttt{\emph{trackn}}
\end{lyxlist}
'device' is the SCSI id of the device, in the format scsibus,target,lun. This
data can be found by running \texttt{cdrecord -{}-scanbus}. For IDE drives,
this usually is 0,0,0.


\slidesubheading{General options:}

The most important options include:

\begin{lyxlist}{00.00.0000}
\item [\texttt{-v}]Enable verbose mode - a 'must have' option.
\item [\texttt{-dummy}]Simulation mode. Try this before real writing.
\item [\texttt{-eject}]Eject after write.
\item [\texttt{speed=\#}]Set writing speed.
\end{lyxlist}
\end{slide}
\begin{comment}
cdrecord options
\end{comment}
\begin{slide}


\slidesubheading{General options (cont.)}

\begin{lyxlist}{00.00.0000}
\item [\texttt{fs=\#}]Set FIFO size (buffer). Default is 4MB. Mostly used when piping
data directly from \texttt{mkisofs}.
\item [\texttt{-dao}]Disk-At-Once mode, eliminates silence between audio tracks.
\end{lyxlist}

\slidesubheading{Track options}

\begin{lyxlist}{00.00.0000}
\item [\texttt{-audio}]All subsequent tracks are audio tracks (au or wav files).
\item [\texttt{-data}]All subsequent tracks are data tracks (ISO images).
\item [\texttt{-pad}]Pad data/audio tracks to frame. Needed when writing audio.
\end{lyxlist}
Refer to \texttt{man cdrecord} for detailed explanation of all options.

\end{slide}
\begin{comment}
cdrecord options
\end{comment}
\begin{slide}


\slideheading{GUIs for CD-Writing (or: How to do it easily?)}

\begin{itemize}
\item xcdroast - \url{http://www.xcdroast.org}
\item gtoaster - \url{http://gnometoaster.rulez.org/}
\item kreatecd - \url{ftp://ftp.kde.org/pub/kde/unstable/apps/multimedia/cdrom}
\item and much much more..
\end{itemize}
Personally, I use xcdroast and it works very well. All these frontends make
it much easier to write your CDs under Linux, at the cost of loss of some ultra-advanced
functionallty.

\end{slide}
\begin{comment}
Advanced Topics
\end{comment}
\begin{slide}


{\par\centering {\Huge Advanced Topics}\Huge \par}

\end{slide}
\begin{comment}
cdrecord options
\end{comment}
\begin{slide}


\slideheading{CD-RW blanking}

In order to blank a CD-RW (ReWriteable) disc, you should use the \texttt{blank}
option of \texttt{cdrecord}.

The syntax is: \texttt{cdrecord dev=0,0 blank=}\texttt{\emph{type}}

Blank types are:

\begin{lyxlist}{00.00.0000}
\item [all]Blank entire disk
\item [fast]Minimally blank entire disk (best choice)
\item [track]Blank a track
\item [unclose]Un-close last session
\item [session]Blank last session
\end{lyxlist}
\end{slide}
\begin{comment}
cdrecord options
\end{comment}
\begin{slide}


\slideheading{Writing with no image (on-the-fly)}

In order to write a CD without creating an image on the HD, all you need to
do is pipeline to output of \texttt{mkisofs} to \texttt{cdrecord}.

The syntax is: \texttt{mkisofs {[}options{]} | cdrecord {[}options{]} -}

\begin{itemize}
\item This will create the image and write the CD on-the-fly.
\item It is strongly advised to do a dry-run with \texttt{-dummy} before doing the
real write.
\item Make sure that the CD-Writer is NOT on the same IDE as the HD with image data,
otherwise this will not work. 
\item If the machine is tight on CPU, you might want to \texttt{nice} the mkisofs
to priority -18 by typing: \texttt{nice -{}-18 mkisofs} instead of \texttt{mkisofs}.
\item If you get buffer underruns, use \texttt{fs=}\texttt{\emph{size}} in cdrecord
to increase buffer size above 4 megs.
\end{itemize}
\end{slide}
\begin{comment}
Bootable
\end{comment}
\begin{slide}


\slideheading{Creating bootable CDs}

\texttt{cdrecord} supports several types of bootable CDs, however the most commonly
used is {}``El Torito{}'' bootable CDs.

The {}``El Torito{}'' standard specifies that the CD should include an image
of a floppy or hard drive, that will replace the real floppy/hard drive when
booting. The floppy drive option is most commonly used, to boot the system from
CD, still keeping HDD support.

In order to create a bootable CD, you first need a floppy image. More information
about floppy images may be found in the {}``Rescue Disk{}'' lecture, previously
given in this forum.

If you already have a bootable floppy, you can create a floppy image using:
\texttt{cat /dev/fd0 > image}

\pagebreak

In order to make a CD bootable, you need to put the floppy image somewhere in
the CD image directory, and tell \texttt{mkisofs} about it using the \texttt{-b}
flag. In addition you need to specify a name for the boot catalog file with
the \texttt{-c} option. This usually is {}``\texttt{boot.catalog}{}''.

For example, if your floppy image is on \texttt{/bootimage} relative to the
CD image, then the command should look like:

\texttt{mkisofs {[}options{]} -b /bootimage -c boot.catalog} \texttt{\emph{path}}

This will create the CD image, bootable by the given boot image.

\end{slide}
\begin{comment}
Multisession
\end{comment}
\begin{slide}


\slideheading{Multisession CDs}

Multisession CDs allow you to add data to already-burned CDs in an additional
'session'

To write multi-session CDs, you need to mark each session (possibly except the
last) as ready for multi-session using the \texttt{-multi} flag on \texttt{cdrecord}.

To add a session to a written disk, you have to first get the parameters of
the first session using: 

\texttt{cdrecord dev=x,y -msinfo}. 

This will return two numbers seperated by a comma {}``\texttt{xxx,yyy}{}''. 

\pagebreak

To make the image for the second session, you will need to add the following
flags to \texttt{mkisofs} (Persuming your CD-Writer drive is /dev/scd0): 

\texttt{mkisofs -M /dev/scd0 -C xxx,yyy {[}more options{]}}

This will create the image. This image can be written as usual. If you wish
to be able to add additional sessions, you must use the \texttt{-multi} option
in \texttt{cdrecord}.

For more detailed informaion, see \texttt{README.multi} in your cdrecord documentation.

\end{slide}
\begin{comment}
mp3
\end{comment}
\begin{slide}


\slideheading{Audio CD from mp3 on the fly}

Suppose you have some (legal) mp3 files on your hard disk, and you would like
to make an audio CD out of them, \emph{without} needing to save the temporary
wav files on your HD. How can this be done?

To convert and mp3 file to a wav file, you would usually use this command:

\texttt{mpg123 -s song.mp3 | }~\\
\texttt{sox -s -t raw -w -r 44100 -c 2 - song.wav}

To write the mp3 files direcly, all you have to do is create \emph{named pipes}
on the filesystem (calling them \texttt{song1.}raw, \texttt{song2.}raw, etc.)
and call the decoding command in the background into those pipes, then write
from the pipes.

\pagebreak

To create the pipes, use (for each song): \texttt{}

\texttt{mknod song}\texttt{\emph{n}}\texttt{.raw p}

Then, do the decoding for each file in the background (There is no need to convert
to wav format):

\texttt{mpg123 -s song}\texttt{\emph{n}}\texttt{.mp3 > song}\texttt{\emph{n}}\texttt{.raw
\&}

Then, run \texttt{cdrecord} as usual, with the \texttt{-swab} option added to
indicate you are using swapped byte order (little-endian):

\texttt{cdrecord -v dev=xx,yy speed=2 -swab -audio song{*}.raw}

\end{slide}
\begin{comment}
End
\end{comment}
\begin{slide}


\slideheading{Summary}

\begin{itemize}
\item Creating CDs under Linux is quite an easy process.
\item The easiest way to create CDs is with a GUI.
\item Linux allows you to do advanced tricks (such as mp3 on the fly) using the OS's
pipe feature in conjunction with \texttt{cdrecord}.
\item Have fun, and don't forget - use \texttt{-dummy} first!\end{itemize}
\end{slide}

\end{document}
