Candidates should be able to configure kernel options to support various hardware devices including UDMA66 drives and IDE CD burners. This objective includes using LVM (Logical Volume Manager) to manage hard disk drives and partitions as well as software tools to interact with hard disk settings.
Revision: $Revision: 1.11 $ ($Date: 2004/03/24 12:50:18 $)
Key files, terms and utilities include:
hdparm |
tune2fs |
/proc/interrupts |
sysctl |
Resources: Impson00; Hubert00; Colligan00; the man pages for the various commands.
The objective names the tune2fs command as one of the
key utilities for this objective. The filesystem optimizing tools are handled in
tune2fs.
In the section called “Kernel Components (2.201.1)” and on, the process to configure and debug
kernels is described. Additional kernel options may be configured by patching
the kernel source code. Normally the kernel's tunable parameters are listed
in the various header files in the source code tree. There is no golden rule
to apply here - you need to read the kernel documentation or may even need to
crawl through the kernel-code to find the information you need. Additionally,
a running kernel can be configured by either using the /proc
filesystem or by using the sysctl command.
Current kernels also support dynamic setting of kernel parameters. The
easiest method to set kernel parameters is by modifying the /proc
filesystem. You can used the echo to set parameters, in the format:
echo "value" > /proc/kernel/parameter
e.g. to activate forwarding:
echo 1 >/proc/sys/net/ipv4/ip_forward
The changes take effect immediately but are lost during reboot.
The /proc/ filesystem can also be queried. To see which
interrupts a system uses, for example you could issue
# cat /proc/interrupts
which generates output that may look like this:
CPU0
0: 16313284 XT-PIC timer
1: 334558 XT-PIC keyboard
2: 0 XT-PIC cascade
7: 26565 XT-PIC 3c589_cs
8: 2 XT-PIC rtc
9: 0 XT-PIC OPL3-SA (MPU401)
10: 4 XT-PIC MSS audio codec
11: 0 XT-PIC usb-uhci
12: 714357 XT-PIC PS/2 Mouse
13: 1 XT-PIC fpu
14: 123824 XT-PIC ide0
15: 7 XT-PIC ide1
NMI: 0
Kernel tuning can be automated by putting the echo commands in
the startup scripts (e.g. /etc/rc.d/rc.local. Some distributions
support the sysctl command and on those systems the initscripts
run sysctl -p on startup. This reads the configuration in the
default configuration file (/etc/sysctl.conf) and sets the
tunable parameters accordingly.
lvm is a logical volume manager for Linux. It enables you to concatenate several physical volumes (hard disks etc.) to a so-called volume groups, forming a storage pool, much like a virtual disk. IDE, SCSI disks, as well as, multiple devices (MD) are supported.
In the ASCII art below, the concepts/terminology used by lvm are sketched. On the right side the names of the commands are shown that can be used to manipulate/create the layer sketched on the left.
Figure 4.1. LVM concepts in ASCII art
+----------------[ Volume Group ]-------------------+
| |
| +-----------------------------------------------+ |
| | filesystem | filesystem | | mkfs
| +-------------------+---------------------------+ |
| | logical volume | logical volume | | lvcreate
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| | | | | | | | |physical extends | | | | | | | | | | vgcreate
+-------------------+---------------+-----------+
| physical volume | | | pvcreate
+-------------------+---------------+-----------+
| partition | | | fdisk (0x8e)
+-------------------+---------------+-----------+
a hard disk, or a partition, e.g. /dev/hda,
/dev/hda6 or /dev/sda.
You should set the partition types of the disk or partition to
0x8e, which is “Linux LVM”.
Partitioning is done using fdisk. Please note that
your version of fdisk may not yet know this type,
so it will be listed as “Unknown”. You can turn any consecutive number
of blocks on a block device into a Physical Volume:
a physical medium with some administrative data added to it. The command pvcreate can be used to add the administration onto the physical medium. The command vgcreate is used to create a volume group, which consists of one or more PV's. A PV that has been grouped in a volume group contains Physical Extents:
Physical Extents are blocks of diskspace, often several megabytes in size. Using the command lvcreate you can assign PEs to a Logical Volume:
A Logical Volume. On a logical volume we can use the command mkfs to get a Filesystem:
ext2, ReiserFS,
NWFS, XFS,
JFX, NTFS etc.
To the linux kernel, there is no difference between a regular partition and a Logical
Volume. A simple mount suffices to be able to use your logical
volume.
Some examples of typical usage of the LVM commandset follow. Initially, you need
to set the partition type for the partitions to use to create logical volumes to
0x8e. Let's assume we have partitions
/dev/hda4 and /dev/hda5, and they are set
to the correct partitioning type. To create a physical volume on both
partitions (i.e. to set up the volume group descriptor) you type (being
the superuser):
# pvcreate /dev/hda4 /dev/hda5
Now we have created two physical volumes. Next, we will create a volume group.
A volume group needs to have a name (we choose volume01).
To create our volume group, using our previously defined physical volumes, type:
# vgcreate volume01 /dev/hda5 /dev/hda4
The previous command line is the most basic form (refer to the manual pages for a list of configurable parameters). This will create an array of physical extents, by default they are 4 Mb in size. Using these extents we can create one or more logical volumes, e.g:
# lvcreate -L 100M volume01
.. this creates a logical volume with a default name choosen by
lvcreate and starts with the string
lvol followed by a digit
-- let's assume lvol0. The logical volume will be
created using the volumegroup volume01. The name of
the devicefile for this volume will be /dev/volume01/lvol0.
Next, we can make a filesystem on the volumegroup, as usual,
using mkfs, e.g. an xfs filesystem:
# mkfs -txfs /dev/volgroup/volname
The resulting filesystem can be mounted as usual:
# mount /dev/volgroup/volname /mnt
One of the nicest features of LVM is the possibility of taking snapshots of volumes. A snapshot is a virtual copy of the volume to enable easy backups. Another interesting feature is striping, which can result in better performance, but also in a higher risk of losing your data.
Most newer CD burners will work with Linux. If the SCSI-version of a particular writer works, the IDE/ATAPI-version will most likely work too and vice versa. Note, however, that IDE/ATAPI writers and writers that use the parallel port require compatibility drivers, which make them appear as if they were real SCSI devices ("everything is SCSI").
In newer Linux kernels (later than 2.6), SCSI-emulation is not needed anymore.
To use IDE burners, you need to activate both IDE and SCSI support in your kernel, and a number of other modules, as listed below:
Description Modulename -------------------------- ---------- Enhanced IDE/MFM/RLL... Y IDE/ATAPI CDROM ide-cd M SCSI hostadaptor emulation ide-scsi M Loopback device loop M SCSI support scsi_mod Y/M SCSI CD-ROM support sr_mod Y/M SCSI generic support sg Y/M ISO 9660 CDROM filesystem iso9660 Y Microsoft Joliet cdrom... joliet M/Y -------------------------- ----------
To use your IDE burner, the modules need to be loaded. This can be done
automatically via the kerneld/kmod
daemons, or you need to insert the modules by hand, using insmod
or modprobe. You might add the following lines to
/etc/conf.modules:
alias scd0 sr_mod # load sr_mod upon access of scd0 alias scsi_hostadaptor ide-scsi # SCSI host adaptor emulation options ide-cd ignore=hdb # if /dev/hdb is your CD-writer
These aliases provide alternate names for the same module and are not essential, but convenient. The options provides a way to make options for module loading permanent, i.e. after you have sucessfully used them with modprobe/insmod.
The disk subsystem of the Linux kernel is very conservative with your data. When not completely sure if a certain disk or controller reliably handles a certain setting (such as using Ultra DMA or IDE Block Mode to transfer more sectors on a single interrupt or 32-bit bus transfers), it will default to the setting least likely to cause data corruption.
The command hdparm can be used to fine-tune your disk-drive. Although this utility is intended primarily for use with (E)IDE hard disk devices, several of the options are also valid (and permitted) for use with SCSI hard disk devices and MFM/RLL hard disks with XT interfaces.
hdparm can be used with many flags that influence it's
behaviour. It is mostly used to set the using_dma flag
(-d) and the 32-bit I/O support
flag (-c) - these two flags can help
improve drive performance enormeously.
DMA (Direct Memory Access) is a technique used by newer (E)IDE drives. Regular IDE drives are interrupt driven. This means that the kernel will receive an interrupt every time a (small) amount of data needs to be transferred from disk to memory. The processor then needs to transfer the data itself. DMA (Direct Memory Access) or UDMA (Ultra DMA, a faster version) works differently: the drive is capable of addressing memory directly, hence can transfer the data into memory itself.
UltraDMA ATA66 drives are commonly used (UDMA66), as are the newer UDMA100 drives. The UDMA66 interface features burst data transfers of up to 66 MB/second, up to 8 IDE devices per system. Other interface speeds are used too: the older 33 MB/second speed (UDMA33) or UDMA100.
Recent kernels (2.4) support DMA. You need to configure the kernel to support special EIDE chipsets to be able to use all features of your controller. For older kernels, you may need to install a patch to the kernel source code first.
You can configure newer kernels (2.4) to activate DMA automatically. For older kernels,
you have to activate it using the hdparm command. Even for newer
kernels, you may want to use hdparm to fine-tune the disk performance,
since, as stated before, the kernel will default to the setting least likely
to cause data corruption. If you are sure about what you are doing, and really
need the extra speed, you can fine-tune the drive using hdparm.
For example, assuming your disk is known as /dev/hdb:
hdparm -X68 /dev/hdb
For older UDMA33 drives, use -X66, for UDMA100
use -X69. You could put a
line in your rc.local file to set this automatically
on (re)boot. The field of (U)DMA drives is moving constantly and fast, therefore
make sure to check the kernel documentation and other references to find out
about the newest developments.
Other flags (see manual page for a complete list) are:
Table 4.3. Common flags for hdparm
-a | set/get the sector count for filesystem read-ahead |
-A | disable/enable read-lookahead |
-C | check power mode status |
-g | display the disks geometry |
-L | lock the door on removable drives (e.g. ZIP) |
-y | force standby mode |
-T | time the drive performance |
-r | set the read-only flag for the device |
-m | set/get count for multiple block IO |
Here is an example of the use of hdparm. IF you have (E)IDE
disk drives, it is often possible to boost your disk-performance by enabling 32 bit
I/0 transfer mode and setting the using_dma flag for that
drive. To try this, put the following line in a bootup script (e.g.
/sbin/init.d/boot.local), assuming the
devicename for the drive is /dev/hda:
hdparm -d1 -c3 /dev/hda
To test how much you gained type:
hdparm -t -T /dev/hda