[Thincrust-devel] [PATCH 1/4] Add LVM physical volume partition type support
Yongjun Wei
weiyj.lk at gmail.com
Fri Dec 16 09:55:20 UTC 2011
partition using by LVM physical volume is defined in ks.conf
with mntpoint pv.<id>, this patch will allowed partitionedfs
to format LVM physical volumes, and also we should skip mount
of them when mount all the partitions before install os.
Signed-off-by: Wei Yongjun <yongjun_wei at trendmicro.com.cn>
diff --git a/appcreate/partitionedfs.py b/appcreate/partitionedfs.py
index 675ac71..3c6795f 100644
--- a/appcreate/partitionedfs.py
+++ b/appcreate/partitionedfs.py
@@ -108,6 +108,27 @@ class PartitionedMount(Mount):
#if rc != 0 and 1 == 0:
# raise MountError("Error creating partition on %s" % d['disk'].device)
+ def __create_physical_volumes(self):
+ logging.debug("Creating physical volumes")
+ for p in self.partitions:
+ d = self.disks[p['disk']]
+ if p['mountpoint'].startswith("pv."):
+ logging.debug("Set LVM flag on partition %s%d" % (p['disk'], p['num']))
+ rc = subprocess.call(["/sbin/parted", "-s", d['disk'].device, "set",
+ str(p['num']), "lvm", "on"])
+ if rc != 0:
+ raise MountError("Error set LVM flag on partition %s%d" %
+ (p['disk'], p['num']))
+
+ logging.debug("Initialize physical volume %s" % p['device'])
+ rc = subprocess.call(["/sbin/lvm", "pvcreate", p['device']])
+ if rc != 0:
+ raise MountError("Error initialize physical volume %s" % p['device'])
+
+ def __format_volumes(self):
+ logging.debug("Formatting volumes")
+ self.__create_physical_volumes()
+
def __map_partitions(self):
for dev in self.disks.keys():
d = self.disks[dev]
@@ -180,6 +201,9 @@ class PartitionedMount(Mount):
def __calculate_mountorder(self):
for p in self.partitions:
+ if p['mountpoint'].startswith("pv."):
+ continue
+
self.mountOrder.append(p['mountpoint'])
self.unmountOrder.append(p['mountpoint'])
@@ -222,6 +246,7 @@ class PartitionedMount(Mount):
self.__format_disks()
self.__map_partitions()
+ self.__format_volumes()
self.__calculate_mountorder()
for mp in self.mountOrder:
--
1.7.7.4
More information about the Thincrust-devel
mailing list