Online Book Reader

Home Category

Running Linux, 5th Edition - Matthias Kalle Dalheimer [41]

By Root 1074 0
in /etc/rc.d or wherever your distribution stores its configuration files. This tells the mount command to mount any filesystems listed in the file /etc/fstab. Therefore, in order to have your filesystems mounted automatically at boot time, you need to include them in /etc/fstab. (Of course, you could always mount the filesystems by hand, using the mount command after booting, but this is unnecessary work.)

Here is a sample /etc/fstab file, shortened by omitting the last two parameters in each line, which are optional and not relevant to the discussion here. In this example, the root filesystem is on /dev/hda1, the /home filesystem is on /dev/hdb2, and the swap partition is on /dev/hdb1:

# /etc/fstab

# device directory type options

#

/dev/hda1 / ext3 defaults

/dev/hdb2 /home ext3 defaults

/dev/hdb1 none swap sw

/proc /proc proc defaults

The lines beginning with the "#" character are comments. Also, you'll notice an additional entry for /proc. /proc is a "virtual filesystem" used to gather process information by commands such as ps.

As you can see, /etc/fstab consists of a series of lines. The first field of each line is the device name of the partition, such as /dev/hda1. The second field is the mount point--the directory where the filesystem is mounted. The third field is the type; Linux ext3fs filesystems should use ext3 for this field. swap should be used for swap partitions. The fourth field is for mounting options. You should use defaults in this field for filesystems and sw for swap partitions.

Using this example as a model, you should be able to add entries for any filesystems not already listed in the /etc/fstab file.

How do we add entries to the file? The easiest way is to edit the file, as root, using an editor such as vi or Emacs. We won't get into the use of text editors here. vi and Emacs are both covered in Chapter 19.

After editing the file, you'll need to issue the command:

# /bin/mount -a

or reboot for the changes to take effect.

If you're stuck at this point, don't be alarmed. We suggest that Unix novices do some reading on basic Unix usage and system administration. We offer a lot of introductory material in upcoming chapters, and most of the remainder of this book is going to assume familiarity with these basics, so don't say we didn't warn you.

Shutting Down the System

You should never reboot or shut down your Linux system by pressing the reset switch or simply turning off the power. As with most Unix systems, Linux caches disk writes in memory. Therefore, if you suddenly reboot the system without shutting down cleanly, you can corrupt the data on your drives. Note, however, that the "Vulcan nerve pinch" (pressing Ctrl-Alt-Delete in unison) is generally safe: the kernel traps the key sequence and passes it to the init process, which, in turn, initiates a clean shutdown of the system (or whatever it is configured to do in this case; see "init, inittab, and rc Files" in Chapter 17). Your system configuration might reserve the Ctrl-Alt-Delete for the system administrator so that normal users cannot shut down the network server that the whole department depends upon. To set permissions for this keystroke combination, create a file called /etc/shutdown.allow that lists the names of all the users who are allowed to shut down the machine.

The easiest way to shut down the system is with the shutdown command. As an example, to shut down and reboot the system immediately, use the following command as root:

# shutdown -r now

This will cleanly reboot your system. The manual page for shutdown describes the other available command-line arguments. Instead of now, you can also specify when the system should be shut down. Most distributions also provide halt, which calls shutdown now. Some distributions also provide poweroff, which actually shuts down the computer and turns it off. Whether it works depends on the hardware and the BIOS (which must support APM or ACPI), not on Linux.

* * *

[*] A side note: on a Windows 95/98/ME system, the user is always the equivalent of a root

Return Main Page Previous Page Next Page

®Online Book Reader