Hey moblin guys,
moblin-image-creator was failing for me at the parted mklabel call in
class PartitionedMount method __format_disk. If I stopped the error
redirection to /dev/null, I saw the warning: "The kernel was unable to
re-read the partition table on /dev/loop0 (Device or resource busy)."
I saw the failure with moblin-image-creator-2-0.09 and
moblin-image-creator-2-0.12.
This began being a problem for me when I switched my build workstation
switched from a native installation of Fedora 11 to a VMware Player
3.0.0 guest installation of Fedora 12. So I'm not sure if VMware or
Fedora 12 changed the parted behavior.
Patch #1 below ignores the return value from the parted mklabel call.
This duplicates the already existing ignoration of the return value of
the parted mkpart and boot=on calls. This allows me to
This also fixes the printing of the device name in the error, if it
weren't ignored.
This patch is against 0.12, but the same code is in the lastest git. I
was just lazy.
Patch #2 below additionally tries to check whether things are working
using fdisk. This is done earlier than the alreasy existing check
using kpartx in the map_partitions method. Take your pick.
-David
Patch #1 that just ignores the error:
diff -rupN moblin-image-creator-2-0.12/mic/appcreate/partitionedfs.py
moblin-image-creator-2-0.12-ignore-mklabel-error/mic/appcreate/partitionedfs.py
--- moblin-image-creator-2-0.12/mic/appcreate/partitionedfs.py 2009-09-23
02:40:32.000000000 -0500
+++
moblin-image-creator-2-0.12-ignore-mklabel-error/mic/appcreate/partitionedfs.py
2009-11-25
12:32:39.805176861 -0600
@@ -96,9 +96,12 @@ class PartitionedMount(Mount):
# FIXME
rc = subprocess.call([self.parted, "-s",
d['disk'].device, "mklabel", "msdos"],
stdout = dev_null, stderr = dev_null)
- if rc != 0:
+ # XXX disabled return code check because parted always fails to
+ # reload part table with loop devices. Annoying because we can't
+ # distinguish this failure from real partition failures :-(
+ if rc != 0 and 1 == 0:
os.close(dev_null)
- raise MountError("Error writing partition table on
%s" % d.device)
+ raise MountError("Error writing partition table on
%s" % d['disk'].device)
# XXX we should probably work in cylinder units to keep fdisk happier..
start = 0
logging.debug("Creating partitions")
Patch #2 that ignores then checks using fdisk:
diff -rupN moblin-image-creator-2-0.12/mic/appcreate/partitionedfs.py
moblin-image-creator-2-0.12-fix-mklabel-error/mic/appcreate/partitionedfs.py
--- moblin-image-creator-2-0.12/mic/appcreate/partitionedfs.py 2009-09-23
02:40:32.000000000 -0500
+++
moblin-image-creator-2-0.12-fix-mklabel-error/mic/appcreate/partitionedfs.py
2009-11-25
15:36:11.670210586 -0600
@@ -48,6 +48,7 @@ class PartitionedMount(Mount):
self.parted="/usr/sbin/parted"
if not os.path.exists(self.parted):
self.parted="/sbin/parted"
+ self.fdisk="/sbin/fdisk"
self.skipformat = skipformat
def add_partition(self, size, disk, mountpoint, fstype = None,
boot = False):
@@ -93,12 +94,14 @@ class PartitionedMount(Mount):
for dev in self.disks.keys():
d = self.disks[dev]
logging.debug("Initializing partition table for %s" %
(d['disk'].device))
- # FIXME
rc = subprocess.call([self.parted, "-s",
d['disk'].device, "mklabel", "msdos"],
stdout = dev_null, stderr = dev_null)
- if rc != 0:
+ # XXX disabled return code check because parted always fails to
+ # reload part table with loop devices. Annoying because we can't
+ # distinguish this failure from real partition failures :-(
+ if rc != 0 and 1 == 0:
os.close(dev_null)
- raise MountError("Error writing partition table on
%s" % d.device)
+ raise MountError("Error writing partition table on
%s" % d['disk'].device)
# XXX we should probably work in cylinder units to keep fdisk happier..
start = 0
logging.debug("Creating partitions")
@@ -124,6 +127,15 @@ class PartitionedMount(Mount):
if rc != 0 and 1 == 0:
os.close(dev_null)
raise MountError("Error creating partition on %s" %
d['disk'].device)
+ logging.debug("Checking that partition %sp%d was made" %
(d['disk'].device, p['num']))
+ proc_fdisk = subprocess.Popen([self.fdisk, "-l",
d['disk'].device], stdout=subprocess.PIPE)
+ str_fdisk = proc_fdisk.communicate()[0]
+ if proc_fdisk.returncode != 0:
+ os.close(dev_null)
+ raise MountError("Error with fisk while checking
device %s partition %d" % (d['disk'].device, p['num']))
+ if str_fdisk.find("%sp%d" %(d['disk'].device, p['num'])) == -1:
+ os.close(dev_null)
+ raise MountError("Error creating device %s partition
%d" % (d['disk'].device, p['num']))
os.close(dev_null)
def __map_partitions(self):
_______________________________________________
Moblin dev Mailing List
[email protected]
To manage or unsubscribe from this mailing list visit:
http://lists.moblin.org/listinfo/dev or your user account on http://moblin.org
once logged in.
For more information on the Moblin Developer Mailing lists visit:
http://moblin.org/community/mailing-lists