It's probably a good idea to explain a little theory before discussing the mechanics of using disks. In particular, the concept of a filesystem. [12] This is confusing, because it has several meanings.
Any physical device you wish to use for storing files must have at least one filesystem on it. This means a filesystem in the second sense - a hierarchy of files and directories, along with information about them. Of course, any filesystem has a type, so the third sense will come into play as well. If you have more than one filesystem on a single device, each filesystem can have a different type --- for example, you might have both a DOS partition and a Linux partition on your hard disk.
It's important to distinguish the filesystem from the low-level format of the disk. In the DOS and Macintosh worlds, the filesystem is called the high-level format. When you format a disk using one of those operating systems, generally you both perform a low-level format and create a file system (high-level format). On GNU and Unix systems, one generally says simply "format" to mean low-level format, and "making a filesystem" to mean high-level format.
Formatting has to do with the particulars of the physical device, such as the exact physical location of your data on a floppy disk (on the edge or in the center of the disk for example). The filesystem is the level of organization you have to worry about --- names of directories and files, their sizes, etc.
This section describes how to mount a floppy or Zip disk, the /dev directory, and distributing the directory tree over multiple physical devices or partitions.
On a GNU/Linux system there's no necessary correspondence between directories and physical devices, as there is in Windows where each drive has its own directory tree beginning with a letter (such as C:\).
Instead, each physical device such as a hard disk or floppy disk has one or more filesystems on it. In order to make a filesystem accessible, it's assigned to a particular directory in another filesystem. To avoid circularity, the root filesystem (which contains the root directory /) is not contained by any other filesystem --- you have access to it automatically when you boot Debian.
A directory in one filesystem which contains another filesystem is known as a mount point. A mount point is a directory in a first filesystem on one device (such as your hard disk) which "contains" a second filesystem, perhaps on another device (such as a floppy disk). To access a filesystem, you must mount it at some mount point.
So, for example, you might mount a CD at the mount point /cdrom. This means that if you look in the directory /cdrom, you'll see the contents of the CD. The /cdrom directory itself is actually on your hard disk. For all practical purposes the contents of the CD become a part of the root filesystem, and when typing commands and using programs it doesn't make any difference what the actual physical location of the files is. You could have created a directory on your hard disk called /cdrom, and put some files in it, and everything would behave in exactly the same way. Once you mount a filesystem, there's no need to pay any attention to physical devices.
However, before mounting a filesystem, or to actually create a filesystem on a disk that doesn't have one yet, it's necessary to refer to the devices themselves. All devices have names, and these are located in the /dev directory. If you type ls /dev now, you'll see a pretty lengthy list of every possible device you could have on your Debian system.
Possible devices include: [13]
To mount a filesystem, we want to tell Linux to associate whatever filesystem it finds on a particular device with a particular mount point. In the process, we might have to tell Linux what kind of filesystem to look for.
As a simple demonstration, we'll go through mounting a CD-ROM, such as the one you may have used to install Debian. You'll need to be root to do this, so be careful; whenever you're root you have the power to mess up the whole system, rather than just your own files. Also, these commands assume there's a CD in your drive; you should put one in the drive now.
mount: block device /dev/hdc is write-protected, mounting read-onlyThe -t option specifies the type of the filesystem, in this case iso9660. Most CDs are iso9660. The next argument is the name of the device to mount, and the final argument is the mount point. There are many other arguments to mount; see the man page for details. Once a CD is mounted, you may find that your drive tray will not open. You must unmount the CD before removing it.
The file /etc/fstab (it stands for "file system table") contains descriptions of filesystems that you mount often. These filesystems can then be mounted with a shorter command, such as mount /cdrom. You can also configure filesystems to mount automatically when the system boots. You'll probably want to mount all of your hard disk filesystems when you boot.
Look at this file now, by typing more /etc/fstab. It will have two or more entries that were configured automatically when you installed the system. It probably looks something like this:
# /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump > <pass> /dev/hda1 / ext2 defaults 0 1 /dev/hda3 none swap sw 0 0 proc /proc proc defaults 0 0 /dev/hda5 /tmp ext2 defaults 0 2 /dev/hda6 /home ext2 defaults 0 2 /dev/hda7 /usr ext2 defaults 0 2 /dev/hdc /cdrom iso9660 ro 0 0 /dev/fd0 /floppy auto noauto,sync 0 0
The first column lists the device the filesystem resides on. The second lists the mount point, the third the filesystem type. The line beginning proc is a special filesystem explained in FIXME xref. Notice that the swap partition (/dev/hda3 in the example) has no mount point, so the mount point column contains none.
The last three columns may require some explanation.
The fifth column is used by the dump utility to decide when to back up the filesystem. In most cases you can put 0 here.
The sixth column is used by fsck to decide in what order to check filesystems when you boot the system. The root filesystem should have a 1 in this field, filesystems which don't need to be checked (such as the swap partition) should have a 0, and all other filesystems should have a 2. FIXME: cross ref to fsck, also, is the swap partition really a filesystem?
Column four contains one or more options to use when mounting the filesystem. Here's a brief summary (some of these probably won't make much sense yet --- they're here for future reference):
How to use them - setting things up so you can access them nicely from userspace.
FIXME I'm actually not sure how to write this. What's in fstab on a default installation? Should we do the manual su root thing, or one of those EZ floppy mounting packages? Perhaps do something with group permissions? Or just the user option in fstab?
How to configure it, just the basics