[Thincrust-devel] [PATCH 1/3] Remove extended partition from kpartx output to avoid partition count mismatch and erroneous device assignment

Marc Savy msavy at redhat.com
Fri Aug 3 14:25:05 UTC 2012


With msdos type layouts that have large numbers of partitions, the
output from kpartx displays the extended partition, which is incorrectly
interpreted as meaning an extra partition is present which aught not be.

This patch pops the line from the kpartx output so that it may be safely
ignored.

  From 2dabfe5646ca941ffa09ca3f4fbcb08bf0a2fe52 Mon Sep 17 00:00:00 2001
From: Marc Savy <msavy at redhat.com>
Date: Wed, 18 Jul 2012 14:05:20 +0100
Subject: [PATCH 1/3] Remove extended partition from kpartx output to avoid
   partition count mismatch and erroneous device
   assignment.
To: thincrust-devel at redhat.com

---
   appcreate/partitionedfs.py | 6 ++++++
   1 file changed, 6 insertions(+)

diff --git a/appcreate/partitionedfs.py b/appcreate/partitionedfs.py
index 675ac71..705c2ae 100644
--- a/appcreate/partitionedfs.py
+++ b/appcreate/partitionedfs.py
@@ -46,6 +46,7 @@ class PartitionedMount(Mount):
           self.mountOrder = []
           self.unmountOrder = []
           self.partition_layout = partition_layout
+        self.has_extended = False # Has extended partition layout

       def add_partition(self, size, disk, mountpoint, fstype = None):
           self.partitions.append({'size': size,
@@ -94,6 +95,7 @@ class PartitionedMount(Mount):
           for p in self.partitions:
               d = self.disks[p['disk']]
               if p['num'] == 5 and self.partition_layout == 'msdos':
+                self.has_extended = True
                   logging.debug("Added extended part at %d of size %d" 
% (p['start'], d['extended']))
                   rc = subprocess.call(["/sbin/parted", "-s", 
d['disk'].device, "mkpart", "extended",
                                         "%dM" % p['start'], "%dM" % 
(p['start'] + d['extended'])])
@@ -125,6 +127,10 @@ class PartitionedMount(Mount):
                   raise MountError("Failed to query partition mapping 
for '%s'" %
                                    d.device)

+            # Pop the fourth (extended) partition
+            if self.has_extended:
+                kpartxOutput.pop(3)
+
               # Quick sanity check that the number of partitions matches
               # our expectation. If it doesn't, someone broke the code
               # further up
-- 
1.7.11.2



-------------- next part --------------
From 2dabfe5646ca941ffa09ca3f4fbcb08bf0a2fe52 Mon Sep 17 00:00:00 2001
From: Marc Savy <msavy at redhat.com>
Date: Wed, 18 Jul 2012 14:05:20 +0100
Subject: [PATCH 1/3] Remove extended partition from kpartx output to avoid
 partition count mismatch and erroneous device
 assignment.
To: thincrust-devel at redhat.com

---
 appcreate/partitionedfs.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/appcreate/partitionedfs.py b/appcreate/partitionedfs.py
index 675ac71..705c2ae 100644
--- a/appcreate/partitionedfs.py
+++ b/appcreate/partitionedfs.py
@@ -46,6 +46,7 @@ class PartitionedMount(Mount):
         self.mountOrder = []
         self.unmountOrder = []
         self.partition_layout = partition_layout
+        self.has_extended = False # Has extended partition layout
 
     def add_partition(self, size, disk, mountpoint, fstype = None):
         self.partitions.append({'size': size,
@@ -94,6 +95,7 @@ class PartitionedMount(Mount):
         for p in self.partitions:
             d = self.disks[p['disk']]
             if p['num'] == 5 and self.partition_layout == 'msdos':
+                self.has_extended = True
                 logging.debug("Added extended part at %d of size %d" % (p['start'], d['extended']))
                 rc = subprocess.call(["/sbin/parted", "-s", d['disk'].device, "mkpart", "extended",
                                       "%dM" % p['start'], "%dM" % (p['start'] + d['extended'])])
@@ -125,6 +127,10 @@ class PartitionedMount(Mount):
                 raise MountError("Failed to query partition mapping for '%s'" %
                                  d.device)
 
+            # Pop the fourth (extended) partition
+            if self.has_extended:
+                kpartxOutput.pop(3)
+
             # Quick sanity check that the number of partitions matches
             # our expectation. If it doesn't, someone broke the code
             # further up
-- 
1.7.11.2




More information about the Thincrust-devel mailing list