]> xenbits.xen.org Git - xenclient/build.git/commitdiff
XC-267, XC-278: fix XC-278 partition clearing,
authorChristopher Clark <cclark@thinkpad-t61-x.(none)>
Thu, 17 Sep 2009 10:16:58 +0000 (11:16 +0100)
committerChristopher Clark <cclark@thinkpad-t61-x.(none)>
Thu, 17 Sep 2009 10:16:58 +0000 (11:16 +0100)
make pvremove best effort rather than fail on error

target/generic/target_xenclient_installer_skeleton/install/stages/Trash-and-install

index b9e4f74af725dc09a39fa26135bdf763d9d86d9f..a306e940d9a128809e69f1909804b428473494f8 100755 (executable)
@@ -7,22 +7,21 @@
 
 DEV="/dev/${TARGET_DISK}"
 
-erase_primary_partitions()
+remove_lvm_from_primary_partitions()
 {
     DISK_DEV="$1"
-    mixedgauge "Removing previous disk partitions." 0
+    mixedgauge "Removing LVM state from primary disk partitions." 0
     if ! do_cmd vgchange -a n >&2 ; then
         echo "ERROR: Failure disabling the LVM contents of disk ${DISK_DEV}.">&2
         exit ${Abort}
     fi
-    REMOVED_OK=0
     for DISK_PTN_NODE in ${DISK_DEV}[1-4] ; do
-        [ ! -b "${DISK_PTN_NODE}" ] || do_cmd pvremove -ff -y "${DISK_PTN_NODE}" >&2 || REMOVED_OK=1
+        # Ignore errors returned by pvremove here as there may not
+        # actually be any LVM state to remove.
+        # Any important failures here will also cause the later
+        # creation commands to fail, so handle errors there.
+        [ ! -b "${DISK_PTN_NODE}" ] || do_cmd pvremove -ff -y "${DISK_PTN_NODE}" >&2
     done
-    if [ "${REMOVED_OK}" -ne 0 ] ; then
-        echo "ERROR: Failure erasing the contents of disk ${DEV}.">&2
-        exit ${Abort}
-    fi
 }
 
 mk_xc_partition_layout()
@@ -32,7 +31,7 @@ mk_xc_partition_layout()
     do_cmd sfdisk -D ${DISK_DEV} >&2 <<EOF
 ,,
 EOF
-    do_cmd dd if=/dev/zero of="${DISK_DEV}" bs=512 count=1
+    do_cmd dd if=/dev/zero of="${DISK_DEV}1" bs=512 count=1
     do_cmd sync
     mixedgauge "Activating first partition." 15
     do_cmd sfdisk "${DISK_DEV}" -A1 >&2
@@ -153,7 +152,7 @@ write_disk_mbr()
     return 0
 }
 
-erase_primary_partitions "${DEV}"
+remove_lvm_from_primary_partitions "${DEV}"
 mk_xc_partition_layout "${DEV}"
 install_xc_packages "${DEV}"
 write_disk_mbr "${DEV}"