Chapter 4. Diskettes and CD-ROMs

Using diskettes and CD-ROMs with Red Hat Linux requires some understanding about removable media. This chapter discusses how to read and write files to and from diskettes, how to format diskettes, and how to read and copy data from a CD-ROM. This chapter also covers using CD-writable and CD-rewritable drives.

Using Diskettes

Diskettes are one of the oldest removable media solutions available for the personal computer (PC). Diskettes are ideal as a portable storage solution used for files that need to be physically moved around. For example, if two PCs are not on the same network, diskettes are a great solution to transfer files from one computer to the other.

Mounting and Unmounting a Diskette

A diskette must be mounted first before it can be used. Insert a diskette into the diskette drive and type mount /mnt/floppy/ at a shell prompt.

The diskette drive activity light should blink as the diskette's file system is mounted to the /mnt/floppy directory.

You can access the contents of the diskette by changing into that directory with the cd /mnt/floppy/ command.

Alternatively, you can also mount a diskette in the GNOME desktop environment by right-clicking on the desktop and choosing Disks => Floppy. This mounts the diskette and adds a desktop icon which you can double-click to explore the diskette contents in Nautilus.

Now that the diskette has been mounted it is available to be copied from or written to. You can open, save, and copy files to/from it as you would normally do to your hard drive. You can even explore the diskette's contents in Nautilus or Konqueror, as shown in Figure 4-1.

Figure 4-1. Viewing files on a Diskette with Nautilus

When you are done using the diskette, you should unmount it before ejecting it from the drive. To do this, close any applications that may be using files on the diskette or exploring the diskette's contents (like Nautilus or Konqueror), and at a shell prompt type the following command :

umount /mnt/floppy/

If you are using GNOME, unmount the diskette by right-clicking on the icon and choosing Unmount Volume from the menu.

You can now safely eject the diskette from the drive.

Reading MS-DOS formatted Diskettes

If you have an MS-DOS formatted diskette, you can access the files on it using the mtools utility.

mtools offers a wide range of options for working with diskettes, including copying, moving, deleting, and formatting. To read more about mtools, type man mtools at a shell prompt.

For example, to copy a file from an MS-DOS formatted diskette (such as one from a Windows system), type the following command at a shell prompt:

mcopy a:thisfile.txt 

thisfile.txt will be copied from the diskette drive (drive A:) to the directory you were in when you issued the mcopy command. If you are in your home directory, you will find thisfile.txt located there.

If you want to view the contents of an MS-DOS formatted diskette, type mdir at the prompt. You will be shown the contents of the diskette. The directory listing will look familiar to some MS-DOS or Windows users, as it is styled in the MS-DOS dir listing format. For example:
[joe@localhost joe]$ mdir a:
 Volume in drive A has no label
 Volume Serial Number is 0000-0000
Directory for A:/

FOOBAR    TXT      6004 01-01-1999   1:01 
ZZTOP     COM      1533 01-01-1999   1:01 
TAXES99   XLS     26469 01-01-1999   1:01 
THISFILE  TXT       277 01-01-1999   1:01 
COMMAND   COM     93890 01-01-1999   1:01 
        5 files             128 173 bytes
                          1 271 827 bytes free

To change to a subdirectory on the diskette, type the following command at a shell prompt:

	mcd a:subdir

In the above command, subdir is the name of the subdirectory you want to access.

Putting Linux Files on an MS-DOS Diskette

To copy files from a Linux machine to an MS-DOS formatted diskette so that a Windows machine can read it you should format your disk with an MS-DOS (FAT) filesystem, which can be done with a Windows OS or with gfloppy (see the Section called Using gfloppy). Then mount it in Linux as described in the Section called Mounting and Unmounting a Diskette. Copy files using the following command (substituting filename with the name of the file you wish to copy):

cp filename /mnt/floppy

You can then unmount the floppy and eject it from the drive. The new file on the diskette should now be accessible from your Windows machine.

Formatting a Diskette

To use a diskette specifically with Red Hat Linux, you need to format the disk using the ext2 file system. ext2 is one of the file systems supported by Red Hat Linux, and is the default method used for formatting diskettes.


Formatting a diskette will erase all of its contents. Be sure to backup any files that you need before performing any of the following operations on your diskettes.

Once you have created an ext2 file system on the diskette, you can manipulate its contents in the same ways that you manipulate directories and files on your hard drive.

Using gfloppy

In GNOME, go to Main Menu => Programs => Utilities => gfloppy to start gfloppy. In KDE, go to Start Application => Programs => Utilities => gfloppy. From a shell prompt, type /usr/bin/gfloppy. As shown in Figure 4-2, the gfloppy interface is small and has few options. The default settings are sufficient for most users and needs; however, you can format your diskette with an MS-DOS file system type if you desire. You can also choose the density of your floppy disk (if you are not using the usual high density 3.5" 1.44MB diskette. You can also elect to quick format the diskette if it was previously formatted as ext2.

Figure 4-2. gfloppy

Insert a diskette and change the settings to suit your needs; then click Format. The status box will appear on top of the main window, showing you the status of formatting and verifying (see Figure 4-3). When it is complete, you can eject the disk and close gfloppy.

Figure 4-3. gfloppy Status Box

Using KDE Floppy Formatter

Another way to format a diskette for either ext2 or MS-DOS is to use KDE Floppy Formatter. To start the utility, go to Start Application => Utilities => KFloppy (Floppy Formatter). You will be presented with a graphical interface shown in Figure 4-4.

Figure 4-4. KDE Floppy Formatter

Insert a diskette that you wish to format and choose whether you want a Quick Format or Full Format by choosing the appropriate radio button. To check for bad sectors or blocks on the diskette while formatting, choose Verify Integrity in the associated check box.

To begin formatting, click the Format button. A window will pop-up asking if you wish to format the diskette. Click Continue to dismiss this window and begin formatting. A status bar will appear at the bottom of the window showing the status of the format. After the diskette has been formatted, a final window will appear to inform you of a successful format. Click OK, remove the diskette, and click Quit to close the application.

Using mke2fs

The mke2fs command is used to create a Linux ext2 file system on a device such as a hard drive partition or (in this case) a floppy diskette. mke2fs essentially formats the device and creates an empty, Linux-compatible device which can then be used for storing files and data.

Insert your diskette into the drive and issue the following command at a shell prompt:

/sbin/mke2fs /dev/fd0

On Linux systems, /dev/fd0 refers to the first diskette drive. If your computer has more than one floppy disk drive, your primary floppy drive will be /dev/fd0, your second /dev/fd1, and so on.

The mke2fs utility has a number of options. The -c option makes the mke2fs command check the device for bad blocks before creating the file system. The other options are covered in the mke2fs man page.

Once you have created an ext2 file system on the diskette, it is ready to be used with your Red Hat Linux system.