Section 28.3. Objective 3: Software and Kernel Configuration


28.3. Objective 3: Software and Kernel Configuration

In the Level 1 Exams, you were prepared to compile kernels and install software to be used with your hardware, including using various hardware-specific tools. For this objective, you are expected to use these tools and kernel options for special hard drive applications, such as Logical Volume Manager (LVM).

28.3.1. hdparm

This command can find a lot of information about your hard drives beyond the more familiar fdisk output. Specifically, hdparm can provide this type of information:

 # hdparm /dev/hda /dev/hda:  multcount    = 16 (on)  IO_support   =  0 (default 16-bit)  unmaskirq    =  0 (off)  using_dma    =  1 (on)  keepsettings =  0 (off)  readonly     =  0 (off)  readahead    =  8 (on)  geometry     = 9729/255/63, sectors = 156301488, start = 0 # hdparm -i /dev/hda /dev/hda:  Model=ST380013AS, FwRev=3.05, SerialNo=3JV2WAWB  Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }  RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4  BuffType=unknown, BuffSize=8192kB, MaxMultSect=16, MultSect=16  CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=156301488  IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}  PIO modes:  pio0 pio1 pio2 pio3 pio4  DMA modes:  mdma0 mdma1 mdma2  UDMA modes: udma0 udma1 *udma2  AdvancedPM=no WriteCache=enabled  Drive conforms to: ATA/ATAPI-6 T13 1410D revision 2:  * signifies the current active mode 

All this can be useful to troubleshoot and/or tune IDE disks. The most important thing for I/O performance is not to use PIO (programmed I/O) modes . To use PIO, the kernel must run in a loop, fetching 1 byte at a time from the disk. This is how IDE disks used to work originally, but it's not at all effective, and even the fastest Pentium 4 gets bogged down with this kind of I/O.

The next line, DMA modes, lists the original DMA modes supported by IDE disks. These are quite a bit faster, and you will probably find that CD-ROMs and DVD drives support only these modes. UDMA modes are "Ultra" DMA, which is very fast DMA. In general, you want to be the furthest down and to the right on these three lines. But beware: the BIOS and drives usually default these to the fastest mode that is commonly supported. If you set one of these the wrong way, you may well end up breaking things and massively corrupting the filesystem. The one thing that's quite safe to do is enable using_dma.

In the first listing, you can see that using_dma is already on. In the second listing, you can see that udma2 is the active DMA mode. Since this is the highest mode the drive supports, you can't do much better.

Using DMA is the default in all recent kernels, including the ones used in distributions. If you roll your own kernels, you should make sure that you configure it correctly. In 2.4 kernel configurations, there is a top-level selection called "ATA/IDE/MDM/RLL support." Select it, enable "ATA/IDE/MFM/RLL support," and then select "IDE, ATA and ATAPI Block devices." Here you will need to find and enable support for the IDE chipset or chipsets you have. Then, under "PCI IDE chipset support," you will find "Use PCI DMA by default when available." This should be safe to enable, In fact, it would have been the default were there not some systems using an old chipset called VIA VP2.


Syntax

 hdparm [flags] [device] 


Description

The hdparm command configures Linux ATA/IDE driver hard disk ioctls. It can both view and set hard disk parameters. There are many options available.


Frequently used options


-a

Get or set the sector count for filesystem read-ahead. -a disables or enables the read-ahead feature. The default is on.


-Bnum

Set APM (Advanced Power Management) features. A low num value sets higher power management, whereas a high num value delivers better performance. The num range is 0 to 255; 255 disables APM on the drive.


-c [num]

Query or enable IDE 32-bit I/O support. num can be 0, 1, or 3; 0 disables 32-bit I/O support, 1 enables support, and 3 enables support with a special sync sequence.


-d [0|1]

Get or set the using_dma flag.


-g

Display drive geometry.


-i

Display identification information.


-k

Get or set the keep_settings_over_reset flag.


-mnum

Get or set the sector count for multiple sector I/O. A num value of 0 disables this feature. Most drives support 2, 4, 8, 16, or 32 sectors. Your drive manufacturer will often recommend the optimal setting.


-r [0|1]

Get (1) or set (0) the read-only flag.


-S

Set the standby (spindown) timeout.


-u [0|1]

Get (1) or set (0) the interrupt-unmask flag.


-v

Display all settings, except -i.


-y

Force an IDE drive to immediately go into low power consumption mode.


-z

Force a kernel reread of the partition table.

28.3.2. tune2fs

tune2fs was a subject on the Level 1 Exams and was also mentioned in the previous chapter. When it comes to how ext2 and ext3 filesystems interact with the kernel, there are a couple of options worth mentioning.


-e error_behavior

This parameter decides how the kernel should react when it finds errors in the specific filesystem that tune2fs is applied to. The possible behaviors are as follows (repeated from Chapter 27).


continue

Just ignore the error. A read or write error should be reported to any application that tries to access that part of the filesystem.


remount-ro

Remount the filesystem read only. This prevents escalating or dominoing failures that could otherwise result when a filesystem that cannot be written is remounted. After you set this option, applications that subsequently try to write to the filesystem will fail with write errors, but the data already on disk is secure.


panic

Cause a kernel panic and halt the system. This is a very obvious failure mode that is certain to get noticed. In the two previous failure modes, errors are more subtle and the problems might not be noticed right away.


-mreserved_block_percentage

When a filesystem begins to fill up, a normal user will be barred from filling the filesystem completely up. The reason for this is that a completely full filesystem will suffer bad fragmentation, which should be avoided for performance reasons. Also, if the root filesystem is 100% full, the machine may become unbootable. A full disk also usually means that users with home directories on that partition may find it impossible to log in.

Only the root user is allowed to exceed this limit. The margin of free disk allows the boot process to work and the root user to log in. But if the root user fills up the disk, you're in trouble.

Now that disks are becoming huge, the default percentage of 5% may be overly large, and something more like 1% may be suitable for some filesystems.


-uuser

Change the user that can use reserved blocks. The user is stored as a numerical UID.


-ggroup

Set a group that can use reserved blocks. This is stored as a numerical GID in the filesystem.


-O [^]mount_option ...

Set the filesystem's mount options. This is supported only by kernels from 2.4.20 on. Any values given at mount time, or in /etc/fstab, will override these options. An option prefixed with ^ is cleared instead of set. Many options can be given, separated by commas.


-s [0|1]

Enable or disable the sparse superblock feature. On huge filesystems, enabling this can save quite a bit of space because fewer backup superblocks are used, freeing up space. After setting or resetting this feature, you must run e2fsck on the filesystem to make it valid again.

28.3.3. Supporting IDE CD Burners

As mentioned in Chapter 27, when CD burners first appeared on the market, they were all SCSI. The standard Linux tool to burn CDs, cdrecord, was written to support SCSI burners. Later, cheaper IDE burners appeared. Rather than fixing cdrecord to understand IDE burning, the SCSI-IDE translation module was made to bridge the gap. This is important for CD burning in 2.4 kernels; it is no longer needed in 2.6.

This module is available in all stock distribution kernels now; CD burners are very common hardware these days. But if you roll your own 2.4 kernel, enable it like this: In the kernel configuration, select and enable "SCSI support," then enable support for SCSI CD-ROMs and SCSI generic. Back at the main level, select "ATA/IDE/MFM/RLL support," then "IDE, ATA and ATAPI Block devices." Finally, find and enable "SCSI emulation support."

After building this kernel, configure the modules in /etc/modules (Red Hat/Fedora) or /etc/modules.d/local (Debian) as described in the section "Burning with IDE CD burners" in Chapter 27. This procedure sets up the system so that it loads the ide-scsi module before loading the SCSI CD device module or the SCSI "generic" driver. As described in the same section, put the option hdc=ide-scsi onto the kernel command line in your boot loader. If you now reboot, you should be all set to burn CDs.

28.3.4. Logical Volume Manager (LVM)

Logical volume management is one of the most powerful disk management techniques available on Linux. It allows you to free yourself from having to think about physical volumes and, instead, think about the volumes you need in a logical fashion. Almost. It is very seductive, but you should keep in mind that disks do fail, and if you do not plan for this in your LVM management, you may lose a lot of data. What LVM does allow you to forget about entirely is all the messing about with partitions that people traditionally do when finding space for user data and system files. LVM volumes can be resized at will, so if your filesystem can be resized (and most can) you gain a great degree of freedom in managing your disk resources.

The basic way to set up LVM is to set aside some disks or disk partitions. The sequence of utilities used is as follows:

  1. Put the disks or partitions under LVM management by using pvcreate. This puts the physical volume under LVM control.

  2. Once you have one or more physical volumes, run vgcreate to create a volume group, combining one or more of the physical disks into one large virtual disk.

  3. On this volume group, you can create one or more logical volumes using lvcreate. These logical volumes can be used for filesystems, for swap, or directly by applications such as databases.

Each of these building blocks has programs to display their properties, called pvdisplay, vgdisplay, and lvdisplay. There are multiple other commands to change different properties of LVM objects. And most of them have a lot of options, most of which you will never use or miss. Because there are so many commands, we'll go through them by task instead of by command and show only typical option usage. The following is ordered more or less as follows: creating, displaying, changing, and destroying LVM objects.

28.3.4.1. Initializing a disk or partition

You can initialize either a whole disk or a partition for LVM use as follows:

 # pvcreate /dev/hdc pvcreate -- physical volume "/dev/hdc" successfully created 

If you're initializing a whole disk that has a partition table on it, pvcreate will back off, and not even --force will talk it into initializing it. You must destroy the partition table, as shown in the following procedure. The procedure is very dangerous because there are no sanity checks. Only you can stop yourself from doing something wrong, such as destroying the contents of a disk, with the dd command.

 # pvcreate /dev/hdc pvcreate -- device "/dev/hdc" has a partition table pvcreate [-d|--debug] [-f[f]|--force [--force]] [-h|--help]         [-s|--size PhysicalVolumeSize[kKmMgGtT]] [-y|--yes] [-v|--verbose]         [--version] PhysicalVolume [PhysicalVolume...] # dd if=/dev/zero of=/dev/hdc bs=1k count=1 1+0 records in 1+0 records out # blockdev --rereadpt /dev/hdc# pvcreate /dev/hdc pvcreate -- physical volume "/dev/hdc" successfully created 


Tip: When booting, the partition check will print hdc: unknown partition table. This is nothing to worry about, because there is no partition table on a disk that is all devoted to LVM.

When you create a physical volume in a partition, the partition needs to be the right type. You can find out the type though fdisk (which is normally used to change partitions, but can also be used just to view information about them):

 # pvcreate /dev/hdc1 pvcreate -- invalid partition type 0x83 for "/dev/hdc1" (must be 0x8e) # fdisk /dev/hdc ...Command (m for help): t Partition number (1-4): 1 Hex code (type L to list codes): 8e Changed system type of partition 1 to 8e (Linux LVM) Command (m for help): w The partition table has been altered! Calling ioctl( ) to re-read partition table. Syncing disks. # pvcreate /dev/hdc1 pvcreate -- physical volume "/dev/hdc1" successfully created 

28.3.4.2. Creating a volume group

A volume group occupies one or more physical volumes. A volume group, in turn, contains one or more logical volumes. A logical volume can contain several physical volumes, but it becomes more vulnerable that way, because two disks fail twice as often as one disk. Therefore, although it is seductive to pool all your physical disks into one volume group, it may also cause a lot of trouble if a disk fails.

You can create a volume group called Disk2 on /dev/hdc this way:

 # vgcreate Disk2 /dev/hdc vgcreate -- INFO: using default physical extent size 4 MB vgcreate -- INFO: maximum logical volume size is 255.99 Gigabyte vgcreate -- doing automatic backup of volume group "Disk2" vgcreate -- volume group "Disk2" successfully created and activated 

A "physical extent" can be likened to a partition. When managing volume group space, LVM allocates space in units of extents.

28.3.4.3. Making a logical volume

Logical volumes can be used for filesystems, swap, or perhaps databases that want disk devices without file systems. To create a logical volume named accounting on Disk2, enter:

 # lvcreate -L5G -n accounting Disk2 lvcreate -- doing automatic backup of "Disk2" lvcreate -- logical volume "/dev/Disk2/accounting" successfully created 

The size number can be postfixed by K, M, G, or T, meaning kilobytes, megabytes, gigabytes, or terabytes, respectively. The default, if no unit is given, is megabytes. If the volume is going to be used for database use and speed is important, you may want to ensure that it is allocated contiguously in one block by supplying -C y on the command line. Note that this may make it harder to resize the volume later if there are other logical volumes in the volume group and they use space around the volume you want to resize.

Instead of the -L option, you can use the -l option and give the size of the logical volume in logical extents, which are usually the same size as physical extents. If you obtain the number of available physical extents in a volume group with vgdisplay (discussed later), this makes it easier to specify such things as making the volume half the size of the volume group or filling the whole volume group.

Now the volume is ready to be used as if it were a disk device. As the last line of the previous output shows, the path of the device is in the form /dev/volume_group/logical_volume.

28.3.4.4. Displaying physical volume properties

Perhaps the most interesting property of a physical volume is how many free physical extents it contains. The following pvdisplay output shows that the PE size of the device is 4 MB, and that 23,497 PEs are free. There is a lot of space, and if you want to move the contents through the pvmove command (shown later), there is little to move.

 # pvdisplay /dev/hdc --- Physical volume --- PV Name               /dev/hdc VG Name               Disk2 PV Size               111.79 GB [234441648 secs] / NOT usable 4.25 MB [LVM: 239 KB] PV#                   1 PV Status             available Allocatable           yes Cur LV                3 PE Size (KByte)       4096 Total PE              28617 Free PE               23497 Allocated PE          5120 PV UUID               BSN7hI-u8DU-vT4g-WUdv-aaYZ-ECNK-5f65vm 

28.3.4.5. Displaying volume group properties

The vgdisplay command shows all available volume groups on the system. The following display shows several interesting parameters: the maximum logical volume size (MAX LV), how many logical volumes it houses (Cur LV), the number of physical volumes it consists of (Cur PV), and how many physical extents you still have at your disposal (Free PE).

If invoked with the -v option, vgdisplay also lists all the logical volumes and physical volumes associated with each disk group.

 # vgdisplay -v Disk2 --- Volume group --- VG Name               Disk2 VG Access             read/write VG Status             available/resizable VG #                  2 MAX LV                256 Cur LV                1 Open LV               0 MAX LV Size           255.99 GB Max PV                256 Cur PV                1 Act PV                1 VG Size               111.79 GB PE Size               4 MB Total PE              28617 Alloc PE / Size       1280 / 5 GB Free  PE / Size       27337 / 106.79 GB VG UUID               K7L9Gz-foUx-gw7W-5Iy9-Sfoo-8d4C-EtZqQT --- Logical volume --- LV Name                /dev/Disk2/accounting VG Name                Disk2 LV Write Access        read/write LV Status              available LV #                   1 # open                 0 LV Size                5 GB Current LE             1280 Allocated LE           1280 Allocation             next free Read ahead sectors     1024 Block device           58:7 --- Physical volumes --- PV Name (#)           /dev/hdc (1) PV Status             available / allocatable Total PE / Free PE    28617 / 27337 

28.3.4.6. Displaying logical volume properties

The default lvdisplay displays exactly the same information as vgdisplay -v. With the -v option, however, lvdisplay shows something you can't get through vgdisplay: which physical volumes the logical volume occupies and some additional, less interesting I/O statistics.

 # lvdisplay -v /dev/Disk2/accounting --- Logical volume --- LV Name                /dev/Disk2/accounting VG Name                Disk2 LV Write Access        read/write LV Status              available LV #                   1 # open                 0 LV Size                5 GB Current LE             1280 Allocated LE           1280 Allocation             next free Read ahead sectors     1024 Block device           58:7    --- Distribution of logical volume on 1 physical volume  ---    PV Name                  PE on PV     reads      writes    /dev/hdc                 1280         1          82369    --- logical volume i/o statistic ---    1 reads  82369 writes    --- Logical extents ---    LE    PV                        PE     reads      writes    00000 /dev/hdc                  00000  1          2086    00001 /dev/hdc                  00001  0          0 ...    01278 /dev/hdc                  01278  0          0    01279 /dev/hdc                  01279  0          64 

28.3.4.7. Listing disks and volume groups

The pvscan command scans your system's disks to find physical volumes. It also shows the available volume groups as a side effect, as well as the free and occupied space in them.

 # pvscan pvscan -- reading all physical volumes (this may take a while...) pvscan -- inactive PV "/dev/hdc"   is in no VG  [111.79 GB] pvscan -- ACTIVE   PV "/dev/hda11" of VG "Disk0" [43.77 GB / 584 MB free] pvscan -- ACTIVE   PV "/dev/hdb"   of VG "Disk1" [232.88 GB / 0 free] pvscan -- total: 3 [388.45 GB]/in use:2 [276.66 GB]/in no VG: 1 [111.79 GB] 

28.3.4.8. Adding disks to a volume group

To add /dev/hdd (previously formatted as a physical volume using pvcreate) to Disk2, enter:

 # vgextend Disk2 /dev/hdd vgextend -- INFO: maximum logical volume size is 255.99 Gigabyte vgextend -- doing automatic backup of volume group "Disk2" vgextend -- volume group "Disk2" successfully extended 

28.3.4.9. Removing a disk from a volume group

If the physical disk has one or more logical volumes, their contents must be moved before it is removed from its volume group. The move is done with pvmove, as shown in the following example:

 # pvmove /dev/hdc pvmove -- moving physical extents in active volume group "Disk2" pvmove -- WARNING: moving of active logical volumes may cause data loss!pvmove -- do you want to continue? [y/n] y pvmove -- 249 extents of physical volume "/dev/hdc" successfully moved # vgreduce dev /dev/hdc vgreduce -- doing automatic backup of volume group "Disk2" vgreduce -- volume group "Disk2" successfully reduced by physical volume: vgreduce -- /dev/hdc 

If the destination is not specified as a parameter, the data in /dev/hdc will be moved to free extents on other physical volumes. It is recommended that you make a backup of your data before doing this. Once the physical volume is clear, it can be removed from the volume group with vgreduce, and then the disk can be removed safely.

If you have a new disk in the system where you want to move the data from the old disk, add the new disk to the volume group and enter pmove olddisk newdisk.

28.3.4.10. Expanding a logical volume

Expanding a volume with lvextend is quite easy, providing one of the major advantages of LVM. No preparation is needed, so long as you have enough space to perform the expansion. After the logical volume has been expanded, the filesystem on it can be enlarged or the application using it can be told of the change. Note that not all software using disk partitions directly is capable of taking advantage of a resized partition. You may want to just create a new logical volume for these applications and add in the application. An ext2 (or ext3) filesystem is resized with resize2fs, which is capable of finding the size of the underlying device itself.

 # lvextend -L +5G /dev/Disk2/accounting lvextend -- extending logical volume "/dev/Disk2/accounting" to 10 GB lvextend -- doing automatic backup of volume group "Disk2" lvextend -- logical volume "/dev/Disk2/accounting" successfully extended # resize2fs /dev/Disk2/accounting resize2fs 1.34 (25-Jul-2003) Resizing the filesystem on /dev/Disk2/accounting to 2621440 (4k) blocks. The filesystem on /dev/Disk2/accounting is now 2621440 blocks long. 

The -L option to lvextend accepts, as its parameter, either the absolute size or size changes prefixed with + or -. Units of K, M, G, and T can be used, just as with lvcreate.

28.3.4.11. Shrinking a logical volume

Shrinking a logical volume is just like expanding it, except that the application or filesystem must use less space before you can shrink the volume. Even fewer applications support shrinking their disk usage than growing it. The trick with shrinking a logical volume is to shrink it no more than its contents, because otherwise you will destroy some of the contents. In the case of an ext2 filesystem, it can be convenient to take a two-step approach: first shrink the filesystem a tad too much, then shrink the logical volume, and then resize the filesystem again, letting resize2fs figure out the right size. So, to shrink the accounting filesystem from 5 GB to 4 GB, run something like this:

 # resize2fs /dev/Disk2/accounting 3993M resize2fs 1.34 (25-Jul-2003) Resizing the filesystem on /dev/Disk2/accounting to 1022208 (4k) blocks. The filesystem on /dev/Disk2/accounting is now 1022208 blocks long. # lvreduce -L -1G /dev/Disk2/accounting lvreduce -- WARNING: reducing active logical volume to 4 GB lvreduce -- THIS MAY DESTROY YOUR DATA (filesystem etc.) lvreduce -- do you really want to reduce "/dev/Disk2/accounting"? [y/n]: y lvreduce -- doing automatic backup of volume group "Disk2" lvreduce -- logical volume "/dev/Disk2/accounting" successfully reduced # resize2fs /dev/Disk2/accounting resize2fs 1.34 (25-Jul-2003) Resizing the filesystem on /dev/Disk2/accounting to 1048576 (4k) blocks. The filesystem on /dev/Disk2/accounting is now 1048576 blocks long. 

28.3.4.12. Removing a logical volume

Of course, you should be sure that there is no data you want on the volume before removing it. Then enter a command such as:

 # lvremove /dev/Disk2/accounting lvremove -- do you really want to remove "/dev/Disk2/accounting"? [y/n]: y lvremove -- doing automatic backup of volume group "Disk2" lvremove -- logical volume "/dev/Disk2/accounting" successfully removed 

28.3.4.13. Removing a volume group

Once a volume group has no logical volumes left, removing the volume group is a two-step process. First deactivate the group with vgchange, then remove it with vgremove:

 # vgchange -a n Disk2 vgchange -- volume group "Disk2" successfully deactivated # vgremove Disk2 vgremove -- volume group "Disk2" successfully removed 

The -a option to vgchange changes the availability of a volume group. Use n to make it unavailable and y to make it available again.

28.3.4.14. Removing a physical volume

Actually, this section has a trick subject. There is no way to remove a physical volume. Once pvscan shows the volume to be "inactive" or pvdisplay alleges that the volume is a "new physical volume," the disk or partition may be reused for whatever purpose.

 # pvscan pvscan -- reading all physical volumes (this may take a while...) pvscan -- inactive PV "/dev/hdc"   is in no VG  [111.79 GB] pvscan -- ACTIVE   PV "/dev/hda11" of VG "Disk0" [43.77 GB / 584 MB free] pvscan -- ACTIVE   PV "/dev/hdb"   of VG "Disk1" [232.88 GB / 0 free] pvscan -- total:3 [388.45 GB]/in use: 2 [276.66 GB]/in no VG: 1 [111.79 GB] # pvdisplay /dev/hdc pvdisplay -- "/dev/hdc" is a new physical volume of 111.79 GB 

28.3.4.15. Starting and stopping LVM

If you are in a recovery or troubleshooting situation and LVM needs to be manipulated by hand, there are two commands. vgscan shows you the status of the logical volumes on the system, and vgchange changes their status:

 # vgscan vgscan -- reading all physical volumes (this may take a while...) vgscan -- found inactive volume group "Disk2" vgscan -- found inactive volume group "Disk0" vgscan -- found inactive volume group "Disk1" vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created vgscan -- WARNING: This program does not do a VGDA backup of your volume groups # vgchange -ay vgchange -- volume group "Disk0" successfully activated vgchange -- volume group "Disk1" successfully activated vgchange -- volume group "Disk2" successfully activated 

Stopping LVM is even easier:

 # vgchange -an vgchange -- volume group "Disk0" successfully deactivated vgchange -- volume group "Disk1" successfully deactivated vgchange -- volume group "Disk2" successfully deactivated 

28.3.4.16. LVM snapshots

LVM supports a very useful feature called snapshots. With this, you can freeze a volume while it's being used and then, for example, make a backup of the frozen copy. This should get you a consistent backup image.

If you back up a partition while it's being usedunless you use special toolsthe backup will in many cases be unusable. Most filesystem backup tools have no problems with the filesystem itself, but if the accounting software continues to write onto its files while they are being backed up, the backup will probably be useless. Most software needs to be shut down during backups for this reason. An LVM snapshot is a good and fast alternative:

 # lvcreate -L100M -s -n accbackup /dev/Disk2/accounting lvcreate -- WARNING: the snapshot will be automatically disabled once it gets full lvcreate -- INFO: using default snapshot chunk size of 64 KB for "/dev/Disk2/accbackup" lvcreate -- doing automatic backup of "Disk2" lvcreate -- logical volume "/dev/Disk2/accbackup" successfully created   ... do backup of /dev/Disk2/accbackup ... # lvremove /dev/Disk2/accbackup lvremove -- do you really want to remove "/dev/Disk2/accbackup"? [y/n]: y lvremove -- doing automatic backup of volume group "Disk2" lvremove -- logical volume "/dev/Disk2/accbackup" successfully removed 

The snapshot stays unchanged because, even while the original is being updated, LVM backs up the unchanged data, a strategy called "copy on write." This has two implications. First, it means that if there are few changes to the original, the snapshot will use very little space. Second, making a snapshot is very fastbut as long as you keep the snapshot around, there is a extra read/write operation every time a block is updated. The previous command creates a reserve of 100 MB for all changes made during the snapshot, and if more space is needed for the changed data, the snapshot will be deactivated.

A snapshot can be regarded as a backup. If you make a snapshot every night, you can have several days of backups online and accessible at all times. The snapshot is read-only and can't be made read/write, so you must copy the whole snapshot to a fresh volume before it's usable as a ordinary filesystem.

28.3.5. Runtime Kernel Configuration

Changing a system's properties without having to reboot it, or even take down services, is one of the holy grails of system administration. Linux has many shortcomings in this area, but the kernel itself is fairly reconfigurable. Not only does runtime kernel module loading and unloading allow you to change properties and hardware support in a system, but the Linux kernel has two ways of changing quite a few configuration parameters. The /proc/sys files and sysctl command are different interfaces that let you manipulate these parameters. Both require procfs support in the kernel.

If you have a look at /proc/sys, you might find, depending on your hardware and kernel options, 300 or more different files that tune the kernel in some way. If you take one of the filenames found there, say, fs/file-max, you can transform it into a variable name for sysctl by simply exchanging the slashes with dots. Thus, fs/file-max becomes fs.file-max. If you do a long listing (ls -l) of fs/file-max, you'll see it has read/write permissions for root, which means that it can be changed. Most of the files in /proc/sys are writable. A small demonstration of the interfaces follows:

 # cd /proc/sys# sysctl fs.file-max fs.file-max = 92000 # cat fs/file-max 92000 # echo 92100 > fs/file-max # cat fs/file-max 92100 # sysctl -w fs.file-max=92000 fs.file-max = 92000 

The filesystem limits in particular are self-tuning. They grow as the system needs them to. Other parameters that you yourself need to tune will be mentioned in relevant documentation. For example, if you configure a firewall's parameters, such as net.ipv4.ip_forward and net.ipv4.conf.default.rp_filter, the iptables documentation lists the parameters and discusses the appropriate settings. If you struggle with a specific problem that the kernel seems to be imposing on you, you can find what can be changed through:

 # find /proc/sys -type f -perm -0600 -print /proc/sys/abi/fake_utsname /proc/sys/abi/trace ... 


Syntax

 sysctl [-n] [-e] variable ... sysctl [-n] [-e] -w variable=value ... sysctl [-n] [-e] -p [ filename ] 


Description

The sysctl command displays and changes kernel parameters. The variables available are the same as found in /proc/sys and vary depending on kernel configuration, the modules loaded, and the hardware on the system.

The first syntax is used to show a kernel parameter. Several parameter names can be given on the command line. The second form changes the given parameters. The third form loads a file with settings. If no filename is given, the default is /etc/sysctl.conf, and this file is loaded on boot by most distributions.


Examples

The following is a default /etc/sysctl.conf file from a Red Hat Fedora Core system.

 # Controls IP packet forwarding net.ipv4.ip_forward = 0 # Controls source route verification net.ipv4.conf.default.rp_filter = 1 # Controls the System Request debugging functionality of the kernel kernel.sysrq = 0 # Controls whether core dumps will append the PID to the core filename. # Useful for debugging multithreaded applications. kernel.core_uses_pid = 1 

The commands to get and set kernel.core_uses_pid are as follows:

 # sysctl -w kernel.core_uses_pid=1 kernel.core_uses_pid = 1 # sysctl kernel.core_uses_pid kernel.core_uses_pid = 1 

Note that the syntax in the file is different from the command line. In the file, there must be spaces around the equals sign, whereas on the command line there must be none.



LPI Linux Certification in a Nutshell
LPI Linux Certification in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596005288
EAN: 2147483647
Year: 2004
Pages: 257

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net