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.02.
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 is less than, equal to, or greater than, the second.
boot_files_older_than
my @to_archive = boot_files_older_than(
$oldest_kernel_to_keep, qr/$targets_regex/o
);
Find and return a list of all files in the /boot directory that meet BOTH of the following criteria:
file is considered to be kernel version-specific
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 a sensible format) will be selected (criterion #1). The second parameter is a regex that is used to identify "target" files -- only files matching this regex 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 tarred and gzipped archive of files in arrayref specified by FILES. If DELETE_ORIG is a true value, the original files will be deleted.
PROGRAM: DESCRIPTION
Finds kernel-version-specific files in /boot and prompts for the newest kernel version whose /boot files are to be kept. The older /boot files are compressed and archived. The bootloader menu is updated accordingly.
To run as a program, invoke the module itself from the command line, e.g.:
$ perl `perldoc -l Linux::BootCleanup` --help
PROGRAM: SYNOPSIS
Linux::BootCleanup modulino: 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. Configuration files are
supported and should contain the same arguments used on the command line
(one per line separated by newlines). The config file should be named after
the executable, preceded by a dot.
options:
--help show this help menu
--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>
--delete-originals delete originals after archiving
--dry-run pretend, but take no actions
--verbose be noisy
NOTES:
* 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 arguments not supplied via the command line are prompted for interactively.
PROGRAM: 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.
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
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.
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.
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