summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/bootloader-config
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-09-26 09:20:24 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-09-26 09:20:24 +0000
commit82dbe80eef9f1ae5da732f7324d77bfed49ad5c9 (patch)
tree85de9581fe6aecd859196ce1b39ed73ad09a81d8 /perl-install/standalone/bootloader-config
parent7b77e5129475053b5aa94a9f9bc20553e7670415 (diff)
downloaddrakx-82dbe80eef9f1ae5da732f7324d77bfed49ad5c9.tar
drakx-82dbe80eef9f1ae5da732f7324d77bfed49ad5c9.tar.gz
drakx-82dbe80eef9f1ae5da732f7324d77bfed49ad5c9.tar.bz2
drakx-82dbe80eef9f1ae5da732f7324d77bfed49ad5c9.tar.xz
drakx-82dbe80eef9f1ae5da732f7324d77bfed49ad5c9.zip
- bootloader-config:
o --action migrate-to-uuids: be more precautious when modifying /etc/fstab (especially do not drop unrecognised entries) (#43548)
Diffstat (limited to 'perl-install/standalone/bootloader-config')
-rwxr-xr-xperl-install/standalone/bootloader-config40
1 files changed, 23 insertions, 17 deletions
diff --git a/perl-install/standalone/bootloader-config b/perl-install/standalone/bootloader-config
index 8c3dc7466..4a21bc7ac 100755
--- a/perl-install/standalone/bootloader-config
+++ b/perl-install/standalone/bootloader-config
@@ -239,9 +239,10 @@ sub migrate_to_uuids() {
_add_uuid_to_swap($_) if $_->{fs_type} eq 'swap' && !$_->{device_UUID};
}
- _migrate_to_uuids__fstab();
-
my $fstab = [ fs::get::fstab($all_hds) ];
+
+ _migrate_to_uuids__fstab($fstab);
+
my $bootloader_migrated;
my $may_migrate = sub {
my ($label, $dev_ref) = @_;
@@ -269,16 +270,30 @@ sub migrate_to_uuids() {
}
sub _migrate_to_uuids__fstab() {
+ my ($fstab) = @_;
+
+ my @raw_fstab = fs::read_fstab('', '/etc/fstab', 'keep_freq_passno', 'verbatim_credentials');
+
my $fstab_migrated;
- foreach my $part (fs::get::really_all_fstab($all_hds)) {
- if (_set_prefer_device_UUID($part)) {
- log::l("migrate_to_uuids: migrating fstab $part->{device} entry");
- $fstab_migrated = 1;
- }
+ foreach my $part (@raw_fstab) {
+ devices::should_prefer_UUID($part->{device}) or next;
+
+ my $part_ = find { fs::get::is_same_hd($part, $_) } @$fstab
+ or log::l("migrate_to_uuids: do not know $part->{device}, can not migrate it"), next;
+
+ $part->{device_UUID} = $part_->{device_UUID}
+ or log::l("migrate_to_uuids: no UUID for $part->{device}, can not migrate it"), next;
+ $part->{prefer_device_UUID} = 1;
+ $part->{prefer_device} = 0;
+
+ log::l("migrate_to_uuids: migrating fstab $part->{device} entry");
+ $fstab_migrated = 1;
}
if ($fstab_migrated) {
cp_af('/etc/fstab', '/etc/fstab.before-migrate-to-uuids');
- fs::write_fstab($all_hds);
+
+ my ($s) = fs::prepare_write_fstab(\@raw_fstab, '', 'keep_smb_credentials');
+ output('/etc/fstab', $s);
}
}
@@ -290,15 +305,6 @@ sub _migrate_dev_to_uuid {
$part && $part->{device_UUID} && "UUID=$part->{device_UUID}";
}
-sub _set_prefer_device_UUID {
- my ($part) = @_;
- $part->{device_UUID} && !$part->{prefer_device_UUID} && !$part->{prefer_device_LABEL}
- && devices::should_prefer_UUID($part->{device}) or return;
- $part->{prefer_device_UUID} = 1;
- $part->{prefer_device} = 0;
- 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) = @_;