Skip to contentSkip to conversation

running pygrub on split-partition disk layouts.

PATCH Ian Campbell 3 participants 3 messages Nov 21, 2014 – Dec 13, 2014

lore
Share & tools
lore
#0 lore raw

An absolute age ago Michael posted a patch to allow pygrub to work with split-partition layouts (i.e. those where the guests disk cfg refers to xvda1, xvda2, etc rather than an xvda with a partition table). See
http://lists.xen.org/archives/html/xen-devel/2011-01/msg02076.html
(patch itself is below).

Apparently at the time I was of the opinion that this was a reasonable workaround for the underlying issue (although I seem to have thought I had a better solution, not so sure right now...).

I'm not sure why it didn't go in (in the likely event I just dropped the ball -- sorry!).

Anyway, this resurfaced recently in the context of Debian bug #745419:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=745419#27

#745419 seems to be unrelated to Michael's issue, it is a full disk image case with an MBR etc.

Michael, are you still carrying this patch to the Fedora packages? If so presumably it is without issue in the field so to speak?

Should the patch be resurrected for either 4.5 or 4.6? Or does anyone have any other insights into the various issues?

Ian.

tools/pygrub/src/pygrub renamed from tools/pygrub/src/pygrub.orig +5 -0
@@ -96,6 +96,7 @@
 
     fd = os.open(file, os.O_RDONLY)
     buf = os.read(fd, 512)
+    offzerocount = 0
     for poff in (446, 462, 478, 494): # partition offsets
 
         # MBR contains a 16 byte descriptor per partition
@@ -105,6 +106,7 @@
         
         # offset == 0 implies this partition is not enabled
         if offset == 0:
+            offzerocount += 1
             continue
 
         if type == FDISK_PART_SOLARIS or type == FDISK_PART_SOLARIS_OLD:
@@ -123,6 +125,9 @@
         else:
             part_offs.append(offset)
 
+    if offzerocount == 4:
+        # Might be a grub boot sector pretending to be an MBR
+        part_offs.append(0)
     return part_offs
 
 class GrubLineEditor(curses.textpad.Textbox):
#1 lore raw
Quoted 13 lines · Ian Campbell

An absolute age ago Michael posted a patch to allow pygrub to work with split-partition layouts (i.e. those where the guests disk cfg refers to xvda1, xvda2, etc rather than an xvda with a partition table). See
http://lists.xen.org/archives/html/xen-devel/2011-01/msg02076.html
(patch itself is below).

Apparently at the time I was of the opinion that this was a reasonable workaround for the underlying issue (although I seem to have thought I had a better solution, not so sure right now...).

I'm not sure why it didn't go in (in the likely event I just dropped the ball -- sorry!).

Quoted 8 lines

Anyway, this resurfaced recently in the context of Debian bug #745419:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=745419#27

#745419 seems to be unrelated to Michael's issue, it is a full disk image case with an MBR etc.

Michael, are you still carrying this patch to the Fedora packages? If so presumably it is without issue in the field so to speak?

Yes, it is still in Fedora (with a minor change to get it to apply as a line was added in the surrounding code). I haven't seen any bug reports relating to this patch.

Michael Young

#2 lore raw
In reply to Ian Campbell
Quoted 13 lines · Ian Campbell

An absolute age ago Michael posted a patch to allow pygrub to work with split-partition layouts (i.e. those where the guests disk cfg refers to xvda1, xvda2, etc rather than an xvda with a partition table). See
http://lists.xen.org/archives/html/xen-devel/2011-01/msg02076.html
(patch itself is below).

Apparently at the time I was of the opinion that this was a reasonable workaround for the underlying issue (although I seem to have thought I had a better solution, not so sure right now...).

I'm not sure why it didn't go in (in the likely event I just dropped the ball -- sorry!).

Quoted 8 lines

Anyway, this resurfaced recently in the context of Debian bug #745419:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=745419#27

#745419 seems to be unrelated to Michael's issue, it is a full disk image case with an MBR etc.

Michael, are you still carrying this patch to the Fedora packages? If so presumably it is without issue in the field so to speak?

ping?

Quoted 41 lines

Should the patch be resurrected for either 4.5 or 4.6? Or does anyone have any other insights into the various issues?

Ian.

tools/pygrub/src/pygrub renamed from tools/pygrub/src/pygrub.orig +5 -0
@@ -96,6 +96,7 @@
 
     fd = os.open(file, os.O_RDONLY)
     buf = os.read(fd, 512)
+    offzerocount = 0
     for poff in (446, 462, 478, 494): # partition offsets
 
         # MBR contains a 16 byte descriptor per partition
@@ -105,6 +106,7 @@
 
         # offset == 0 implies this partition is not enabled
         if offset == 0:
+            offzerocount += 1
             continue
 
         if type == FDISK_PART_SOLARIS or type == FDISK_PART_SOLARIS_OLD:
@@ -123,6 +125,9 @@
         else:
             part_offs.append(offset)
 
+    if offzerocount == 4:
+        # Might be a grub boot sector pretending to be an MBR
+        part_offs.append(0)
     return part_offs
 
 class GrubLineEditor(curses.textpad.Textbox):

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel