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

Chapter 8 User Environment Settings 263

The user environment is constantly changing, and as a result, systems require the addition of new hardware, the expansion of current hardware, and

software changes. The system maintainer may be required to perform several configurations when adding any piece of hardware. This job may include the reconfiguration of swap space, printers, configuration files, hardware profiles, and other environmental variables. The system maintainer may also need to reconfigure LILO and the kernel modules — or even upgrade the kernel. After these tasks have been completed, several of the critical system files may also need to be reconfigured. In this chapter, you will learn how to handle the addition of hardware or software by reconfiguring the user environments.

Adding Hardware

3.9 Install and configure add-in hardware (e.g., monitors, modems, network interfaces, scanners)

When maintaining or deploying systems, new hardware is often required to support the users’ needs. This new hardware may consist of additional memory, video cards, network cards or modems, I/O controllers, printers, and many others. These devices must be configured for the Linux system in order to use them correctly, which often requires the physical installation or connection of the device.

When installing or connecting any device to a system, you must follow the installation instructions for the device. These instructions usually include antistatic guidelines and directions for proper grounding and environmental conditions; you should make sure that you have followed these instructions before attempting any hardware change. If you don’t follow the instructions, you may not see any immediate, adverse effects; the damage, however, has been done and the system will show the effects of the damage in time.

For example, monitors are often installed and connected while the system is still powered on. This can be a big mistake because voltage will damage the system if you experience an accidental misconnection of the cables. The same warning goes for printers and most other external devices. Hot plug devices, such as USB, are an exception to this rule because they don’t require the system to be powered down for installation. High-end servers usually offer hot plug and swap devices, including hard drives and even PCI cards, that require special consideration. These systems, however, are beyond the basic configuration of a Linux system. Maintaining a Linux system often requires the installation and configuration of new devices, but Linux provides the tools to perform these configurations.

264 Part III Configuration

Memory

3.7 Identify when swap space needs to be increased

3.12 Edit basic configuration files (e.g., BASH files, inittab, fstab)

The addition of memory to a system is often required to meet the demanding needs of new applications. In most cases, Linux handles the addition of memory quite well; however, you do need to make several considerations. Memory is often added to increase the memory available to programs, which can render the swap file inadequate for the amount of installed memory. The recommended size of the swap file is twice the available RAM. To reconfigure the Linux swap partition created during installation or to create a swap partition after installation, you should edit the /etc/fstab file accordingly, or use the many disk partitioning tools available to you such as fdisk. If you want to adjust the size of a swap partition, you must disable the current swap partition, which you can do by editing the fstab file (this controls the file systems that are used on boot). The following is an example of the fstab file:

/dev/hda1 / reiserfs defaults 1 1 none /dev/pts devpts mode=0620 0 0

/dev/hdb5 /home reiserfs exec,dev,suid,rw,usrquota 1 2 /mnt/cdrom /mnt/cdrom supermount fs=iso9660,dev=/dev/cdrom 0 0 /mnt/floppy /mnt/floppy supermount fs=vfat,dev=/dev/fd0 0 0 none /proc proc defaults 0 0

/dev/hda6 /usr reiserfs defaults 1 2 /dev/hda7 /var reiserfs defaults 1 2 /dev/hda5 swap swap defaults 0 0

To disable the swap file, simply remark the entry:

#/dev/hda5 swap swap defaults 0 0

VI

You can use any editor to edit the file, but you may want to consider vi, which is a very good, basic text editor. You will find that vi is very simple to use, and even though vi has many commands, you can perform most simple editing using the commands shown in Table 8-1.

Chapter 8 User Environment Settings 265

Table 8-1

VI Commands

Switch

Task performed

Notes

aEnter insert mode. The characters typed in

will be inserted after the current cursor position

iEnter insert mode. The characters typed in will be inserted before the current cursor position

r

Replace one character under the cursor

 

 

 

 

u

Undo the last change to the file

 

 

 

 

x

Delete character under the cursor

 

 

 

 

<esc>

Used to exit editing mode

This key is in the upper left

 

 

corner on the keyboard

 

 

 

:

Used to prepare to exit and save

Used after <esc>

 

 

 

w

Writes the file when used after :

Used after <esc>

 

 

 

q

Quits vi when used after :

Used after <esc>

 

 

 

!

Forces command ignoring other factors

Used to overwrite files or

 

 

quit without saving

 

 

 

1.Open the file in the vi editor to begin editing the fstab file. Use the command vi /etc/fstab or by moving to the directory where fstab is contained (usually /etc and using the command vi fstab).

2.After you have opened the file, edit the file by using the arrow keys to move down the file to the line containing the swap file information.

3.Comment out the relevant line configuring the swap using the i command and adding a semicolon (;) to the beginning of the line.

4.The changes must be saved, so use the <esc> keystroke to exit editing mode. Then, : to move to prepare to save and w to write or save the file.

5.After you have saved the file, you can exit the file by using : and q.

266 Part III Configuration

This action disables the mounting of the swap partition at boot and allows the configuration of a larger swap partition. To boot the system without the swap partition enabled, simply reboot the system after editing the fstab file. Be aware, though, that system performance may decrease drastically upon a reboot. At this point, you can create a new swap partition by using any of the hard disk (HD) partitioning tools discussed in Chapters 4 and 5; cfdisk is usually the preferred tool. The typical cfdisk screen looks like this.

 

 

cfdisk 2.10s

 

 

 

Disk Drive: /dev/hda

 

 

 

Size: 2111864832 bytes

 

 

 

Heads: 128

Sectors per Track: 63

Cylinders: 511

Name

Flags

Part Type FS Type

[Label]

Size (MB)

--------------------------------------------------------------------------

hda1

Boot

Primary

Linux

260.12

hda5

 

Logical

Linux swap

417.01

hda6

 

Logical

Linux

957.88

hda7

 

Logical

Linux

474.81

[Bootable] [ Delete ] [ Help ] [Maximize] [ Print ]

[ Quit ] [ Type ] [ Units ] [ Write ]

Toggle bootable flag of the current partition

Swap

In the cfdisk output, the swap partition is listed even though it has been disabled; you can verify this by using the mount command to view mounted systems after rebooting the system. Use the cfdisk program to delete the current swap partition and to create a new swap partition. Your system may not have extra free space, however, so you must back up, resize, and then restore another file system in order to create a larger swap partition. After you have created the larger swap partition, you must activate it with mkswap /dev/<partition>. Therefore, in the preceding example, <partition> would be hda5, and then swapon /dev/<partition>. Then, you can mount the swap by entering the line into fstab, /dev/hda5 swap swap defaults 0 0, or — if the partition is the same as before — by removing the comment from the line and rebooting the system.

The creation of a new swap partition is most often made on a second hard drive to improve system performance.

After you have successfully created swap space, the system will have improved performance and better reliability.

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