# lilo-uuid-diskid - convert boot and root options to diskid
# and uuid in /etc/lilo.conf
#
-# Copyright 2010-2011 Joachim Wiedorn <ad_debian at joonet.de>
+# Copyright 2010-2014 Joachim Wiedorn <joodevel at joonet.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
#---- global variables
my $prog = $0;
$prog =~ s#.*/##;
-my $version = "0.3";
+my $version = "0.4";
#---- parameter check
our $opt_h = 0;
#---- other variables
our $liloconf = "/etc/lilo.conf";
-our $liloconfold = '';
+our $liloconfold = $liloconf . ".old";
+our $liloconfnew = $liloconf . ".new";
our $fstabconf = "/etc/fstab";
our $idpath = "/dev/disk/by-id";
our $uuidpath = "/dev/disk/by-uuid";
}
if (-f $liloconf) {
- $liloconfold = $liloconf . "_old";
+ $liloconfold = $liloconf . ".old";
+ $liloconfnew = $liloconf . ".new";
$exit = convert_lilo_conf();
}
else {
- print "cannot open $liloconf: file not found!\n";
+ print "E: cannot open $liloconf: file not found!\n";
$exit = 1;
}
return $exit;
# at first read lilo.conf and search for 'boot'
my $ok = 0;
- open(MYFH, "<$liloconf") or die ("cannot open $liloconf: $!");
+ open(MYFH, "<$liloconf") or die ("E: cannot open $liloconf: $!");
@sellines = grep(/^#?boot/, readline(MYFH));
close(MYFH);
write_boot_option();
}
else {
- if($opt_v) { print "cannot open $boot_id: link does not exist!\n"; }
+ if($opt_v) { print "E: cannot open $boot_id: link does not exist!\n"; }
$exit = 1;
}
}
}
}
else {
- print "cannot use $liloconf: uncomplete configuration!\n";
+ print "E: cannot use $liloconf: uncomplete configuration!\n";
$exit = 1;
}
# found only ^#boot in lilo.conf, then /etc/fstab is needed
if (-f $fstabconf) {
if($opt_v) {
- print "no boot option in $liloconf: selecting from $fstabconf\n";
+ print "W: no boot option in $liloconf: selecting from $fstabconf\n";
}
$boot_disk = read_fstab($fstabconf);
}
else {
- print "no boot option in $liloconf and no file $fstabconf found!\n";
+ print "E: no boot option in $liloconf and no file $fstabconf found!\n";
$exit = 1;
}
}
if($boot_disk =~ /$idpath/
or $boot_disk =~ /$uuidpath/
or $boot_disk =~ /$labpath/) {
- print "boot option is already updated to $boot_disk\n";
+ print "Boot option is already updated to $boot_disk\n";
$bootready = 1; $exit = 1;
}
else {
- if($opt_v) { print "convert boot option $boot_disk into new ID\n"; }
+ if($opt_v) { print "Convert boot option $boot_disk into new ID\n"; }
# is it a block device name ?
$_part = $boot_disk;
}
}
else {
- if($opt_v) { print "cannot read $boot_disk: link does not exist!\n"; }
+ if($opt_v) { print "E: cannot read $boot_disk: link does not exist!\n"; }
$exit = 1;
}
return $exit;
# check if root device exist / also for raid volume
if (-b $root_disk) {
- if($opt_v) { print "convert root option $root_disk into new UUID\n"; }
+ if($opt_v) { print "Convert root option $root_disk into new UUID\n"; }
$root_id = find_id_link($root_disk,$uuidpath);
if (not -l "$uuidpath/$root_id") { $exit = 1; }
}
$root_link =~ s{^LABEL=}{/dev/disk/by-label/};
$root_link =~ s{^UUID=}{/dev/disk/by-uuid/};
if (not -l $root_link) {
- if($opt_v) { print "cannot check $root_link: link does not exist!\n"; }
+ if($opt_v) { print "W: cannot check $root_link: link does not exist!\n"; }
}
}
return $exit;
my $newdevid = '';
my $ok = 0;
- opendir(MYDH, "$path_id") or die("cannot open $path_id: $! \n");
+ opendir(MYDH, "$path_id") or die("E: cannot open $path_id: $! \n");
@sellinks = grep(!/\-part\d\d?$/, grep(!/^\.\.?$/, readdir(MYDH)));
@sellinks = sort(@sellinks);
closedir(MYDH);
}
}
- if($opt_v and not $ok) { print "$olddev not converted: link not useful\n\n"; }
+ if($opt_v and not $ok) { print "W: $olddev not converted: link not useful!\n\n"; }
return ($newdevid);
}
# copy all lines from lilo.conf_old into
# new lilo.conf and add 'boot=' line
my $ok = 0;
- open(MYFH_NEW, "> $liloconf") or die("cannot open $liloconf: $!");
- open(MYFH_OLD, "< $liloconfold") or die ("cannot open $liloconfold: $!");
+ open(MYFH_NEW, "> $liloconf") or die("E: cannot open $liloconf: $!");
+ open(MYFH_OLD, "< $liloconfold") or die ("E: cannot open $liloconfold: $!");
while (<MYFH_OLD>) {
# line read from MYFH_OLD
chmod (0600,$liloconf);
}
else {
- print "file $liloconf does not exist: nothing changed\n";
+ print "W: file $liloconf does not exist: nothing changed!\n";
}
}
=head1 SYNOPSIS
-lilo-uuid-diskid [-h] [-v] [lilo.conf]
+B<lilo-uuid-diskid> [B<-h>] [B<-v>] [B<lilo.conf>]
=head1 DESCRIPTION
use the libata module for parallel and serial ATA interfaces of block devices
(i. e. hard disks with IDE or SATA interface, usbsticks).
-=head1 EXAMPLES
-
-Lines in the configuration file /etc/lilo.conf:
-
- #boot = /dev/sda
- boot = /dev/disk/by-id/ata-SAMSUNG_SV1604N_S01FJ10X999999
-
- #root = /dev/sda1
- root = "UUID=18843936-00f9-4df0-a373-000d05a5dd44"
-
=head1 OPTIONS
=over 4
=back
+=head1 EXAMPLES
+
+Lines in the configuration file /etc/lilo.conf:
+
+ #boot = /dev/sda
+ boot = /dev/disk/by-id/ata-SAMSUNG_SV1604N_S01FJ10X999999
+
+ #root = /dev/sda1
+ root = "UUID=18843936-00f9-4df0-a373-000d05a5dd44"
+
+=head1 COPYRIGHT and LICENSE
+
+Copyright (C) 2010-2014 Joachim Wiedorn
+
+This script is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
=head1 AUTHOR
B<lilo-uuid-diskid> was written by Joachim Wiedorn.
+This manual page was written by Joachim Wiedorn <joodevel at joonet.de>.
+
+=head1 SEE ALSO
+
+B<lilo>(8), B<update-lilo>(8), B<liloconfig>(8)
+
=cut