Saturday, April 25, 2009

Using floppy disks and CDROMs

Accessing Removable Media

Floppy Disks

There are two completely different ways to access a floppy disk:


By mounting it.

Run 'mount -t msdos /dev/fd0 /mnt/floppy' (but check that the directory /mnt/floppy exists first).

After mounting it, the disk is accessible through the directory /mnt/floppy and the usual unix commands will work in that directory (eg. cat, cp, rm, mv). This will work for other disk formats too (eg. Linux ext2, minix, etc if you use '-t ext2' instead of '-t msdos').

After you finish working with the disk (BEFORE ejecting it) you MUST unmount it with 'umount /mnt/floppy'. Note that you cannot unmount a disk if it is in use (that even includes being cd'ed into the mounted directory).

You can (by default) only mount/unmount a disk if you are root. If you want to be able to do this as any user, you need to add a line such as this to the file /etc/fstab:

/dev/fd0 /mnt/floppy msdos noauto,user,exec 0 0

After adding that line, any user can mount or unmount the floppy by typing 'mount /mnt/floppy' and 'umount /mnt/floppy' respectively.


To access the 'B:' drive, use /dev/fd1 instead of /dev/fd0

The choice of /mnt/floppy is only a convention; you can pick a different directory if you prefer. The only requirement is that the directory must exist and not be in use.

For further information, see mount(8) and fstab(5) (ie. type 'man mount' or 'man fstab').

By using the 'mtools' set of programs.

Without mounting a disk, you can manipulate an MSDOS disk by using commands such as:

mdir a:
mcopy file a:
mcopy a:file
mdel a:file


To perform the above commands, the user needs to have the permissions to access the floppy device /dev/fd0. To give everyone on the system read and write permissions to the floppy disk, type the command: 'chmod 666 /dev/fd0' when logged in as root.

For further information, see mtools(1) (ie. type 'man mtools').


Presuming that your kernel already supports your CDROM drive, using a CDROM drive is essentially the same as mounting and accessing a floppy drive (so read and understand that section first), with the following differences:


CDROMs use the iso9660 filesystem type instead of msdos.

The customary directory for mounting a CDROM is /mnt/cdrom.

A different device name to /dev/fd0 will be used. Some of the more common device names are:
* /dev/scd0 (SCSI CDROM drive)
* /dev/hda, /dev/hdb, /dev/hdc, etc (IDE CDROM drive)
* /dev/sbpcd (Old SoundBlaster/Panasonic CDROM interface type)

The kernel will display the device name of the CDROM drive when it boots up. To see those messages again, type 'dmesg'.

There may be a link from /dev/cdrom to the real device name. For these purposes, use the real device name.

CDROMs are read-only, so the 'ro' option should be supplied to the 'mount' command.

As an example, here is how to mount a CDROM in a SCSI CDROM drive:

mount -t iso9660 -o ro /dev/scd0 /mnt/cdrom

To allow any user to mount/unmount CDROMs, the line to place in /etc/fstab would be:

/dev/scd0 /mnt/cdrom iso9660 noauto,user,exec,ro 0 0

With the above line added, users can type 'mount /mnt/cdrom/' or 'umount /mnt/cdrom' to mount/umount the CDROM

No comments: