Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Linux+ Certification Bible.pdf
Скачиваний:
46
Добавлен:
15.03.2015
Размер:
3.78 Mб
Скачать

514

Part VI Troubleshooting and Maintaining System Hardware

If the file contains an invalid entry, it won’t mount the file system properly. In this case, you will need to edit the /etc/fstab file to fix the error. If this happens with the root partition, you will have to mount it manually, and then make your change to the file.

Any error messages that occur during the boot process are logged to the file

/var/log/dmesg.

Using System Status Tools

6.5 Use system status tools to examine system resources and statuses (e.g., fsck, setserial)

You have a number of tools at your disposal for help in troubleshooting your Linux system. These tools allow you to check the status of your hardware and software, and can greatly shorten the troubleshooting process by narrowing down the source of the problem.

File System Check

6.8 Use disk utilities to solve file system problems (e.g., mount, umount)

Depending on the type of boot process problem that you are troubleshooting, you may have to use special utilities to rescue your disk from a corrupted state. Disk data can be easily damaged by file systems that are not unmounted properly — a situation that can result from a power failure or improper shutdown. You can use these special utilities to quickly analyze and fix any inconsistencies in your file systems, thus restoring them to a normal state.

The most important utility you will need for repairing your Linux system is the fsck utility. This program will check your file system for errors and inconsistencies, and can repair them while it is running.

During a normal shutdown procedure, the file systems are properly closed and unmounted before the machine shuts down. If Linux is improperly shut down because of a power failure or because someone uses the on/off switch, the file systems and disk tables may become corrupt. If your file systems are not unmounted properly, fsck will run automatically at the next boot-up to attempt to fix the errors.

fsck is actually a front-end for more specific utilities. For example, Linux uses the ext2 file system, so when fsck is invoked to check this system, it will run the e2fsck utility.

Chapter 17 Troubleshooting the Boot Process

515

The following is the syntax for using the fsck command:

fsck [option] device

For example, if you need to run a file system check on /dev/hda1, use this command:

fsck /dev/hda1

The file system must be unmounted in order to run properly. If the file system was mounted and in use, the contents would be constantly changing and fsck would not be able to examine it properly.

If you need to check the root file system, you must either boot into the system by using a boot floppy disk or run the check in single-user mode.

Options for fsck

You can use a number of options with fsck, which is shown in Table 17-2.

Table 17-2

fsck Options

sSerialize fsck operations. Use this option if you want to check multiple file systems in order.

-t Specifies the type of file system to be checked (for example, ext2).

-A Walk through the /etc/fstab file and try to check all file systems in one run. -C Display completion/progress bars.

-N Don’t execute, just show what would be done if the file system check was run. -T Don’t show the title on startup.

-V Produce verbose output, including all file system-specific commands that are executed.

-a Automatically repair the file system without any questions. -r Interactively repair the file system (ask for confirmations).

You may receive a message stating that you must manually run fsck on a file system. If you receive this message, fsck was unable to fix the problem normally. Therefore, you must use a more specific utility. You may also receive an error message stating that the superblock is damaged and could not be read. The superblock is a special area that contains pointers to where the file systems are located on the disk. In this case, you have to specifically use the e2fsck and pass the superblock parameter manually.

e2fsck -b 8193 /dev/hda

516

Part VI Troubleshooting and Maintaining System Hardware

Know how to properly use the fsck command to check file systems.

System Resource Commands

The following are some commands that can help you examine your current resources and where they are being used. This is helpful when troubleshooting your system for resource conflicts, or over use. For example, if one of your processes uses too much memory, it may cause other programs or even your whole system to crash.

Top

You can use the top command to check current resource usage. This utility lets you see on one screen how much memory and CPU resources you are currently using. This screen also displays the resource usage by each program and process. Figure 17-1 shows a screenshot from the output of the top command.

Figure 17-1: Output of top command

If one of your processes is not working properly, it may be using up all of your available CPU and memory resources. If this is the case, kill the process and restart it.

Setserial

You can use the setserial utility to obtain information about your serial port resource usage, such as IRQ and IO addresses. A device uses an IRQ (Interrupt Request) to signal the CPU that it has a request that needs processing. The IO

Chapter 17 Troubleshooting the Boot Process

517

address is a special address reserved in memory for a particular device. If any of these addresses conflict with another device, it may disable them or cause erratic behavior. You can use setserial to examine your serial ports and ensure that no conflicts exist.

By default, the Linux system loads serial ports COM1-4 with the default and IRQ values. You can change these settings if you need to set up a device with a nonstandard IRQ or IO address.

For example, the following is the default configuration of the first serial port, COM1:

setserial /dev/ttyS0

The output should look something like this:

ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4

The four default com ports are listed in Table 17-3.

Table 17-3

Linux Serial Port Settings

PORT

Device

IRQ

IO Address

 

 

 

 

COM1

ttyS0

4

0x03f8

 

 

 

 

COM2

ttyS1

3

0x02f8

 

 

 

 

COM3

ttyS2

4

0x03e8

 

 

 

 

COM4

ttyS3

3

0x02e8

 

 

 

 

If you need to set a serial port with different settings to be compatible with a certain device, you can use the setserial command to change them. Just remember that the device needs to have the settings or it won’t work.

For example, if you need to set COM4 to a different IRQ, you can use the following command:

setserial /dev/ttyS3 irq 10

This command sets the COM4 serial port to use IRQ 10.

Соседние файлы в предмете Операционные системы