summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/NEWS4
-rwxr-xr-xperl-install/standalone/bootloader-config28
2 files changed, 32 insertions, 0 deletions
diff --git a/perl-install/NEWS b/perl-install/NEWS
index 9edc2099c..2d161e868 100644
--- a/perl-install/NEWS
+++ b/perl-install/NEWS
@@ -1,3 +1,7 @@
+- bootloader-config:
+ o --action migrate-to-uuids: add UUID to swap v.2 in case the swap was
+ created long ago when mkswap didn't do it by default
+
Version 11.43 - 16 September 2008
- diskdrake:
diff --git a/perl-install/standalone/bootloader-config b/perl-install/standalone/bootloader-config
index b5a8e6807..17446b581 100755
--- a/perl-install/standalone/bootloader-config
+++ b/perl-install/standalone/bootloader-config
@@ -235,6 +235,10 @@ sub rebuild_initrds() {
#-###############################################################################
sub migrate_to_uuids() {
+ foreach (fs::get::fstab($all_hds)) {
+ _add_uuid_to_swap($_) if $_->{fs_type} eq 'swap' && !$_->{device_UUID};
+ }
+
_migrate_to_uuids__fstab();
my $fstab = [ fs::get::fstab($all_hds) ];
@@ -294,6 +298,30 @@ sub _set_prefer_device_UUID {
1;
}
+# add UUID to swap v.2 in case the swap was created long ago when mkswap didn't do it by default
+sub _add_uuid_to_swap {
+ my ($part) = @_;
+
+ my $ids = fs::type::call_vol_id($part);
+ $ids->{ID_FS_VERSION} eq '2'
+ or log::l("ERROR: do not know swap version $ids->{ID_FS_VERSION}, so can not add UUID to it"), return;
+
+ my $uuid = run_program::get_stdout('uuidgen');
+ log::l("adding UUID=$uuid to $part->{device}");
+ $uuid =~ s/-//g;
+ $uuid =~ s/(..)/chr(hex($1))/ge;
+
+ {
+ my $F;
+ sysopen($F, devices::make($part->{device}), 2) or die "error opening device $part->{device} for writing";
+ sysseek($F, 1036, 0) && syswrite($F, $uuid) or log::l("writing UUID failed");
+ }
+
+ if (my $p = fs::type::type_subpart_from_magic($part)) {
+ $part->{device_UUID} = $p->{device_UUID};
+ }
+}
+
#-###############################################################################
sub update_splash() {
bootloader::update_splash($bootloader);