There are two ways to manage devices under Linux: the DOS way and the UNIX way. Take your pick.
Most Linux distributions include the Mtools suite, a set of commands that are perfectly equivalent to their DOS counterpart, but start with an `m': i.e.,
mmd, and so on. They can even preserve long file names, but not file permissions. If you configure Mtools editing a file called /etc/mtools.conf (a sample is provided in the distribution), you can also access the DOS/Win partition, the CD--ROM, and the Zip drive. To format a fresh disk though, the
mformat command won't do. As root, you'll have to issue this command beforehand:
You can't access files on the floppy with a command like, say,
less a:file.txt! This is the disadvantage of the DOS way of accessing disks.
UNIX has a different way to handle devices. There are no separate volumes like A: or C:; a disk, be it a floppy or whatever, becomes part of the local file system through an operation called ``mounting''. When you're done using the disk, before extracting it you must ``unmount'' it.
Physically formatting a disk is one thing, making a file system on it is another. The DOS command
FORMAT A: does both things, but under Linux there are separate commands. To format a floppy, see above; to create a file system:
# mkfs -t ext2 -c /dev/fd0H1440
You can use
vfat (recommended) or other formats instead of
ext2. Once the disk is prepared, mount it with the command
# mount -t ext2 /dev/fd0 /mnt
specifying the right file system if you don't use
ext2. Now you can address the files in the floppy using
/mnt instead of A: or B:. Examples:
DOS Linux --------------------------------------------------------------------- C:\GUIDO>DIR A: $ ls /mnt C:\GUIDO>COPY A:*.* $ cp /mnt/* . C:\GUIDO>COPY *.ZIP A: $ cp *.zip /mnt C:\GUIDO>EDIT A:FILE.TXT $ jstar /mnt/file.txt C:\GUIDO>A: $ cd /mnt A:> _ /mnt/$ _
When you've finished, before extracting the disk you must unmount it with the command
# umount /mnt
Obviously, you have to
mkfs only unformatted disks, not previously used ones. If you want to use the drive B:, refer to
fd1 instead of
fd0 in the examples above.
Needless to say, what applies to floppies also applies to other devices; for instance, you may want to mount another hard disk or a CD--ROM drive. Here's how to mount the CD--ROM:
# mount -t iso9660 /dev/cdrom /mnt
This was the ``official'' way to mount your disks, but there's a trick in store. Since it's a bit of a nuisance having to be root to mount a floppy or a CD--ROM, every user can be allowed to mount them this way:
# mkdir /mnt/floppy ; mkdir /mnt/cdrom # chmod 777 /mnt/floppy /mnt/cd* # # make sure that the CD-ROM device is right # chmod 666 /dev/hdb ; chmod 666 /dev/fd*
/dev/cdrom /mnt/cdrom iso9660 ro,user,noauto 0 0 /dev/fd0 /mnt/floppy vfat user,noauto 0 0
Now, to mount a DOS floppy and a CD--ROM:
$ mount /mnt/floppy $ mount /mnt/cdrom
/mnt/floppy and /mnt/cdrom can now be accessed by every user. Remember that allowing everyone to mount disks this way is a gaping security hole, if you care.
Two useful commands are
df, which gives information on the mounted file systems, and
du dirname which reports the disk space consumed by the directory.
There are several packages to help you, but the very least you can do for a multi-volume backup is (as root):
# tar -M -cvf /dev/fd0H1440 dir_to_backup/
Make sure to have a formatted floppy in the drive, and several more ready. To restore your stuff, insert the first floppy in the drive and do:
# tar -M -xpvf /dev/fd0H1440