source: branches/3.2/MondoRescue/lib/MondoRescue/Disk.pm @ 3432

Last change on this file since 3432 was 3432, checked in by Bruno Cornec, 5 years ago
  • Change analyze-my-lvm in order to generate percentage of Extents of a VG to use to create the LV instead of a fixed size. Should improve bugs when creating LVM on a disk of different size greatly.
File size: 1.2 KB
Line 
1#!/usr/bin/perl -w
2#
3# Disk subroutines brought by the MondoRescue project
4#
5# $Id$
6#
7# Copyright B. Cornec 2008-2015
8# Provided under the GPL v2
9
10package MondoRescue::Disk;
11
12use strict 'vars';
13use ProjectBuilder::Base;
14use English;
15
16# Inherit from the "Exporter" module which handles exporting functions.
17
18use Exporter;
19
20# Export, by default, all the functions into the namespace of
21# any code which uses this module.
22
23our @ISA = qw(Exporter);
24our @EXPORT = qw(mr_disk_type);
25
26=pod
27
28=head1 NAME
29
30MondoRescue::Disk, part of the mondorescue.org
31
32=head1 DESCRIPTION
33
34This modules provides disk related functions for the Mondorescue project
35
36=head1 USAGE
37
38=over 4
39
40=item B<mr_disk_type>
41
42This function uses fdisk to determine the type of disk whose device is passed as a parameter
43It returns either msdos for MBR type or gpt for GPT type
44
45=cut
46
47sub mr_disk_type {
48
49my $device = shift;
50# MBR by default
51my $type = "msdos";
52
53my $fdisk = pb_check_req("fdisk",0);
54
55open(FDISK, "$fdisk -l $device 2>/dev/null |") || die "Unable to read from $fdisk";
56while (<FDISK>) {
57    if (($_ =~ /EFI GPT/) || ($_ =~ / GPT /)) {
58        $type= "gpt";
59        last;
60    }
61}
62close(FDISK);
63pb_log(2,"Found a $type partition format\n");
64return ($type);
65}
66
67
Note: See TracBrowser for help on using the repository browser.