summaryrefslogtreecommitdiffstats
path: root/perl-install/fsedit.pm
blob: 2fcd1f1eeca5831ee15aef169444af15e0fcda30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
package fsedit;

use diagnostics;
use strict;
use vars qw(%suggestions);
use feature 'state';

#-######################################################################################
#- misc imports
#-######################################################################################
use common;
use partition_table;
use partition_table::raw;
use fs::get;
use fs::type;
use fs::loopback;
use fs::proc_partitions;
use detect_devices;
use devices;
use log;
use fs;

# min_hd_size: only suggest this partition if the hd size is bigger than that
%suggestions = (
  N_("simple") => [
    { mntpoint => "/",     size => MB(300), fs_type => defaultFS(), ratio => 6, maxsize => MB(51500) },
    { mntpoint => "swap",  size => MB(256), fs_type => 'swap', ratio => 1, maxsize => MB(4096) },
    { mntpoint => "/home", size => MB(300), fs_type => defaultFS(), ratio => 12, min_hd_size => MB(51200) },
  ], N_("with /usr") => [
    { mntpoint => "/",     size => MB(250), fs_type => defaultFS(), ratio => 1, maxsize => MB(8000) },
    { mntpoint => "swap",  size =>  MB(64), fs_type => 'swap', ratio => 1, maxsize => MB(4000) },
    { mntpoint => "/usr",  size => MB(300), fs_type => defaultFS(), ratio => 4, maxsize => MB(8000) },
    { mntpoint => "/home", size => MB(100), fs_type => defaultFS(), ratio => 3, min_hd_size => MB(10000) },
  ], N_("server") => [
    { mntpoint => "/",     size => MB(150), fs_type => defaultFS(), ratio => 1, maxsize => MB(8000) },
    { mntpoint => "swap",  size =>  MB(64), fs_type => 'swap', ratio => 2, maxsize => MB(4000) },
    { mntpoint => "/usr",  size => MB(300), fs_type => defaultFS(), ratio => 4, maxsize => MB(8000) },
    { mntpoint => "/var",  size => MB(200), fs_type => defaultFS(), ratio => 3 },
    { mntpoint => "/home", size => MB(150), fs_type => defaultFS(), ratio => 3, min_hd_size => MB(10000) },
    { mntpoint => "/tmp",  size => MB(150), fs_type => defaultFS(), ratio => 2, maxsize => MB(4000) },
  ],
);
my %bck_suggestions = %suggestions;

sub init_mntpnt_suggestions {
    my ($all_hds, $o_force) = @_;
    my $fstab = [ fs::get::fstab($all_hds) ];
    state $done;
    return if $done && !$o_force;
    $done++;

    my $mntpoint;
    # only suggests /boot/EFI if there's not already one:
    require fs::any;
    if (is_uefi()) {
	if (!any { isESP($_) } @$fstab) {
	    $mntpoint = { mntpoint => "/boot/EFI", size => MB(100), pt_type => 0xef, ratio => 1, maxsize => MB(300) };
	}
    }
    return if !$mntpoint;
    foreach (keys %suggestions) {
	$suggestions{$_} = [ $mntpoint, @{$bck_suggestions{$_}} ];
    }
}

my @suggestions_mntpoints = (
    "/var/ftp", "/var/www", "/boot", '/usr/local', '/opt',
   "/mnt/windows",
);

#-######################################################################################
#- Functions
#-######################################################################################
sub recompute_loopbacks {
    my ($all_hds) = @_;
    my @fstab = fs::get::fstab($all_hds);
    @{$all_hds->{loopbacks}} = map { isPartOfLoopback($_) ? @{$_->{loopback}} : () } @fstab;
}

sub raids {
    my ($hds) = @_;

    my @parts = fs::get::hds_fstab(@$hds);

    my @l = grep { isRawRAID($_) } @parts or return [];

    log::l("looking for raids in " . join(' ', map { $_->{device} } @l));
    
    require raid;
    raid::detect_during_install(@l) if $::isInstall;
    raid::get_existing(@l);
}

sub dmcrypts {
    my ($all_hds) = @_;

    my @parts = fs::get::fstab($all_hds);

    my @l = grep { fs::type::isRawLUKS($_) } @parts or return;

    log::l("using dm-crypt from " . join(' ', map { $_->{device} } @l));
    
    require fs::dmcrypt;
    fs::dmcrypt::read_crypttab($all_hds);

    fs::dmcrypt::get_existing(@l);
}

sub lvms {
    my ($all_hds) = @_;
    my @pvs = grep { isRawLVM($_) } fs::get::fstab($all_hds) or return;
    scan_pvs(@pvs);
}

sub scan_pvs {
    my (@pvs) = @_;

    log::l("looking for vgs in " . join(' ', map { $_->{device} } @pvs));

    #- otherwise vgscan will not find them
    devices::make($_->{device}) foreach @pvs; 
    require lvm;

    my @lvms;
    foreach (@pvs) {
	my $name = lvm::pv_to_vg($_) or next;
	my $lvm = find { $_->{VG_name} eq $name } @lvms;
	if (!$lvm) {
	    $lvm = new lvm($name);
	    lvm::update_size($lvm);
	    lvm::get_lvs($lvm);
	    push @lvms, $lvm;
	}
	$_->{lvm} = $name;
	push @{$lvm->{disks}}, $_;
    }
    @lvms;
}

sub handle_dmraid {
    my ($drives, $o_in) = @_;

    @$drives > 1 or return;

    devices::make($_->{device}) foreach @$drives;

    require fs::dmraid; 
    eval { fs::dmraid::init() } or log::l("dmraid::init failed"), return;

    my @vgs = fs::dmraid::vgs();
    log::l(sprintf('dmraid: ' . join(' ', map { "$_->{device} [" . join(' ', @{$_->{disks}}) . "]" } @vgs)));

    if ($o_in && @vgs && $::isInstall) {
	@vgs = grep {
	    $o_in->ask_yesorno('', N("BIOS software RAID detected on disks %s. Activate it?", join(' ', @{$_->{disks}})), 1);
	} @vgs or do {
	    fs::dmraid::call_dmraid('-an');
	    return;
	};
    }
    if (!$::isInstall) {
	fs::dmraid::migrate_device_names($_) foreach @vgs;
    }
    log::l("using dmraid on " . join(' ', map { $_->{device} } @vgs));

    my @used_hds = map {
	my $part = fs::get::device2part($_, $drives) or log::l("handle_dmraid: can't find $_ in known drives");
	if_($part, $part);
    } map { @{$_->{disks}} } @vgs;

    @$drives = difference2($drives, \@used_hds);

    push @$drives, @vgs;
}

sub get_hds {
    my ($o_flags, $o_in) = @_;
    my $flags = $o_flags || {};
    $flags->{readonly} && ($flags->{clearall} || $flags->{clear}) and die "conflicting flags readonly and clear/clearall";

    my @drives = detect_devices::hds();

    #- replace drives used in dmraid by the merged name
    handle_dmraid(\@drives, $o_in) if !$flags->{nodmraid};

    foreach my $hd (@drives) {
	$hd->{file} = devices::make($hd->{device});
    }

    @drives = partition_table::raw::get_geometries(@drives);

    my (@hds, @raw_hds);
    foreach my $hd (@drives) {
	$hd->{readonly} = $flags->{readonly};

	eval { partition_table::raw::test_for_bad_drives($hd) if !$flags->{no_bad_drives} };
	if (my $err = $@) {
	    log::l("test_for_bad_drives returned $err");
	    if ($err =~ /write error:/) { 
		log::l("setting $hd->{device} readonly");
		$hd->{readonly} = 1;
	    } elsif ($err =~ /read error:/) {
		next;
	    } else {
		$o_in and $o_in->ask_warn('', $err);
		next;
	    }
	}

	if ($flags->{clearall} || member($hd->{device}, @{$flags->{clear} || []})) {
	    my $lvms = []; #- temporary one, will be re-created later in get_hds()
	    partition_table_clear_and_initialize($lvms, $hd, $o_in);
	} else {
	    my $handle_die_and_cdie = sub {
		if (my $type = fs::type::type_subpart_from_magic($hd)) {
		    #- non partitioned drive?
		    if (exists $hd->{usb_description} && $type->{fs_type}) {
			#- USB keys
			put_in_hash($hd, $type);
			push @raw_hds, $hd;
			$hd = '';
			1;
		    } else {
			0;
		    }
		} elsif ($hd->{readonly}) {
		    log::l("using /proc/partitions since diskdrake failed :(");
		    fs::proc_partitions::use_($hd);
		    1;
		} else {
		    0;
		}
	    };
	    my $handled;
	    eval {
		catch_cdie {
		    partition_table::read($hd);
		    if (listlength(partition_table::get_normal_parts($hd)) == 0) {
			$handled = 1 if $handle_die_and_cdie->();
		    } elsif ($::isInstall) {
			if (fs::type::is_dmraid($hd)) {
			    if (my $p = find { ! -e "/dev/$_->{device}" } partition_table::get_normal_parts($hd)) {
				#- dmraid should have created the device, so it means we don't agree
				die sprintf(q(bad dmraid (missing partition %s), you may try rebooting install with option "nodmraid"), $p->{device});
			    }
			} else {
			    fs::proc_partitions::compare($hd) if !detect_devices::is_xbox();
			}
		    }
		} sub {
		    my $err = $@;
		    if ($handle_die_and_cdie->()) {
			$handled = 1;
			0; #- do not continue, transform cdie into die
		    } else {
			!$o_in || $o_in->ask_okcancel('', formatError($err));
		    }
		};
	    };
	    if (my $err = $@) {
		if ($handled) {
		    #- already handled in cdie handler above
		} elsif ($handle_die_and_cdie->()) {
		} elsif ($o_in && $o_in->ask_yesorno(N("Error"), 
N("I cannot read the partition table of device %s, it's too corrupted for me :(
I can try to go on, erasing over bad partitions (ALL DATA will be lost!).
The other solution is to not allow DrakX to modify the partition table.
(the error is %s)

Do you agree to lose all the partitions?
", $hd->{device}, formatError($err)))) {
		    partition_table::raw::zero_MBR($hd);
		} else {
		    #- using it readonly
		    log::l("using /proc/partitions since diskdrake failed :(");
		    fs::proc_partitions::use_($hd);
		}
	    }
	    $hd or next;

	    member($_->{device}, @{$flags->{clear} || []}) and partition_table::remove($hd, $_)
	      foreach partition_table::get_normal_parts($hd);
	}

	my @parts = partition_table::get_normal_parts($hd);

	# fix installer failures due to udev's race when run too early:
	run_program::run('udevadm', 'settle');

	# checking the magic of the filesystem, do not rely on pt_type
	foreach (@parts) {
	    if (my $type = fs::type::type_subpart_from_magic($_)) {
                $type->{pt_type} = $_->{pt_type}; #- keep {pt_type}
                put_in_hash($_, $type); 
	    } else {
		$_->{bad_fs_type_magic} = 1;
	    }
	}

	if ($hd->{usb_media_type}) {
	    $hd->{is_removable} = 1;
	    $_->{is_removable} = 1 foreach @parts;
	}

	push @hds, $hd;
    }

    #- detect raids before LVM allowing LVM on raid
    my $raids = raids(\@hds);
    my $all_hds = { %{ fs::get::empty_all_hds() }, hds => \@hds, raw_hds => \@raw_hds, lvms => [], raids => $raids };

    $all_hds->{lvms} = [ lvms($all_hds) ];

    fs::get_major_minor([ fs::get::fstab($all_hds) ]);

    # must be done after getting major/minor
    $all_hds->{dmcrypts} = [ dmcrypts($all_hds) ];
    # allow lvm on dmcrypt
    $all_hds->{lvms} = [ lvms($all_hds) ];

    $_->{faked_device} = 0 foreach fs::get::fstab($all_hds);

    $all_hds;
}

#- are_same_partitions() do not look at the device name since things may have changed
sub are_same_partitions {
    my ($part1, $part2) = @_;
    foreach ('start', 'size', 'pt_type', 'fs_type', 'rootDevice') {
	$part1->{$_} eq $part2->{$_} or return 0;
    }
    1;
}

sub is_one_big_fat_or_NT {
    my ($hds) = @_;
    @$hds == 1 or return 0;

    my @l = fs::get::hds_fstab(@$hds);
    @l == 1 && isFat_or_NTFS($l[0]) && fs::get::hds_free_space(@$hds) < MB(10);
}


sub computeSize {
    my ($part, $best, $all_hds, $suggestions) = @_;
    my $max = $part->{maxsize} || $part->{size};
    return min($max, $best->{size}) unless $best->{ratio};

    my %free_space;
    $free_space{$_->{rootDevice}} += $_->{size} foreach fs::get::holes($all_hds);

    my @l = my @L = grep {
	my @possible = $_->{hd} ? $_->{hd} : keys %free_space;
	my $size = $_->{size};
	if (my $dev = find { $free_space{$_} >= $size } @possible) {
	    $free_space{$dev} -= $size;
	    1;
	} else { 0 } } @$suggestions;

    my $free_space = $best->{hd} && $free_space{$best->{hd}} || sum(values %free_space);

    my $cylinder_size_maxsize_adjusted;
    my $tot_ratios = 0;
    while (1) {
	my $old_free_space = $free_space;
	my $old_tot_ratios = $tot_ratios;

	$tot_ratios = sum(map { $_->{ratio} } @l);
	last if $tot_ratios == $old_tot_ratios;

	@l = grep { 
	    if ($_->{ratio} && $_->{maxsize} && $tot_ratios &&
		$_->{size} + $_->{ratio} / $tot_ratios * $old_free_space >= $_->{maxsize}) {
		return min($max, $best->{maxsize}) if $best->{mntpoint} eq $_->{mntpoint};
		$free_space -= $_->{maxsize} - $_->{size};
		if (!$cylinder_size_maxsize_adjusted++) {
		    eval { $free_space += fs::get::part2hd($part, $all_hds)->cylinder_size - 1 };
		}
		0;
	    } else {
		$_->{ratio};
	    } 
	} @l;
    }
    my $size = int min($max, $best->{size} + $free_space * ($tot_ratios && $best->{ratio} / $tot_ratios));
    #- verify other entry can fill the hole
    (any { $_->{size} <= $max - $size } @L) ? $size : $max;
}

sub suggest_part {
    my ($part, $all_hds, $o_suggestions) = @_;
    my $suggestions = $o_suggestions || $suggestions{server} || $suggestions{simple};

    #- suggestions now use {fs_type}, but still keep compatibility
    foreach (@$suggestions) {
	fs::type::set_pt_type($_, $_->{pt_type}) if !exists $_->{fs_type};
    }

    my $hd = fs::get::part2hd($part, $all_hds);
    my $hd_size = $hd && $hd->{totalsectors}; # nb: no $hd if $part is /dev/mdX
    my $has_swap = any { isSwap($_) } fs::get::fstab($all_hds);

    my @local_suggestions =
      grep { $::auto_install || !$_->{mntpoint} && !$_->{VG_name} || !fs::get::has_mntpoint($_->{mntpoint}, $all_hds) || isSwap($_) && !$has_swap }
      grep { !$_->{min_hd_size} || !$hd_size || $_->{min_hd_size} <= $hd_size }
      grep { !$_->{hd} || $_->{hd} eq $part->{rootDevice} }
	@$suggestions;

    #- this allows specifying the size using a relative size.
    #- one should rather use {ratio} instead
    foreach (@local_suggestions) {
	if ($_->{percent_size} && $_->{percent_size} =~ /(.+?)%?$/) {
	    $_->{size} = $1 / 100 * $hd_size;
	    log::l("in suggestion, setting size=$_->{size} for percent_size=$_->{percent_size}");
	}
    }

    my ($best) =
      grep { !$_->{maxsize} || $part->{size} <= $_->{maxsize} }
      grep { $_->{size} <= ($part->{maxsize} || $part->{size}) }
      grep { !$part->{fs_type} || $part->{fs_type} eq $_->{fs_type} || isTrueFS($part) && isTrueFS($_) }
	@local_suggestions;

    defined $best or return 0; #- sorry no suggestion :(

    $part->{mntpoint} = $best->{mntpoint};
    fs::type::set_type_subpart($part, $best) if !isTrueFS($best) || !isTrueFS($part);
    $part->{size} = computeSize($part, $best, $all_hds, \@local_suggestions);
    foreach ('options', 'lv_name', 'encrypt_key', 'primaryOrExtended',
	     'device_LABEL', 'prefer_device_LABEL', 'device_UUID', 'prefer_device_UUID', 'prefer_device') {
	$part->{$_} = $best->{$_} if $best->{$_};
    }
    $best;
}

sub suggestions_mntpoint {
    my ($all_hds) = @_;
    sort grep { !/swap/ && !fs::get::has_mntpoint($_, $all_hds) }
      (@suggestions_mntpoints, map { $_->{mntpoint} } @{$suggestions{server} || $suggestions{simple}});
}

#- you can do this before modifying $part->{mntpoint}
#- so $part->{mntpoint} should not be used here, use $mntpoint instead
sub check_mntpoint {
    my ($mntpoint, $part, $all_hds) = @_;

    $mntpoint eq '' || isSwap($part) || isNonMountable($part) and return 0;
    $mntpoint =~ m|^/| or die N("Mount points must begin with a leading /");
    $mntpoint =~ m|[\x7f-\xff]| and cdie N("Mount points should contain only alphanumerical characters");
    fs::get::mntpoint2part($mntpoint, [ grep { $_ ne $part } fs::get::really_all_fstab($all_hds) ]) and die N("There is already a partition with mount point %s\n", $mntpoint);

    if ($mntpoint eq "/" && (isLUKS($part) || isRawLUKS($part)) && !fs::get::has_mntpoint("/boot", $all_hds)) {
	cdie N("You've selected an encrypted partition as root (/).
No bootloader is able to handle this without a /boot partition.
Please be sure to add a separate /boot partition");
    }

    if ($mntpoint eq "/boot" && (isLUKS($part) || isRawLUKS($part)))  {
	die N("You cannot use an encrypted filesystem for mount point %s", "/boot");
    }

    cdie N("This directory should remain within the root filesystem")
      if member($mntpoint, qw(/root));
    die N("This directory should remain within the root filesystem")
      if member($mntpoint, qw(/bin /dev /etc /lib /sbin /mnt /media));
    die N("You need a true filesystem (ext2/3/4, reiserfs, xfs, or jfs) for this mount point\n")
      if !isTrueLocalFS($part) && $mntpoint eq '/';
    die N("You need a true filesystem (ext2/3/4, reiserfs, xfs, or jfs) for this mount point\n") . $mntpoint
      if !isTrueFS($part) && member($mntpoint, '/home', fs::type::directories_needed_to_boot_not_ESP());
    die N("You cannot use an encrypted filesystem for mount point %s", $mntpoint)
      if $part->{options} =~ /encrypted/ && member($mntpoint, qw(/ /usr /var /boot));

    local $part->{mntpoint} = $mntpoint;
    fs::loopback::check_circular_mounts($part, $all_hds);
}

sub add {
    my ($hd, $part, $all_hds, $options) = @_;

    isSwap($part) ?
      ($part->{mntpoint} = 'swap') :
      $options->{force} || check_mntpoint($part->{mntpoint}, $part, $all_hds);

    delete $part->{maxsize};

    if (isLVM($hd)) {
	lvm::lv_create($hd, $part);
    } else {
	partition_table::add($hd, $part, $options->{primaryOrExtended});
    }
    fs::get_major_minor([ $part ]);
}

sub allocatePartitions {
    my ($all_hds, $to_add, $o_hd) = @_;

    my @to_add = @$to_add;
 
    foreach my $part_ (fs::get::holes($all_hds, 'non_readonly')) {
	my ($start, $size, $dev) = @$part_{"start", "size", "rootDevice"};
	next if $o_hd && (($o_hd->{device} || $o_hd->{VG_name}) ne $dev);
	my ($part, $suggested);
	while ($suggested = suggest_part($part = { start => $start, size => 0, maxsize => $size, rootDevice => $dev }, 
					 $all_hds, \@to_add)) {
	    my $hd = fs::get::part2hd($part, $all_hds);
	    add($hd, $part, $all_hds, { primaryOrExtended => $part->{primaryOrExtended} });
	    $size -= $part->{size} + $part->{start} - $start;
	    $start = $part->{start} + $part->{size};
 	    @to_add = grep { $_ != $suggested } @to_add;
	}
    }
}

sub auto_allocate {
    my ($all_hds, $o_suggestions, $o_target) = @_;
    my $before = listlength(fs::get::fstab($all_hds));

    auto_allocate_bios_boot_parts($all_hds, $o_target) if !is_uefi();

    my $suggestions = $o_suggestions || $suggestions{simple};
    allocatePartitions($all_hds, $suggestions, $o_target);

    if ($o_suggestions) {
	auto_allocate_raids($all_hds, $suggestions);
	if (auto_allocate_vgs($all_hds, $suggestions)) {
	    #- allocatePartitions needs to be called twice, once for allocating PVs, once for allocating LVs
	    my @vgs = map { $_->{VG_name} } @{$all_hds->{lvms}};
	    my @suggested_lvs = grep { member($_->{hd}, @vgs) } @$suggestions;
	    allocatePartitions($all_hds, \@suggested_lvs);
	}
    }

    partition_table::assign_device_numbers($_) foreach @{$all_hds->{hds}};

    if ($before == listlength(fs::get::fstab($all_hds))) {
	# find out why auto_allocate failed
	if (any { !fs::get::has_mntpoint($_->{mntpoint}, $all_hds) } @$suggestions) {
	    die N("Not enough free space for auto-allocating");
	} else {
	    die N("Nothing to do");
	}
    }
    my @fstab = fs::get::fstab($all_hds);
    fs::mount_point::suggest_mount_points_always(\@fstab);
}

sub auto_allocate_bios_boot_parts {
    my ($all_hds, $o_hd) = @_;
    foreach my $hd (@{$all_hds->{hds}}) {
	# skip if not the selected device
	next if $o_hd && ($o_hd->{device} ne $hd->{device});
	# skip non-GPT disks
	next if ($hd->{pt_table_type} || partition_table::default_type($hd)) ne 'gpt';
	# check if a BIOS boot partition already exists
	my @parts = map { partition_table::get_normal_parts($_) } $hd;
	next if any { isBIOS_GRUB($_) } @parts;
	# try to allocate a BIOS boot partition
	my $suggest = { mntpoint => "", size => MB(1), pt_type => 'BIOS_GRUB', ratio => 1, maxsize => MB(2) };
	allocatePartitions($all_hds, [ $suggest ], $hd);
    }
}

sub auto_allocate_raids {
    my ($all_hds, $suggestions) = @_;

    my @raids = grep { isRawRAID($_) } fs::get::fstab($all_hds) or return;

    require raid;
    my @mds = grep { $_->{hd} =~ /md/ } @$suggestions;
    foreach my $md (@mds) {
	my @raids_ = grep { !$md->{parts} || $md->{parts} =~ /\Q$_->{mntpoint}/ } @raids;
	@raids = difference2(\@raids, \@raids_);

	my %h = %$md;
	delete @h{'hd', 'parts'}; # keeping mntpoint, level, chunk-size, fs_type/pt_type
	$h{disks} = \@raids_;

	my $part = raid::new($all_hds->{raids}, %h);

	raid::updateSize($part);
	push @raids, $part; #- we can build raid over raid
    }
}

sub auto_allocate_vgs {
    my ($all_hds, $suggestions) = @_;

    my @pvs = grep { isRawLVM($_) } fs::get::fstab($all_hds) or return 0;

    my @vgs = grep { $_->{VG_name} } @$suggestions or return 0;

    partition_table::write($_) foreach @{$all_hds->{hds}};

    require lvm;

    foreach my $vg (@vgs) {
	my $lvm = new lvm($vg->{VG_name});
	push @{$all_hds->{lvms}}, $lvm;
	
	my @pvs_ = grep { !$vg->{parts} || $vg->{parts} =~ /\Q$_->{mntpoint}/ } @pvs;
	@pvs = difference2(\@pvs, \@pvs_);

	foreach my $part (@pvs_) {
	    raid::make($all_hds->{raids}, $part) if isRAID($part);
	    $part->{lvm} = $lvm->{VG_name};
	    delete $part->{mntpoint};
	    lvm::vg_add($part);
	    push @{$lvm->{disks}}, $part;
	}
	lvm::update_size($lvm);
    }
    1;
}

sub change_type {
    my ($type, $hd, $part) = @_;
    $type->{pt_type} != $part->{pt_type} || $type->{fs_type} ne $part->{fs_type} or return;
    fs::type::check($type->{fs_type}, $hd, $part);
    delete $part->{device_UUID};
    $hd->{isDirty} = 1;
    $part->{mntpoint} = '' if isSwap($part) && $part->{mntpoint} eq "swap";
    $part->{mntpoint} = '' if fs::type::cannotBeMountable($part);
    set_isFormatted($part, 0);
    fs::type::set_type_subpart($part, $type);
    fs::mount_options::rationalize($part);
    1;
}

=item partition_table_clear_and_initialize($lvms, $hd, $o_in, $o_type, $b_warn) = @_;

wrapper around partition_table::initialize() but which also create a singleton VG
automatically (so that it's easier for the user)

=cut

sub partition_table_clear_and_initialize {
    my ($lvms, $hd, $o_in, $o_type, $b_warn) = @_;
    partition_table::initialize($hd, $o_type);
    if ($hd->isa('partition_table::lvm')) {
	if ($b_warn && $o_in) {
	    $o_in->ask_okcancel_('', N("ALL existing partitions and their data will be lost on drive %s", partition_table::description($hd))) or return;
	}
	require lvm;
	lvm::check($o_in ? $o_in->do_pkgs : do_pkgs_standalone->new) if $::isStandalone;
	lvm::create_singleton_vg($lvms, fs::get::hds_fstab($hd));
    }
}

1;
for 1MB bootstrap! Install will continue, but to boot your " "system, you'll need to create the bootstrap partition in DiskDrake" msgstr "" "Няма свободно място за 1 МБ стартиращо поле ! Инсталацията ще продължи, но, " "за да стартирате системата си, ще трябва да създадете стартиращо поле в " "DiskDrake" #: steps_interactive.pm:289 #, fuzzy, c-format msgid "" "You'll need to create a PPC PReP Boot bootstrap! Install will continue, but " "to boot your system, you'll need to create the bootstrap partition in " "DiskDrake" msgstr "" "Няма свободно място за 1 МБ стартиращо поле ! Инсталацията ще продължи, но, " "за да стартирате системата си, ще трябва да създадете стартиращо поле в " "DiskDrake" #: steps_interactive.pm:381 #, fuzzy, c-format msgid "" "Change your Cd-Rom!\n" "Please insert the Cd-Rom labelled \"%s\" in your drive and press Ok when " "done.\n" "If you do not have it, press Cancel to avoid installation from this Cd-Rom." msgstr "" "Сменете CD-ROM !\n" "\n" "Моля, сложете CD-ROM озаглавен \"%s\" в устройството и натиснете Ok, когато " "сте готови.\n" "Ако го нямате, натиснете Отмяна, за да избегнете инсталирането от този CD-" "ROM." #: steps_interactive.pm:403 #, c-format msgid "Looking for available packages..." msgstr "Търся налични пакети..." #: steps_interactive.pm:411 #, c-format msgid "" "Your system does not have enough space left for installation or upgrade (%" "dMB > %dMB)" msgstr "" #: steps_interactive.pm:459 #, fuzzy, c-format msgid "" "Please choose load or save package selection.\n" "The format is the same as auto_install generated files." msgstr "" "Може изберете зареждане или запис на избора на пакети на флопи.\n" "Форматът е същият като auto_install генерираните дискети." #: steps_interactive.pm:461 #, c-format msgid "Load" msgstr "Натовареност" #: steps_interactive.pm:461 #, c-format msgid "Save" msgstr "Запазва" #: steps_interactive.pm:469 #, fuzzy, c-format msgid "Bad file" msgstr "Зареждане на файл" #: steps_interactive.pm:485 #, fuzzy, c-format msgid "KDE" msgstr "IDE" #: steps_interactive.pm:486 #, c-format msgid "GNOME" msgstr "" #: steps_interactive.pm:489 #, fuzzy, c-format msgid "Desktop Selection" msgstr "Избор на група пакети" #: steps_interactive.pm:490 #, c-format msgid "You can choose your workstation desktop profile:" msgstr "" #: steps_interactive.pm:575 #, c-format msgid "Selected size is larger than available space" msgstr "Избраната големина е по-голяма от достъпното пространство" #: steps_interactive.pm:590 #, c-format msgid "Type of install" msgstr "Тип инсталация" #: steps_interactive.pm:591 #, c-format msgid "" "You have not selected any group of packages.\n" "Please choose the minimal installation you want:" msgstr "" "Вие не сте избрали никаква група от пакети.\n" "Моля, изберете минималната инсталация кояти искате:" #: steps_interactive.pm:594 #, c-format msgid "With X" msgstr "С X" #: steps_interactive.pm:595 #, c-format msgid "With basic documentation (recommended!)" msgstr "С базова документация (препоръчва се!)" #: steps_interactive.pm:596 #, c-format msgid "Truly minimal install (especially no urpmi)" msgstr "Наистина минимална инсталация (особенно без urpmi)" #: steps_interactive.pm:650 #, c-format msgid "Preparing installation" msgstr "Подготвям инсталацията" #: steps_interactive.pm:658 #, c-format msgid "Installing package %s" msgstr "Инсталиране на пакета %s" #: steps_interactive.pm:682 #, c-format msgid "There was an error ordering packages:" msgstr "Появи се грешка при поръчването на пакетите:" #: steps_interactive.pm:682 #, c-format msgid "Go on anyway?" msgstr "Да продължа ли все пак ?" #: steps_interactive.pm:686 #, c-format msgid "Retry" msgstr "" #: steps_interactive.pm:687 #, c-format msgid "Skip this package" msgstr "" #: steps_interactive.pm:688 #, c-format msgid "Skip all packages from medium \"%s\"" msgstr "" #: steps_interactive.pm:689 #, fuzzy, c-format msgid "Go back to media and packages selection" msgstr "Запази избор на пакети" #: steps_interactive.pm:692 #, fuzzy, c-format msgid "There was an error installing package %s." msgstr "Появи се грешка при инсталиране на пакетите:" #: steps_interactive.pm:710 #, c-format msgid "Post-install configuration" msgstr "След инсталационна настройка" #: steps_interactive.pm:717 #, c-format msgid "Please ensure the Update Modules media is in drive %s" msgstr "" #: steps_interactive.pm:745 steps_list.pm:47 #, c-format msgid "Updates" msgstr "Обновяване" #: steps_interactive.pm:746 #, c-format msgid "" "You now have the opportunity to download updated packages. These packages\n" "have been updated after the distribution was released. They may\n" "contain security or bug fixes.\n" "\n" "To download these packages, you will need to have a working Internet \n" "connection.\n" "\n" "Do you want to install the updates?" msgstr "" #: steps_interactive.pm:768 #, c-format msgid "Contacting the mirror to get the list of available packages..." msgstr "Свързване с огледалния сървър за получаване на списъка с пакетите" #: steps_interactive.pm:774 #, c-format msgid "Unable to contact mirror %s" msgstr "Не мога да се свръжа с огледален сървър' %s" #: steps_interactive.pm:879 #, c-format msgid "%s on %s" msgstr "%s на %s" #: steps_interactive.pm:912 steps_interactive.pm:919 steps_interactive.pm:932 #: steps_interactive.pm:949 steps_interactive.pm:964 #, c-format msgid "Hardware" msgstr "Хардуер" #: steps_interactive.pm:933 steps_interactive.pm:950 #, c-format msgid "Sound card" msgstr "Звукова карта" #: steps_interactive.pm:953 #, c-format msgid "Do you have an ISA sound card?" msgstr "Имате ли ISA звукова карта?" #: steps_interactive.pm:955 #, fuzzy, c-format msgid "" "Run \"alsaconf\" or \"sndconfig\" after installation to configure your sound " "card" msgstr "" "Изпълнете \"sndconfig\" след инсталация за да конфигурирате вашата звукова " "карта" #: steps_interactive.pm:957 #, c-format msgid "No sound card detected. Try \"harddrake\" after installation" msgstr "Няма открита звукова карта. Опитайте \"harddrake\" след инсталацията" #: steps_interactive.pm:965 #, c-format msgid "Graphical interface" msgstr "Графичен интерфайс" #: steps_interactive.pm:971 steps_interactive.pm:982 #, c-format msgid "Network & Internet" msgstr "Мрежа и интернет" #: steps_interactive.pm:983 #, fuzzy, c-format msgid "Proxies" msgstr "Профил " #: steps_interactive.pm:984 #, fuzzy, c-format msgid "configured" msgstr "пренастройка" #: steps_interactive.pm:994 #, c-format msgid "Security Level" msgstr "Ниво на защита" #: steps_interactive.pm:1013 #, c-format msgid "Firewall" msgstr "Защитна стена" #: steps_interactive.pm:1017 #, c-format msgid "activated" msgstr "активирано" #: steps_interactive.pm:1017 #, c-format msgid "disabled" msgstr "изключен" #: steps_interactive.pm:1031 #, c-format msgid "You have not configured X. Are you sure you really want this?" msgstr "Вие не сте конфигурирали X. Сигурни ли сте, че искате това?" #: steps_interactive.pm:1058 #, c-format msgid "Preparing bootloader..." msgstr "Подготовка на bootloader" #: steps_interactive.pm:1068 #, fuzzy, c-format msgid "" "You appear to have an OldWorld or Unknown machine, the yaboot bootloader " "will not work for you. The install will continue, but you'll need to use " "BootX or some other means to boot your machine. The kernel argument for the " "root fs is: root=%s" msgstr "" "Изглежда имате старовремска или неизвестна\n" "машина, на която yaboot няма да проработи.\n" "Инсталацията ще продължи, но ще трябва\n" "да иползвате BootX, за да стартирате машината си" #: steps_interactive.pm:1087 #, c-format msgid "" "In this security level, access to the files in the Windows partition is " "restricted to the administrator." msgstr "" #: steps_interactive.pm:1121 #, c-format msgid "Insert a blank floppy in drive %s" msgstr "Сложете празна дискета в устройство %s" #: steps_interactive.pm:1123 #, c-format msgid "Creating auto install floppy..." msgstr "Подготвям дискета с автоматична инсталация" #: steps_interactive.pm:1134 #, c-format msgid "" "Some steps are not completed.\n" "\n" "Do you really want to quit now?" msgstr "" "Някои етапи не са завършени.\n" "\n" "Наистина ли искате да излезете сега ?" #: steps_interactive.pm:1144 #, c-format msgid "Congratulations" msgstr "Поздравления" #: steps_interactive.pm:1147 #, c-format msgid "Reboot" msgstr "Престартира" #: steps_interactive.pm:1151 steps_interactive.pm:1152 #, c-format msgid "Generate auto install floppy" msgstr "Подготви дискета за автоматична инсталация" #: steps_interactive.pm:1153 #, c-format msgid "" "The auto install can be fully automated if wanted,\n" "in that case it will take over the hard drive!!\n" "(this is meant for installing on another box).\n" "\n" "You may prefer to replay the installation.\n" msgstr "" "Автоматичната инсталация може да бъде напълно автоматизирана,\n" "в такъв случай ще превземе твърдия ви диск !!!\n" "(това е за предназначено за инсталиране на друга машина).\n" "\n" "Може би искате да повторите инсталацията.\n" #: steps_interactive.pm:1158 #, c-format msgid "Replay" msgstr "Повтори" #: steps_interactive.pm:1158 #, c-format msgid "Automated" msgstr "Автоматизиран" #: steps_interactive.pm:1161 #, c-format msgid "Save packages selection" msgstr "Запази избор на пакети" #. -PO: please keep the following messages very short: they must fit in the left list of the installer!!! #: steps_list.pm:16 #, c-format msgid "" "_: Keep these entry short\n" "Language" msgstr "Избор на език" #: steps_list.pm:16 steps_list.pm:23 #, c-format msgid "Localization" msgstr "" #: steps_list.pm:17 #, c-format msgid "" "_: Keep these entry short\n" "License" msgstr "Лиценз" #: steps_list.pm:18 #, c-format msgid "" "_: Keep these entry short\n" "Mouse" msgstr "Мишка" #: steps_list.pm:19 steps_list.pm:20 #, c-format msgid "" "_: Keep these entry short\n" "Hard drive detection" msgstr "Засичане на дисковете" #: steps_list.pm:21 steps_list.pm:22 #, c-format msgid "" "_: Keep these entry short\n" "Installation class" msgstr "" #: steps_list.pm:23 #, c-format msgid "" "_: Keep these entry short\n" "Keyboard" msgstr "Клавиатура" #: steps_list.pm:24 #, c-format msgid "" "_: Keep these entry short\n" "Security" msgstr "Сигурност" #: steps_list.pm:25 #, c-format msgid "" "_: Keep these entry short\n" "Partitioning" msgstr "Разделяне на дялове" #: steps_list.pm:27 steps_list.pm:28 #, c-format msgid "" "_: Keep these entry short\n" "Formatting" msgstr "" #: steps_list.pm:29 #, c-format msgid "" "_: Keep these entry short\n" "Choosing packages" msgstr "" #: steps_list.pm:31 #, c-format msgid "" "_: Keep these entry short\n" "Installing" msgstr "Инсталирам" #: steps_list.pm:34 #, c-format msgid "" "_: Keep these entry short\n" "Users" msgstr "Потребители" #: steps_list.pm:36 steps_list.pm:37 #, c-format msgid "" "_: Keep these entry short\n" "Networking" msgstr "Мрежа" #: steps_list.pm:38 steps_list.pm:39 #, c-format msgid "" "_: Keep these entry short\n" "Bootloader" msgstr "Bootloader" #: steps_list.pm:40 steps_list.pm:41 #, c-format msgid "" "_: Keep these entry short\n" "Configure X" msgstr "Настройка на Х" #: steps_list.pm:42 #, c-format msgid "" "_: Keep these entry short\n" "Summary" msgstr "Обобщение" #: steps_list.pm:44 steps_list.pm:45 #, c-format msgid "" "_: Keep these entry short\n" "Services" msgstr "Услуги" #: steps_list.pm:46 #, c-format msgid "" "_: Keep these entry short\n" "Updates" msgstr "Обновяване" #: steps_list.pm:48 #, c-format msgid "" "_: Keep these entry short\n" "Exit" msgstr "Излез" #: ../../advertising/IM_flash.pl:1 #, c-format msgid "Your desktop on a USB key" msgstr "" #: ../../advertising/IM_free08S.pl:1 #, c-format msgid "The 100%% open source Mandriva Linux distribution" msgstr "" #: ../../advertising/IM_one08S.pl:1 #, c-format msgid "Explore Linux easily with Mandriva One" msgstr "" #: ../../advertising/IM_pwp08S.pl:1 #, c-format msgid "A full Mandriva Linux desktop, with support" msgstr "" #: ../../advertising/IM_range08S.pl:1 #, c-format msgid "Mandriva: distributions for everybody's needs" msgstr "" #~ msgid "Do you want to use aboot?" #~ msgstr "Искате ли да използвате aboot ?" #~ msgid "" #~ "Error installing aboot, \n" #~ "try to force installation even if that destroys the first partition?" #~ msgstr "" #~ "Грешка при инсталиране на aboot, \n" #~ "да се опитам ли да продължа инсталацията дори, ако това унижтожи първия " #~ "дял ?" #~ msgid "All" #~ msgstr "Всички" #~ msgid "TV card" #~ msgstr "TV карта" #~ msgid "Boot" #~ msgstr "Зареждане" #~ msgid "" #~ "_: Keep these entry short\n" #~ "Authentication" #~ msgstr "Идентификация" #, fuzzy #~ msgid "(%d package, %d MB)" #~ msgid_plural "(%d packages, %d MB)" #~ msgstr[0] "%d пакета" #~ msgstr[1] "%d пакета" #~ msgid "%d packages" #~ msgstr "%d пакета" #~ msgid "Language" #~ msgstr "Избор на език" #~ msgid "License" #~ msgstr "Лиценз" #, fuzzy #~ msgid "Installation class" #~ msgstr "Избор на клас инсталация" #, fuzzy #~ msgid "Formatting" #~ msgstr "Пресмятане" #, fuzzy #~ msgid "Choosing packages" #~ msgstr "Пакети за инсталиране" #~ msgid "Users" #~ msgstr "Потребители" #~ msgid "Networking" #~ msgstr "Мрежа" #~ msgid "Configure X" #~ msgstr "Настройка на Х" #~ msgid "" #~ "Can not access kernel modules corresponding to your kernel (file %s is " #~ "missing), this generally means your boot floppy in not in sync with the " #~ "Installation medium (please create a newer boot floppy)" #~ msgstr "" #~ "Нямам достъп да модулите на ядрото съответстващи на вашият (файл %s " #~ "липсва), това означава, че вашето флопи не е синхронизирано с " #~ "инсталационният носител (моля направете ново boot флопи)"