diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-09-16 13:12:22 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-09-16 13:12:22 +0000 |
commit | a93167ffc1aa311e57517a5c84aeab24123b30fb (patch) | |
tree | 61d0abb7f5b52056390a75fb8d0f8bd6c3aa0375 | |
parent | 7874dbbd46abc0d0fa3feca91fb3fb024cfbba66 (diff) | |
download | drakx-backup-do-not-use-a93167ffc1aa311e57517a5c84aeab24123b30fb.tar drakx-backup-do-not-use-a93167ffc1aa311e57517a5c84aeab24123b30fb.tar.gz drakx-backup-do-not-use-a93167ffc1aa311e57517a5c84aeab24123b30fb.tar.bz2 drakx-backup-do-not-use-a93167ffc1aa311e57517a5c84aeab24123b30fb.tar.xz drakx-backup-do-not-use-a93167ffc1aa311e57517a5c84aeab24123b30fb.zip |
- 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
-rw-r--r-- | perl-install/NEWS | 4 | ||||
-rwxr-xr-x | perl-install/standalone/bootloader-config | 28 |
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); |