[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ 16 ] [ 17 ] [ 18 ] [ A ] [ B ] [ C ] [ D ] [ next ]


Debian Tutorial (Obsolete Documentation)
Chapter 13 - Using disks


13.1 Concepts

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. [17] 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 near 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.


13.2 mount and /etc/fstab

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.


13.2.1 Mounting a filesystem

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: [18]

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.


13.2.2 Example: Mounting a CD-ROM

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.

  1. su

    If you haven't already, you need to either log in as root or gain root privileges with the su (super user) command. If you use su, enter the root password when prompted.

  1. ls /cdrom

    See what's in the /cdrom directory before you start. If you don't have a /cdrom directory, you may have to make one using mkdir /cdrom.

  1. mount

    Typing simply mount with no arguments lists the currently mounted filesystems.

  1. mount -t iso9660 CD device /cdrom

    For this command, you should substitute the name of your CD-ROM device for CD device in the above command line. If you aren't sure, /dev/cdrom is a good guess since the install process should have created this symbolic link on the system. If that fails, try the different IDE devices: /dev/hdc, etc. You should see a message like:

         mount: block device /dev/hdc is write-protected, mounting read-only
    

    The -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 manual 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.

  1. ls /cdrom

    Confirm that /cdrom now contains whatever is on the CD in your drive.

  1. mount

    Look at the list of filesystems again, noticing that your CD drive is now mounted.

  1. umount /cdrom

    This unmounts the CD. It's now safe to remove the CD from the drive. Notice that the command is umount with no "n", even though it's used to unmount the filesystem.

  1. exit

    Don't leave yourself logged on as root. Log out immediately, just to be safe.


13.2.3 /etc/fstab: Automating the mount process

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,noauto   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 by proc is a special filesystem . 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. It's worth noting that the swap partition isn't exactly a filesystem in the sence that it does not contain files and directories, but is just used by the Linux kernel as secondary memory. However, for historical reasons, the swap partitions are still listed in the same file than the filesystems.

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):

async and sync

Do I/O synchronously or asynchronously. Synchronous I/O writes changes to files immediately, while asynchronous I/O may keep data in buffers and write it later, for efficiency reasons.

ro and rw

Mount the filesystem read-only or read-write. If you don't need to make any changes to the filesystem, it's a good idea to mount it read-only so you don't accidentally mess something up. Also, read-only devices (such as CD-ROM drives and floppy disks with write protection tabs) should be mounted read-only.

auto and noauto

When the system boots, or whenever you type mount -a, mount tries to mount all the filesystems listed in /etc/fstab. If you don't want it to automatically mount a filesystem, you should use the noauto option. It's probably a good idea to use noauto with removable media such as floppy disks, because there may or may not be a disk in the drive. You'll want to mount these filesystems manually after you put in a disk.

dev and nodev

Use or ignore device files on this filesystem. You might use nodev if you mount the root directory of another system on your system --- you don't want your system to try to use the devices on the other machine.

user and nouser

Permit or forbid ordinary users to mount the filesystem. nouser means that only root can mount the filesystem. This is the normal arrangement. You might use the user option to access the floppy drive without having to be root.

exec and noexec

Allow or do not allow the execution of files on this filesystem. Probably you won't need these options.

suid and nosuid

Allow or do not allow the suid bit to take effect. Probably you won't need these options.

defaults

Equivalent to: rw, dev, suid, exec, auto, nouser, async. You can specify defaults followed by other options to override specific aspects of defaults.


13.2.4 Removable disks (floppies, Zip disks, etc.)

Add the following lines to your /etc/fstab file:

     /dev/sda1  /mnt/zip  ext2    noauto,user     0 0
     /dev/sda4  /mnt/dos  msdos   noauto,user     0 0

From then on, you'll be able to mount the DOS formated Zip disks with the command mount /mnt/dos, and Linux formated Zip disks with the command mount /mnt/zip. [20]


13.3 PPP


13.3.1 Introduction

If you connect to the internet over a phone line, you'll want to use PPP (Point-To-Point Protocol). This is the standard connection method offered by ISPs (Internet Service Providers). In addition to using PPP to dial your ISP, you can have your computer listen for incoming connections --- this lets you dial your computer from a remote location.

This section is a quick-start no-frills guide to setting up PPP on Debian. If it turns out that you need more details, see the excellent PPP HOWTO from the Linux Documentation Project. The HOWTO goes into much more detail if you're interested or have unique needs.


13.3.2 Preparation

Configuring PPP on GNU/Linux is straightforward once you have all the information you'll need. Debian makes things even easier with its simple configuration tools.

Before you start, be sure you have all the information provided by your ISP. This might include:

Next, you'll want to investigate your hardware setup: whether your modem works with GNU/Linux, and which serial port it's connected to.

There's a simple rule which determines whether your modem will work. If it's a "WinModem" or "host-based modem", it won't work. These modems are cheap because they have very little functionality, and require the computer to make up for their shortcomings. Unfortunately, this means they are complex to program, and manufacturers generally do not make the specifications available for developers.

If you have a modem with its own on-board circuitry, you should have no trouble at all.

On GNU/Linux systems, the serial ports are referred to as /dev/ttyS0, /dev/ttyS1, and so on. Your modem is almost certainly connected to either port 0 or port 1, equivalent to COM1: and COM2: under Windows. If you don't know which your modem is connected to, wvdialconf can try to detect it (see below); otherwise just try both and see which works.

If you want to talk to your modem or dial your ISP without using PPP, you can use the minicom program. You may need to install the minicom package before the program is available.


13.3.3 The Easy Way: wvdial

The simplest way to get PPP running is with the wvdial program. It makes some reasonable guesses and tries to set things up for you. If it works, you're in luck. If it guesses wrong, you'll have to do things manually.

Be sure you have the following packages installed:

When you install the wvdial package, you may be given the opportunity to configure it. Otherwise, to set up wvdial, follow these simple steps:

  1. Login as root, using su as described in an earlier chapter

  1. touch /etc/wvdial.conf

    touch will create an empty file if the file doesn't exist --- the configuration program requires an existing file.

  1. wvdialconf /etc/wvdial.conf

    This means you're creating a configuration file, /etc/wvdial.conf

  1. Answer any questions that appear on the screen. wvdialconf will also scan for your modem and tell you which serial port it's on; you may want to make a note of this for future reference.

  1. /etc/wvdial.conf should look something like this now:

         [Dialer Defaults]
         Modem = /dev/ttyS1
         Baud = 115200
         Init1 = ATZ
         Init2 = ATQ0 V1 E1 S0=0 S11=55 +FCLASS=0
         ; Phone = [Target Phone Number]
         ; Username = [Your Login Name]
         ; Password = [Your Password]
    

    Just replace the information in brackets with the proper information and remove the semicolons from the beginning of those lines and you're done! Here is what a completed wvdial.conf file should look like:

         [Dialer Defaults]
         Modem = /dev/ttyS1
         Baud = 115200
         Init1 = ATZ
         Init2 = ATQ0 V1 E1 S0=0 S11=55 +FCLASS=0        
         Phone = 5551212
         Username = beavis
         Password = password
    

Now that wvdial.conf is set up, to connect to your ISP just type wvdial. If it doesn't work, you'll probably have to delve into manual PPP configuration.


13.3.4 Doing It Manually

This still isn't all that difficult, though it's slightly harder than wvdial. The quick-and-easy summary: type pppconfig as root, answer the questions, then type pon to log on, and poff to log off. We'll go into a little more detail though.


[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ 16 ] [ 17 ] [ 18 ] [ A ] [ B ] [ C ] [ D ] [ next ]


Debian Tutorial (Obsolete Documentation)

29 Dezember 2009

Havoc Pennington [email protected]