Skip to content

Commit

Permalink
add support for gpt partition labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrfai committed Jun 27, 2021
1 parent af30f15 commit 9c82cdb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/setup-storage/Commands.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,12 @@ sub rebuild_preserved_partitions {
}
}

# set partition label if it exists
if ($FAI::configs{$config}{disklabel} eq "gpt") {
$part_type = (defined($FAI::configs{$config}{partitions}{$mapped_id}{ptlabel}) ) ?
$FAI::configs{$config}{partitions}{$mapped_id}{ptlabel} : "'\" \"'"; # or empty ptlabel
}

# restore the partition type, if any
my $fs =
$FAI::current_config{$disk}{partitions}{$mapped_id}{filesystem};
Expand Down Expand Up @@ -1335,6 +1341,12 @@ sub setup_partitions {
}
}

# set partition label if it exists
if ($FAI::configs{$config}{disklabel} eq "gpt") {
$part_type = (defined($part->{ptlabel}) ) ?
$part->{ptlabel} : "'\" \"'"; # or empty ptlabel
}

my $fs = (defined($part->{filesystem}) && $part->{filesystem} =~ /\S+/) ?
$part->{filesystem} : "-";
($fs) = split(/:/, $fs);
Expand All @@ -1351,6 +1363,7 @@ sub setup_partitions {
$pre .= ",exist_" . &FAI::make_device_name($disk, $prev_id) if ($prev_id > -1);
# build a parted command to create the partition
my $dn = &FAI::make_device_name($disk, $part_id);

&FAI::push_command( "parted -s $disk mkpart $part_type \"$fs\" ${start}B ${end}B",
$pre, "prep2_$dn");
my $cmd = "true";
Expand Down Expand Up @@ -1475,6 +1488,12 @@ sub restore_partition_table {
}
}

# set partition label if it exists
if ($FAI::current_config{$disk}{disklabel} eq "gpt") {
$part_type = (defined($curr_part->{ptlabel}) ) ?
$curr_part->{ptlabel} : "'\" \"'"; # or empty ptlabel
}

# restore the partition type, if any
my $fs = $curr_part->{filesystem};

Expand Down

0 comments on commit 9c82cdb

Please sign in to comment.