Accessing Removable Media devices
Reading removable media
The floppy, cd/dvd, zip drive and USB memory sticks can all be read from the command line or via a graphical file browser.
Command line usage
Each fixed device has a mount point as listed below:- Floppy -
/media/floppy - Zip -
/media/zip - CD/DVD -
/media/cdrom
Note each of these is actually a symlink to the first such device labelled 0, i.e. the floppy drive mount point is really /media/floppy0.
In the case of USB memory sticks/flash disks the system determines the mount point when the device is connected.
When you insert a CD or USB disk the machine notices the new media and automatically mounts the device and opens the graphical file manager at the correct mount point. If you do not like this behaviour you can change it from the Applications -> Desktop Preferences -> Removable drives and media menu item (e.g. turn of the graphical file manager auto startup). Note the automatic mounting and starting of the graphical file manager can take up to 30 seconds.
In the case of floppy and zip disks the machine cannot tell if media has been inserted so you first need to mount it, e.g. to mount a floppy disk use
mount /media/floppy
The machine will then mount the media and the files appear under /media/floppy/.
To copy a file from the floppy disk to your home direct you might do
cp /media/floppy/myfile ~/
Important: When you have finished using the media/device before removing it you must first unmount it!.
When the device was first mounted an icon appears at the left hand side of your screen. You can unmount/eject the device by right clicking the icon and choosing the appropriate option.
To unmount a device using the command line tools you need to make sure you are not still using its files and that your current directory is not within the device, e.g. for the floppy drive to unmount it you would do
pumount /media/floppy
Note the command is pumount not punmount.
Having unmounted the device/media it is then safe to remove it. Failure to unmount a device can lead to file damage/loss as the computer may not have finished all operations on the device.
Graphical file browser
As an alternative to command line interaction you can use the nautilus file browser. On the desktop their is an icon markedComputer. If you double click this the file browser will start listing all the media devices on the machine. You can then double click a particular device to instruction nautilus to mount it and display the files. You can now browse the files and open them as required or copy them to your home directory or drag them on to your desktop.
Writing to removable media
The floppy, cd/dvd, zip drive and USB memory sticks can all be read from the command line or via a graphical file browser.
Command line usage
For the floppy, zip and USB memory sticks writing to the media is done in a similar fashion to reading from it. First you mount the device (if it does not automatically mount) and then you copy files on, e.g. for the floppy diskmount /media/floppy
cp ~/myfile /media/floppy/
pumount /media/floppy
which mounts the device, copies a file on and then unmounts the device before you remove the media.
The key exception is CD/DVD drives. CD/DVD media does not typically contain a file system to which you can simply write new files as with other media. Instead to create CD/DVDs you need to create a disk image first and then burn it to the media. Depending on whether the media is recordable (e.g. CD-R) or rewritable (e.g. CD-RW) determines whether you can blank the disk and use it again or whether you can only write to it once.CD Writing
Graphical usage
By default when you insert writable media into the CD/DVD drive the nautilus graphical file manager will start at the CD burning location.
To start the nautilus CD bruner by hand start nautilus and select Go -> CD Creator. Then drag files/directories into the CD creator that you wish to put on the CD/DVD When you are ready press the Write to CD button to write the files to CD/DVD.
Another graphical CD writing tool is xcdroast.
Command line usage
Single Session CD
To write to a CD the contents of a directory you would do
mkisofs -r -o /scratch/mycdimage.iso my_directory_of_files
to make a CD image. You then burn this to a blank CD with
cdrecord -v -data /scratch/mycdimage.iso
Lastly tidy up by removing the cdimage with
rm /scratch/mycdimage.iso
If you are using a rewritable CD that already contains data you can blank the CD first with the extra option -blank=fast.
Note: mkisofs without additional options as above makes a strictly ISO9660 compliant CD image. If you wish to losen the restrictions to allow more readable filenames etc you can add additional options as listed below.
| Option | Meaning |
| -L | allow dot files |
| -d | omit trailing period from files that do not have a period |
| -l | allow full 31 character filenames |
| -allow-lowercase | allow lower case filenames |
| -allow-multidot | allow more than one dot in filenames |
| -N | omit version number in filenames |
Multi Session CD
The above single session CD cannot have further files added to it even if it is a rewritable CD, it can only be blanked an overwritten.
To be able to add additional files to a CD at a later date you need to write the CD in multi session mode as follows
- First session
mkisofs -r -o /scratch/mycdimage.iso my_directory_of_files
cdrecord -v -multi -data /scratch/mycdimage.iso - Additional sessions
mkisofs -r -C `cdrecord -msinfo` -o /scratch/mycdimage.iso my_directory_of_files
cdrecord -v -multi -data /scratch/mycdimage.isoThe -C `cdrecord -msinfo` runs the cdrecord command on the CD to locate the end of the current session and hence location for to the start of the next session.
- Last sessions
mkisofs -r -C `cdrecord -msinfo` -o /scratch/mycdimage.iso my_directory_of_files
cdrecord -v -data /scratch/mycdimage.isoWhen writing the last session the CD is closed off by omitting the -multi option.
Copying a data CD
To copy a data CD (assuming you only have one CD drive) you need to first copy the raw data off the CD with a command of the form
dd if=/dev/cdrom of=/scratch/mycdimage.iso
and then write it back to the new CD with
cdrecord -v -data /scratch/mycdimage.iso
as before.
DVD writing
To write a DVD you can either first create an ISO image as above for a CD and then burn it to the DVD using the growisofs command or you can perform both steps at once.
An example command to create a DVD ISO image and burn it straight to DVD is
growisofs -R -Z /dev/dvd my_directory_of_files
Using the groisofs command it is possible to then append additional files to the DVD with
growisofs -R -M /dev/dvd another_directory_of_files 