From 0b2e5d22188febeb98b3464bd9a9c2d487bb6357 Mon Sep 17 00:00:00 2001 From: Antoine Ginies Date: Wed, 9 Mar 2011 08:12:52 +0000 Subject: add GPT support --- perl-install/install/steps_interactive.pm | 69 +++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'perl-install/install/steps_interactive.pm') diff --git a/perl-install/install/steps_interactive.pm b/perl-install/install/steps_interactive.pm index 399f6ada6..920dad93f 100644 --- a/perl-install/install/steps_interactive.pm +++ b/perl-install/install/steps_interactive.pm @@ -121,6 +121,75 @@ sub selectKeyboard { } } +#------------------------------------------------------------------------------ +sub selectPartitionTable { + my ($o, $clicked) = @_; + my @drives = detect_devices::hds(); + my $part_type; my @bigdrives; my $reboot; + + foreach my $hd (@drives) { + my $full_dev = "/dev/$hd->{device}"; + my ($stdout, @l) = run_program::get_stdout('fdisk', '-s', $full_dev); + my ($size) = $stdout =~ m|(.*)|; + # testing paramater + if ($size > 2 * 1024 * 1024 * 1024 * 1024) { +# if ($size > 248) { + push @bigdrives, $hd; + log::l("selectPartitionTable: $hd->{device} is a big drive ($size MB)"); + } else { + log::l("selectPartitionTable: $hd->{device} not a big drive ($size MB)"); + } + } + my $howmany = @bigdrives; + log::l("selectPartitionTable: $howmany bigdrive(s)"); + sleep 10; + if ($howmany > 0) { + $o->ask_from(N("Partition table modification"), + N("Installer detects big drives (>2To). +GPT partition table is mandatory if you want to create partition bigger than 2To. + +Beware, this operation will be written to disk as soon as you validate! +ALL DATA will be lost: this will erase everything on your harddisk. + +Leave it blanck if you dont want to change the partition table type. + +CAUTION: +In case of modification, system will reboot to take into account the new partition table type and avoid errors."), + [ + (map { { label => N(("Partition table type for: %s (/dev/%s)", $_->{info}, $_->{device})), val => \$selection{$_}, list => [ "", "msdos", "gpt", "dvh", "loop", "mac", "bsd", "pc98", "sun" ], + } } @bigdrives), + ], + complete => sub { + map { + if ($selection{$_} ne "") { + $o->ask_okcancel(N("Last Chance"), N("Partition table Type of this drive %s is going to be written to disk", $_->{device}, 0)) or return 1; + eval { + run_program::run("parted", "/dev/$_->{device}", "mklabel", $selection{$_}, "--script"); + log::l("selectPartitionTable: parted to mklabel $selection{$_}"); + $reboot = 1; + }; + if (my $err = $@) { + if ($err =~ /Error/i) { + log::l("selectPartitionTable: error to switch /dev/$_->{device} to $selection{$_}"); + } else { + log::l("selectPartitionTable: Partition Table %s for /dev/%s", $selection{$_}, $_->{device}); + } + } + } else { + log::l("selectPartitionTable: Dont touch Partition Table for /dev/%s", $_->{device}); + } + } @bigdrives; + 0; + }, + ); + } + if ($reboot eq "1") { + $o->ask_warn('', N("Rebooting now, to update partition table table and avoid errors.")); + install::steps::rebootNeeded($o); + } + install::steps::selectPartitionTable($o); +} + #------------------------------------------------------------------------------ sub selectInstallClass { my ($o) = @_; -- cgit v1.2.1