Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Linux::BootCleanup
Clean up old kernel files in /boot and update bootloader menu entries accordingly

Linux::BootCleanup - Clean up old kernel files in /boot and update bootloader menu entries accordingly



NAME

Linux::BootCleanup - Clean up old kernel files in /boot and update bootloader menu entries accordingly


VERSION

This documentation refers to Linux::BootCleanup version 0.03.


PROGRAM: DESCRIPTION

Given the newest kernel version whose /boot files are to be kept, finds kernel files from older kernel versions in /boot, compresses, and archives them (in .tar.gz format). The system bootloader menu is updated accordingly.

To use the included utility program:


    $ bootcleanup --verbose --dry-run --targets-re='/initrd|system\.map|abi|vmlinuz|config/'

Alternatively, invoke the module itself from the command line, e.g.:


    $ perl `perldoc -l Linux::BootCleanup` --help


PROGRAM: SYNOPSIS


    bootcleanup: archive old kernel files from /boot directory and

    update bootloader menu...

    Without options, interactively prompts for required information.  Can run

    non-interactively if all options are given.  A configuration file named

    '.bootcleanup' is supported and should contain the same arguments used on

    the command line (one per line separated by newlines).

    options:

        --help                 show this help menu

        --dry-run              pretend, but take no actions

        --verbose              be noisy; show what actions will be taken

        --delete-originals     delete originals after archiving

        --bootldr-config =     <path to boot loader configuration file>

        --archive-dest =       <path to dest dir for archive of old files>

        --targets-re =         <regex that all target filenames must match>

        --oldest-to-keep =     <oldest kernel version to keep active>

    ALERT:

        * The "targets" matched by "targets-re" are files under /boot to be

          considered for archiving.  Matching files are archived provided they

          meet remaining criteria.  By default, the targets are files

          containing: system.map, vmlinux, vmlinuz, config, initrd


PROGRAM: REQUIRED ARGUMENTS

None. Any required arguments not supplied via the command line are prompted for interactively.


DIAGNOSTICS

Error: can't opendir: ...
OS Error while trying to open a directory.

Error: cannot add files to archive.
The list of files specified for archival could not be added to the in-memory tar archive. Check to be sure that the files exist.

Error: cannot write tar archive.
The in-memory tar archive could not be written to disk. Check to be sure that the filename you specified can be written.

Error: can't copy '<source filename>' to '<dest filename>'
Failed attempt to copy a file using system 'cp'. Check permissions and path existence.

Error: cannot load system bootloader configuration.
The system bootloader configuration file could not be loaded. See Linu::Bootloader::Detect (http://search.cpan.org/perldoc) for supported bootloaders.


MODULE: FUNCTIONS

normalized_release_num


    $rel = normalized_release_num( $file_from_boot_dir );

Extract a release number from strings expected to contain one. Returns a release number (see VERSION NUMBER FORMAT) or undef if string does not contain anything that looks like a release number.

rel_num_compare


    $sort_order = rel_num_compare( $a, $b );

Compare release numbers (see VERSION NUMBER FORMAT), returning -1, 0, or 1 if the first argument should be considered an earlier, equivalent, or later version number than the second.

If either argument is not in the expected format, returns undef.

boot_files_older_than


    my @to_archive = boot_files_older_than(

        $oldest_kernel_to_keep, qr/$targets_regex/io

    );

Find and return a list of all files in the /boot directory that meet BOTH of the following criteria:

  1. File is considered to be kernel version-specific.

  2. File's version is earlier than a given number.

Only files with version numbers earlier than the version number given by the first parameter (which is assumed to be in VERSION NUMBER FORMAT) will be selected (criterion #1). The second parameter is a regex that is used to identify ``target'' files -- only files matching this regex (a case-insensitive match) meet criterion #2.

run

``main() method'' for running modulino as a command line program. Parses command line options, handles flow of control, interactively getting options not specified on the command line.

remove_bootldr_stanzas


    remove_bootldr_stanzas(

        BOOTLDR_CONF        => $bootloader_menu_filename,

        BACKUP_FILENAME     => "$bootloader_menu.$date",

        OLDEST_REL_TO_KEEP  => $oldest_kernel_to_keep,

        DRY_RUN             => 1,

        VERBOSE             => 1,

    );

Backup the bootloader menu and remove all kernel stanzas that correspond to a kernel with a version number older than the specified oldest version to save.

archive_files


    archive_files(

        ARCHIVE_NAME    => "$archive_dest_dir/$archive_name",

        DELETE_ORIG     => $delete_originals,

        FILES           => \@confirmed_for_archival,

        DRY_RUN         => $dry_run,

    );

Create a .tar.gz archive of files in arrayref specified by FILES. If DELETE_ORIG is a true value, the original files will be deleted.


VERSION NUMBER FORMAT

Valid version numbers used by this module are of the form 'a.b...c-X.Y...Z' (e.g. 2.6.17-12).


DEPENDENCIES

POSIX

Exporter

ExtUtils::Installed

Pod::Usage >= 1.33

Getopt::Long

Getopt::ArgvFile

Archive::Tar

IO::Prompt

Linux::Bootloader

Linux::Bootloader::Detect


INCOMPATIBILITIES

This modulino is intended to be used on Linux platforms only.


BUGS AND LIMITATIONS

No known bugs. Please report problems to Karl Erisman (kerisman@cpan.org) Patches are welcome.


SEE ALSO

Linux::Bootloader (http://search.cpan.org/perldoc)


ACKNOWLEDGEMENTS

Thanks to the Perl Monks, O'Reilly, Stonehenge, various authors of learning resources, and last but not least, to CPAN authors everywhere!


AUTHOR

Karl Erisman (kerisman@cpan.org)


LICENSE AND COPYRIGHT

Copyright (c) 2007 Karl Erisman (kerisman@cpan.org), Murray State University. All rights reserved.

This is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic (http://search.cpan.org/perldoc).

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


SCRIPT CATEGORIES

UNIX/System_Administration

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy